-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge package:test_descriptor into the test monorepo
- Loading branch information
Showing
25 changed files
with
1,859 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Dependabot configuration file. | ||
version: 2 | ||
|
||
updates: | ||
- package-ecosystem: github-actions | ||
directory: / | ||
schedule: | ||
interval: monthly | ||
labels: | ||
- autosubmit | ||
groups: | ||
github-actions: | ||
patterns: | ||
- "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Dart CI | ||
|
||
on: | ||
# Run on PRs and pushes to the default branch. | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
schedule: | ||
- cron: "0 0 * * 0" | ||
|
||
env: | ||
PUB_ENVIRONMENT: bot.github | ||
|
||
permissions: read-all | ||
|
||
jobs: | ||
# Check code formatting and static analysis on a single OS (linux) | ||
# against Dart dev. | ||
analyze: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
sdk: [dev] | ||
steps: | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | ||
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 | ||
with: | ||
sdk: ${{ matrix.sdk }} | ||
- id: install | ||
name: Install dependencies | ||
run: dart pub get | ||
- name: Check formatting | ||
run: dart format --output=none --set-exit-if-changed . | ||
if: always() && steps.install.outcome == 'success' | ||
- name: Analyze code | ||
run: dart analyze --fatal-infos | ||
if: always() && steps.install.outcome == 'success' | ||
|
||
# Run tests on a matrix consisting of two dimensions: | ||
# 1. OS: ubuntu-latest, (macos-latest, windows-latest) | ||
# 2. release channel: dev | ||
test: | ||
needs: analyze | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
# Add macos-latest and/or windows-latest if relevant for this package. | ||
os: [ubuntu-latest] | ||
sdk: [3.1, dev] | ||
steps: | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | ||
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 | ||
with: | ||
sdk: ${{ matrix.sdk }} | ||
- id: install | ||
name: Install dependencies | ||
run: dart pub get | ||
- name: Run VM tests | ||
run: dart test --platform vm | ||
if: always() && steps.install.outcome == 'success' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.buildlog | ||
.DS_Store | ||
.idea | ||
.settings/ | ||
build/ | ||
packages | ||
.packages | ||
pubspec.lock | ||
.dart_tool/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Below is a list of people and organizations that have contributed | ||
# to the project. Names should be added to the list like so: | ||
# | ||
# Name/Organization <email address> | ||
|
||
Google Inc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
## 2.0.2-wip | ||
|
||
* Require Dart 3.1 or later. | ||
|
||
## 2.0.1 | ||
|
||
* Populate the pubspec `repository` field. | ||
* Migrate to `package:lints`. | ||
* Update the package's markdown badges. | ||
|
||
## 2.0.0 | ||
|
||
* Null safety stable release. | ||
* BREAKING: Removed archive support. | ||
* BREAKING: `DirectoryDescriptor.load` only supports a `String` path instead of | ||
also accepting relative `Uri` objects. | ||
* BREAKING: `DirectoryDescriptor.load` no longer has an optional `parents` | ||
parameter - this was intended for internal use only. | ||
|
||
## 1.2.0 | ||
|
||
* Add an `ArchiveDescriptor` class and a corresponding `archive()` function that | ||
can create and validate Zip and TAR archives. | ||
|
||
## 1.1.1 | ||
|
||
* Update to lowercase Dart core library constants. | ||
|
||
## 1.1.0 | ||
|
||
* Add a `path()` function that returns the a path within the sandbox directory. | ||
|
||
* Add `io` getters to `FileDescriptor` and `DirectoryDescriptor` that returns | ||
`dart:io` `File` and `Directory` objects, respectively, within the sandbox | ||
directory. | ||
|
||
## 1.0.4 | ||
|
||
* Support test `1.x.x'. | ||
|
||
## 1.0.3 | ||
|
||
* Stop using comment-based generics. | ||
|
||
## 1.0.2 | ||
|
||
* Declare support for `async` 2.0.0. | ||
|
||
## 1.0.1 | ||
|
||
* `FileDescriptor.validate()` now allows invalid UTF-8 files. | ||
|
||
* Fix a bug where `DirectoryDescriptor.load()` would incorrectly report that | ||
multiple versions of a file or directory existed. | ||
|
||
## 1.0.0 | ||
|
||
* Initial version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
Want to contribute? Great! First, read this page (including the small print at | ||
the end). | ||
|
||
### Before you contribute | ||
Before we can use your code, you must sign the | ||
[Google Individual Contributor License Agreement](https://cla.developers.google.com/about/google-individual) | ||
(CLA), which you can do online. The CLA is necessary mainly because you own the | ||
copyright to your changes, even after your contribution becomes part of our | ||
codebase, so we need your permission to use and distribute your code. We also | ||
need to be sure of various other things—for instance that you'll tell us if you | ||
know that your code infringes on other people's patents. You don't have to sign | ||
the CLA until after you've submitted your code for review and a member has | ||
approved it, but you must do it before we can put your code into our codebase. | ||
|
||
Before you start working on a larger contribution, you should get in touch with | ||
us first through the issue tracker with your idea so that we can help out and | ||
possibly guide you. Coordinating up front makes it much easier to avoid | ||
frustration later on. | ||
|
||
### Code reviews | ||
All submissions, including submissions by project members, require review. | ||
|
||
### File headers | ||
All files in the project must start with the following header. | ||
|
||
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
### The small print | ||
Contributions made by corporations are covered by a different agreement than the | ||
one above, the | ||
[Software Grant and Corporate Contributor License Agreement](https://developers.google.com/open-source/cla/corporate). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Copyright 2016, the Dart project authors. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are | ||
met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided | ||
with the distribution. | ||
* Neither the name of Google LLC nor the names of its | ||
contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
[![Dart CI](https://github.com/dart-lang/test_descriptor/actions/workflows/test-package.yml/badge.svg)](https://github.com/dart-lang/test_descriptor/actions/workflows/test-package.yml) | ||
[![pub package](https://img.shields.io/pub/v/test_descriptor.svg)](https://pub.dev/packages/test_descriptor) | ||
[![package publisher](https://img.shields.io/pub/publisher/test_descriptor.svg)](https://pub.dev/packages/test_descriptor/publisher) | ||
|
||
The `test_descriptor` package provides a convenient, easy-to-read API for | ||
defining and verifying directory structures in tests. | ||
|
||
## Usage | ||
|
||
We recommend that you import this library with the `d` prefix. The | ||
[`d.dir()`][dir] and [`d.file()`][file] functions are the main entrypoints. They | ||
define a filesystem structure that can be created using | ||
[`Descriptor.create()`][create] and verified using | ||
[`Descriptor.validate()`][validate]. For example: | ||
|
||
[dir]: https://pub.dev/documentation/test_descriptor/latest/test_descriptor/dir.html | ||
[file]: https://pub.dev/documentation/test_descriptor/latest/test_descriptor/file.html | ||
[create]: https://pub.dev/documentation/test_descriptor/latest/test_descriptor/Descriptor/create.html | ||
[validate]: https://pub.dev/documentation/test_descriptor/latest/test_descriptor/Descriptor/validate.html | ||
|
||
```dart | ||
import 'dart:io'; | ||
import 'package:test/test.dart'; | ||
import 'package:test_descriptor/test_descriptor.dart' as d; | ||
void main() { | ||
test('Directory.rename', () async { | ||
await d.dir('parent', [ | ||
d.file('sibling', 'sibling-contents'), | ||
d.dir('old-name', [d.file('child', 'child-contents')]) | ||
]).create(); | ||
await Directory('${d.sandbox}/parent/old-name') | ||
.rename('${d.sandbox}/parent/new-name'); | ||
await d.dir('parent', [ | ||
d.file('sibling', 'sibling-contents'), | ||
d.dir('new-name', [d.file('child', 'child-contents')]) | ||
]).validate(); | ||
}); | ||
} | ||
``` | ||
|
||
By default, descriptors create entries in a temporary sandbox directory, | ||
[`d.sandbox`][sandbox]. A new sandbox is automatically created the first time | ||
you create a descriptor in a given test, and automatically deleted once the test | ||
finishes running. | ||
|
||
[sandbox]: https://pub.dev/documentation/test_descriptor/latest/test_descriptor/sandbox.html | ||
|
||
This package is [`term_glyph`][term_glyph] aware. It will decide whether to use | ||
ASCII or Unicode glyphs based on the [`glyph.ascii`][ascii] attribute. | ||
|
||
[term_glyph]: https://pub.dev/packages/term_glyph | ||
[ascii]: https://pub.dev/documentation/term_glyph/latest/term_glyph/ascii.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# https://dart.dev/guides/language/analysis-options | ||
include: package:dart_flutter_team_lints/analysis_options.yaml | ||
|
||
analyzer: | ||
language: | ||
strict-casts: true | ||
strict-inference: true | ||
strict-raw-types: true | ||
|
||
linter: | ||
rules: | ||
- avoid_bool_literals_in_conditional_expressions | ||
- avoid_classes_with_only_static_members | ||
- avoid_private_typedef_functions | ||
- avoid_redundant_argument_values | ||
- avoid_returning_this | ||
- avoid_unused_constructor_parameters | ||
- avoid_void_async | ||
- cancel_subscriptions | ||
- join_return_with_assignment | ||
- literal_only_boolean_expressions | ||
- missing_whitespace_between_adjacent_strings | ||
- no_adjacent_strings_in_list | ||
- no_runtimeType_toString | ||
- prefer_const_declarations | ||
- prefer_expression_function_bodies | ||
- prefer_final_locals | ||
- unnecessary_await_in_return | ||
- unnecessary_raw_strings | ||
- use_if_null_to_convert_nulls_to_bools | ||
- use_raw_strings | ||
- use_string_buffers | ||
- require_trailing_commas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'dart:io'; | ||
|
||
import 'package:test/test.dart'; | ||
import 'package:test_descriptor/test_descriptor.dart' as d; | ||
|
||
void main() { | ||
test('Directory.rename', () async { | ||
await d.dir('parent', [ | ||
d.file('sibling', 'sibling-contents'), | ||
d.dir('old-name', [d.file('child', 'child-contents')]), | ||
]).create(); | ||
|
||
await Directory('${d.sandbox}/parent/old-name') | ||
.rename('${d.sandbox}/parent/new-name'); | ||
|
||
await d.dir('parent', [ | ||
d.file('sibling', 'sibling-contents'), | ||
d.dir('new-name', [d.file('child', 'child-contents')]), | ||
]).validate(); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'sandbox.dart'; | ||
|
||
/// A declarative description of a filesystem entry. | ||
/// | ||
/// This may be extended outside this package. | ||
abstract class Descriptor { | ||
/// This entry's basename. | ||
final String name; | ||
|
||
Descriptor(this.name); | ||
|
||
/// Creates this entry within the [parent] directory, which defaults to | ||
/// [sandbox]. | ||
Future<void> create([String? parent]); | ||
|
||
/// Validates that the physical file system under [parent] (which defaults to | ||
/// [sandbox]) contains an entry that matches this descriptor. | ||
Future<void> validate([String? parent]); | ||
|
||
/// Returns a human-friendly tree-style description of this descriptor. | ||
String describe(); | ||
} |
Oops, something went wrong.