Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
4029d52
Add template files.
nex3 Dec 29, 2016
3934d0b
Add the contents of the package. (dart-lang/test_descriptor#1)
nex3 Jan 18, 2017
b16348d
Allow malformed UTF-8. (dart-lang/test_descriptor#3)
nex3 Jun 1, 2017
0720149
Fix a precedence bug in DirectoryDescriptor.load(). (dart-lang/test_d…
nex3 Jun 1, 2017
92094aa
Fix a broken link in the README. (dart-lang/test_descriptor#4)
nex3 Jun 6, 2017
9416037
Declare support for async 2.0.0 (dart-lang/test_descriptor#5)
nex3 Sep 22, 2017
5365a29
Enable Travis-CI (dart-lang/test_descriptor#8)
kevmoo Oct 13, 2017
f22a69b
Remove comment-based generic syntax (dart-lang/test_descriptor#10)
nex3 Oct 17, 2017
f188cdf
Support test 1.x.x
grouma Jun 15, 2018
1bf333d
Merge pull request dart-lang/test_descriptor#14 from dart-lang/test-u…
grouma Jun 15, 2018
d9a6cac
Add helpers to make it easier to do stuff in the sandbox (dart-lang/t…
nex3 Jun 18, 2018
0f753c2
Fix code awaiting void values, for dart 2.
MichaelRFairhurst Jun 29, 2018
c2dab5a
Fix dart:convert "UTF8" -> "utf8".
munificent Jul 12, 2018
9f15b41
Don't run Travis on stable.
munificent Jul 12, 2018
1912687
Merge pull request dart-lang/test_descriptor#18 from dart-lang/dart-2…
munificent Jul 13, 2018
a115baf
Enable and fix a number of lints, test on the oldest supported SDK (d…
kevmoo Apr 30, 2019
139dfc9
Fix missing_return violation newly enforced in Dart ~2.3.2-dev.0.1 (d…
srawlins May 23, 2019
bf11985
Add an archive descriptor (dart-lang/test_descriptor#21)
nex3 Jun 12, 2019
7237f10
Test on oldest supported Dart SDK (2.0.0)
kevmoo Sep 10, 2019
5defcba
Fix URLs
kevmoo Sep 10, 2019
1959a77
Fix newly enforced package:pedantic lints (dart-lang/test_descriptor#23)
natebosch Dec 9, 2019
65d7dbc
remove author from pubspec
kevmoo Mar 13, 2020
eaf1432
Bump min Dart SDK to 2.7 (dart-lang/test_descriptor#24)
kevmoo Jul 7, 2020
53f4eed
Remove unused dep on package:stack_trace (dart-lang/test_descriptor#26)
natebosch Sep 1, 2020
7c4677c
Remove unused dart:async imports (dart-lang/test_descriptor#27)
MichaelRFairhurst Sep 26, 2020
5d74c52
Migrate to runZonedGuarded (dart-lang/test_descriptor#28)
natebosch Nov 3, 2020
7e7be21
Migrate to null safety (dart-lang/test_descriptor#29)
jakemac53 Nov 5, 2020
07879dd
clean up some apis (dart-lang/test_descriptor#30)
jakemac53 Nov 5, 2020
a09855d
Remove unused dependency on package:meta (dart-lang/test_descriptor#31)
natebosch Nov 5, 2020
cb319bf
Remove unused dart:async imports. (dart-lang/test_descriptor#32)
srawlins Nov 22, 2020
6ea0b78
Migrate to GitHub Actions (dart-lang/test_descriptor#33)
athomas Jan 20, 2021
6f4fcb0
stable null safety release (dart-lang/test_descriptor#34)
jakemac53 Feb 9, 2021
64f5c51
Update LICENSE (dart-lang/test_descriptor#35)
franklinyow Mar 31, 2021
9f8f62b
Add dependabot
kevmoo Jun 5, 2021
81a712b
Bump dart-lang/setup-dart from 0.3 to 1 (dart-lang/test_descriptor#36)
dependabot[bot] Jun 5, 2021
f22b8eb
Migrate to pkg:lints, enable two disable lints (dart-lang/test_descri…
kevmoo Oct 4, 2021
d34b480
Bump actions/checkout from 2 to 3 (dart-lang/test_descriptor#39)
dependabot[bot] Mar 2, 2022
1b703a6
populate the repository field (dart-lang/test_descriptor#40)
devoncarew May 3, 2022
c4a9f9c
Move TestOn annotation to library level (dart-lang/test_descriptor#41)
natebosch May 24, 2022
068bd47
Remove deprecated experimental invariant_booleans lint rule (dart-lan…
srawlins Jul 25, 2022
25339ef
Add permission key to CI (dart-lang/test_descriptor#43)
kevmoo Jul 29, 2022
7f94d3b
update the CI configuration; prep for publishing (dart-lang/test_desc…
devoncarew Oct 7, 2022
fc7b4ec
update lints (dart-lang/test_descriptor#45)
kevmoo Nov 7, 2022
c2f2a40
Bump actions/checkout from 3.1.0 to 3.2.0 (dart-lang/test_descriptor#46)
dependabot[bot] Jan 3, 2023
268564a
Bump actions/checkout from 3.2.0 to 3.3.0 (dart-lang/test_descriptor#47)
dependabot[bot] Feb 1, 2023
f95831e
Bump dart-lang/setup-dart from 1.3 to 1.4 (dart-lang/test_descriptor#48)
dependabot[bot] Feb 1, 2023
8a46712
Bump actions/checkout from 3.3.0 to 3.5.0 (dart-lang/test_descriptor#50)
dependabot[bot] Apr 3, 2023
6e1e998
Bump dart-lang/setup-dart from 1.4.0 to 1.5.0 (dart-lang/test_descrip…
dependabot[bot] Apr 3, 2023
5d041fe
Bump actions/checkout from 3.5.0 to 3.5.2 (dart-lang/test_descriptor#51)
dependabot[bot] May 8, 2023
64b9f9a
blast_repo fixes (dart-lang/test_descriptor#52)
devoncarew May 22, 2023
69447ae
update formatting for recent lints (dart-lang/test_descriptor#54)
devoncarew Jul 4, 2023
23876d6
Bump actions/checkout from 3.5.2 to 3.5.3 (dart-lang/test_descriptor#53)
dependabot[bot] Jul 18, 2023
4964036
Bump actions/checkout from 3.5.3 to 3.6.0 (dart-lang/test_descriptor#55)
dependabot[bot] Sep 1, 2023
ed138a9
Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (dart-lang/test_descrip…
dependabot[bot] Oct 1, 2023
90e0e41
Bump actions/checkout from 3.6.0 to 4.1.0 (dart-lang/test_descriptor#57)
dependabot[bot] Oct 2, 2023
dad3878
Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (dart-lang/test_descrip…
dependabot[bot] Nov 1, 2023
80e218d
Bump actions/checkout from 4.1.0 to 4.1.1 (dart-lang/test_descriptor#59)
dependabot[bot] Nov 1, 2023
4f32b9b
Bump and fix latest lints, require Dart 3.1 (dart-lang/test_descripto…
kevmoo Nov 29, 2023
db63bd7
Bump dart-lang/setup-dart from 1.6.0 to 1.6.2 (dart-lang/test_descrip…
dependabot[bot] Feb 1, 2024
c8528c2
Bump actions/checkout from 4.1.1 to 4.1.2 (dart-lang/test_descriptor#62)
dependabot[bot] Apr 1, 2024
18b5287
Bump actions/checkout from 4.1.2 to 4.1.4 (dart-lang/test_descriptor#63)
dependabot[bot] May 1, 2024
3f87f74
Bump dart-lang/setup-dart from 1.6.2 to 1.6.4 (dart-lang/test_descrip…
dependabot[bot] May 1, 2024
e74c332
blast_repo fixes (dart-lang/test_descriptor#65)
devoncarew May 10, 2024
67dc6e8
Bump actions/checkout from 4.1.4 to 4.1.5 in the github-actions group…
dependabot[bot] May 10, 2024
62cda69
Bump actions/checkout from 4.1.5 to 4.1.6 in the github-actions group…
dependabot[bot] Jun 1, 2024
bffa621
update lints (dart-lang/test_descriptor#68)
kevmoo Jun 20, 2024
a9284c1
Bump the github-actions group with 2 updates (dart-lang/test_descript…
dependabot[bot] Jul 1, 2024
3dc3cbe
Fix angle brackets in doc comments (dart-lang/test_descriptor#70)
kevmoo Aug 26, 2024
d137708
Bump actions/checkout from 4.1.7 to 4.2.0 in the github-actions group…
dependabot[bot] Oct 1, 2024
3184eef
blast_repo fixes (dart-lang/test_descriptor#72)
kevmoo Oct 29, 2024
7369e36
Bump actions/checkout from 4.2.0 to 4.2.2 in the github-actions group…
dependabot[bot] Nov 1, 2024
4d40412
Bump dart-lang/setup-dart in the github-actions group (dart-lang/test…
dependabot[bot] Dec 1, 2024
9d7c6dc
Merge package:test_descriptor into the test monorepo
mosuem Dec 12, 2024
b42c80e
Add issue template and other fixes
mosuem Dec 12, 2024
9f70ed2
Moving fixes
mosuem Dec 12, 2024
711978a
Merge branch 'master' into merge-test_descriptor-package
mosuem Dec 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/test_descriptor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
name: "package:test_descriptor"
about: "Create a bug or file a feature request against package:test_descriptor."
labels: "package:test_descriptor"
---
72 changes: 72 additions & 0 deletions .github/workflows/test_descriptor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: package:test_descriptor

on:
# Run on PRs and pushes to the default branch.
push:
branches: [ master ]
paths:
- '.github/workflows/test_descriptor.yaml'
- 'pkgs/test_descriptor/**'
pull_request:
branches: [ master ]
paths:
- '.github/workflows/test_descriptor.yaml'
- 'pkgs/test_descriptor/**'
schedule:
- cron: "0 0 * * 0"

env:
PUB_ENVIRONMENT: bot.github


defaults:
run:
working-directory: pkgs/test_descriptor/

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'
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ literate API.
| [test](pkgs/test/) | A full featured library for writing and running Dart tests across platforms. | [![pub package](https://img.shields.io/pub/v/test.svg)](https://pub.dev/packages/test) |
| [test_api](pkgs/test_api/) | | [![pub package](https://img.shields.io/pub/v/test_api.svg)](https://pub.dev/packages/test_api) |
| [test_core](pkgs/test_core/) | | [![pub package](https://img.shields.io/pub/v/test_core.svg)](https://pub.dev/packages/test_core) |
| [test_descriptor](pkgs/test_descriptor/) | An API for defining and verifying files and directory structures. | [![pub package](https://img.shields.io/pub/v/test_descriptor.svg)](https://pub.dev/packages/test_descriptor) |
| [test_process](pkgs/test_process/) | Test processes: starting; validating stdout and stderr; checking exit code | [![pub package](https://img.shields.io/pub/v/test_process.svg)](https://pub.dev/packages/test_process) |
9 changes: 9 additions & 0 deletions pkgs/test_descriptor/.gitignore
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/
6 changes: 6 additions & 0 deletions pkgs/test_descriptor/AUTHORS
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.
59 changes: 59 additions & 0 deletions pkgs/test_descriptor/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
## 2.0.2

* Require Dart 3.1 or later.
* Move to `dart-lang/test` monorepo.

## 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.
27 changes: 27 additions & 0 deletions pkgs/test_descriptor/LICENSE
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.
56 changes: 56 additions & 0 deletions pkgs/test_descriptor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[![Build Status](https://github.com/dart-lang/test/actions/workflows/test_descriptor.yaml/badge.svg)](https://github.com/dart-lang/test/actions/workflows/test_descriptor.yaml)
[![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
33 changes: 33 additions & 0 deletions pkgs/test_descriptor/analysis_options.yaml
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
25 changes: 25 additions & 0 deletions pkgs/test_descriptor/example/example.dart
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();
});
}
26 changes: 26 additions & 0 deletions pkgs/test_descriptor/lib/src/descriptor.dart
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();
}
Loading
Loading