From 4029d524fb7e82a3dbaaa71e67940687199d08cd Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Wed, 28 Dec 2016 17:46:24 -0800 Subject: [PATCH 01/72] Add template files. --- pkgs/test_descriptor/.analysis_options | 2 ++ pkgs/test_descriptor/.gitignore | 9 +++++++ pkgs/test_descriptor/AUTHORS | 6 +++++ pkgs/test_descriptor/CHANGELOG.md | 3 +++ pkgs/test_descriptor/CONTRIBUTING.md | 33 ++++++++++++++++++++++++++ pkgs/test_descriptor/LICENSE | 26 ++++++++++++++++++++ pkgs/test_descriptor/README.md | 2 ++ pkgs/test_descriptor/pubspec.yaml | 8 +++++++ 8 files changed, 89 insertions(+) create mode 100644 pkgs/test_descriptor/.analysis_options create mode 100644 pkgs/test_descriptor/.gitignore create mode 100644 pkgs/test_descriptor/AUTHORS create mode 100644 pkgs/test_descriptor/CHANGELOG.md create mode 100644 pkgs/test_descriptor/CONTRIBUTING.md create mode 100644 pkgs/test_descriptor/LICENSE create mode 100644 pkgs/test_descriptor/README.md create mode 100644 pkgs/test_descriptor/pubspec.yaml diff --git a/pkgs/test_descriptor/.analysis_options b/pkgs/test_descriptor/.analysis_options new file mode 100644 index 000000000..a10d4c5a0 --- /dev/null +++ b/pkgs/test_descriptor/.analysis_options @@ -0,0 +1,2 @@ +analyzer: + strong-mode: true diff --git a/pkgs/test_descriptor/.gitignore b/pkgs/test_descriptor/.gitignore new file mode 100644 index 000000000..25a1df332 --- /dev/null +++ b/pkgs/test_descriptor/.gitignore @@ -0,0 +1,9 @@ +.buildlog +.DS_Store +.idea +.pub/ +.settings/ +build/ +packages +.packages +pubspec.lock diff --git a/pkgs/test_descriptor/AUTHORS b/pkgs/test_descriptor/AUTHORS new file mode 100644 index 000000000..e8063a8cd --- /dev/null +++ b/pkgs/test_descriptor/AUTHORS @@ -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 + +Google Inc. diff --git a/pkgs/test_descriptor/CHANGELOG.md b/pkgs/test_descriptor/CHANGELOG.md new file mode 100644 index 000000000..5b26ad30f --- /dev/null +++ b/pkgs/test_descriptor/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 + +* Initial version. diff --git a/pkgs/test_descriptor/CONTRIBUTING.md b/pkgs/test_descriptor/CONTRIBUTING.md new file mode 100644 index 000000000..6f5e0ea67 --- /dev/null +++ b/pkgs/test_descriptor/CONTRIBUTING.md @@ -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). diff --git a/pkgs/test_descriptor/LICENSE b/pkgs/test_descriptor/LICENSE new file mode 100644 index 000000000..82e9b524a --- /dev/null +++ b/pkgs/test_descriptor/LICENSE @@ -0,0 +1,26 @@ +Copyright 2016, the Dart project authors. All rights reserved. +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 Inc. 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. diff --git a/pkgs/test_descriptor/README.md b/pkgs/test_descriptor/README.md new file mode 100644 index 000000000..95b216eed --- /dev/null +++ b/pkgs/test_descriptor/README.md @@ -0,0 +1,2 @@ +The `test_descriptor` package provides a convenient, easy-to-read API for +defining and verifying directory structures in tests. diff --git a/pkgs/test_descriptor/pubspec.yaml b/pkgs/test_descriptor/pubspec.yaml new file mode 100644 index 000000000..97328ce8a --- /dev/null +++ b/pkgs/test_descriptor/pubspec.yaml @@ -0,0 +1,8 @@ +name: test_descriptor +version: 1.0.0 +description: An API for defining and verifying directory structures. +author: Dart Team +homepage: https://github.com/dart-lang/test_descriptor + +environment: + sdk: '>=1.8.0 <2.0.0' From 3934d0b19a36ccabcbd92937fe5b1ae6fabb315b Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Wed, 18 Jan 2017 14:03:38 -0800 Subject: [PATCH 02/72] Add the contents of the package. (dart-lang/test_descriptor#1) This is ported from the scheduled_test package, altered to remove scheduling and to use a more modern style. --- pkgs/test_descriptor/README.md | 51 +++ pkgs/test_descriptor/lib/src/descriptor.dart | 26 ++ .../lib/src/directory_descriptor.dart | 140 +++++++++ .../lib/src/file_descriptor.dart | 194 ++++++++++++ .../lib/src/nothing_descriptor.dart | 37 +++ .../lib/src/pattern_descriptor.dart | 99 ++++++ pkgs/test_descriptor/lib/src/sandbox.dart | 33 ++ pkgs/test_descriptor/lib/src/utils.dart | 82 +++++ pkgs/test_descriptor/lib/test_descriptor.dart | 72 +++++ pkgs/test_descriptor/pubspec.yaml | 9 + pkgs/test_descriptor/test/directory_test.dart | 297 ++++++++++++++++++ pkgs/test_descriptor/test/file_test.dart | 141 +++++++++ pkgs/test_descriptor/test/nothing_test.dart | 47 +++ pkgs/test_descriptor/test/pattern_test.dart | 76 +++++ pkgs/test_descriptor/test/utils.dart | 25 ++ 15 files changed, 1329 insertions(+) create mode 100644 pkgs/test_descriptor/lib/src/descriptor.dart create mode 100644 pkgs/test_descriptor/lib/src/directory_descriptor.dart create mode 100644 pkgs/test_descriptor/lib/src/file_descriptor.dart create mode 100644 pkgs/test_descriptor/lib/src/nothing_descriptor.dart create mode 100644 pkgs/test_descriptor/lib/src/pattern_descriptor.dart create mode 100644 pkgs/test_descriptor/lib/src/sandbox.dart create mode 100644 pkgs/test_descriptor/lib/src/utils.dart create mode 100644 pkgs/test_descriptor/lib/test_descriptor.dart create mode 100644 pkgs/test_descriptor/test/directory_test.dart create mode 100644 pkgs/test_descriptor/test/file_test.dart create mode 100644 pkgs/test_descriptor/test/nothing_test.dart create mode 100644 pkgs/test_descriptor/test/pattern_test.dart create mode 100644 pkgs/test_descriptor/test/utils.dart diff --git a/pkgs/test_descriptor/README.md b/pkgs/test_descriptor/README.md index 95b216eed..db47a2da0 100644 --- a/pkgs/test_descriptor/README.md +++ b/pkgs/test_descriptor/README.md @@ -1,2 +1,53 @@ The `test_descriptor` package provides a convenient, easy-to-read API for defining and verifying directory structures in tests. + +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://www.dartdocs.org/documentation/test_descriptor/latest/test_descriptor/dir.html +[file]: https://www.dartdocs.org/documentation/test_descriptor/latest/test_descriptor/file.html +[create]: https://www.dartdocs.org/documentation/test_descriptor/latest/test_descriptor/Descriptor/create.html +[validate]: https://www.dartdocs.org/documentation/test_descriptor/latest/test_descriptor/Descriptor/validate.html + +```dart +import 'dart:io'; + +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 new 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://www.dartdocs.org/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`][glyph.ascii] attribute. + +[term_glyph]: https://pub.dartlang.org/packages/term_glyph +[gylph.ascii]: https://www.dartdocs.org/documentation/term_glyph/latest/term_glyph/ascii.html diff --git a/pkgs/test_descriptor/lib/src/descriptor.dart b/pkgs/test_descriptor/lib/src/descriptor.dart new file mode 100644 index 000000000..363bc90a6 --- /dev/null +++ b/pkgs/test_descriptor/lib/src/descriptor.dart @@ -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 'dart:async'; + +/// 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 create([String parent]); + + /// Validates that the physical file system under [parent] (which defaults to + /// [sandbox]) contains an entry that matches this descriptor. + Future validate([String parent]); + + /// Returns a human-friendly tree-style description of this descriptor. + String describe(); +} diff --git a/pkgs/test_descriptor/lib/src/directory_descriptor.dart b/pkgs/test_descriptor/lib/src/directory_descriptor.dart new file mode 100644 index 000000000..1b2ca97f5 --- /dev/null +++ b/pkgs/test_descriptor/lib/src/directory_descriptor.dart @@ -0,0 +1,140 @@ +// 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 'dart:async'; +import 'dart:io'; + +import 'package:async/async.dart'; +import 'package:path/path.dart' as p; +import 'package:term_glyph/term_glyph.dart' as glyph; +import 'package:test/test.dart'; + +import 'descriptor.dart'; +import 'file_descriptor.dart'; +import 'sandbox.dart'; +import 'utils.dart'; + +/// A descriptor describing a directory that may contain nested descriptors. +/// +/// In addition to the normal descriptor methods, this has a [load] method that +/// allows it to be used as a virtual filesystem. +/// +/// This may be extended outside this package. +class DirectoryDescriptor extends Descriptor { + /// Descriptors for entries in this directory. + /// + /// This may be modified. + final List contents; + + DirectoryDescriptor(String name, Iterable contents) + : contents = contents.toList(), + super(name); + + /// Creates a directory descriptor named [name] that describes the physical + /// directory at [path]. + factory DirectoryDescriptor.fromFilesystem(String name, String path) { + return new DirectoryDescriptor(name, + new Directory(path).listSync().map((entity) { + // Ignore hidden files. + if (p.basename(entity.path).startsWith(".")) return null; + + if (entity is Directory) { + return new DirectoryDescriptor.fromFilesystem( + p.basename(entity.path), entity.path); + } else if (entity is File) { + return new FileDescriptor( + p.basename(entity.path), entity.readAsBytesSync()); + } + // Ignore broken symlinks. + }).where((path) => path != null)); + } + + Future create([String parent]) async { + var fullPath = p.join(parent ?? sandbox, name); + await new Directory(fullPath).create(recursive: true); + await Future.wait(contents.map((entry) => entry.create(fullPath))); + } + + Future validate([String parent]) async { + var fullPath = p.join(parent ?? sandbox, name); + if (!(await new Directory(fullPath).exists())) { + fail('Directory not found: "${prettyPath(fullPath)}".'); + } + + await waitAndReportErrors( + contents.map((entry) => entry.validate(fullPath))); + } + + /// Treats this descriptor as a virtual filesystem and loads the binary + /// contents of the [FileDescriptor] at the given relative [url], which may be + /// a [Uri] or a [String]. + /// + /// The [parent] parameter should only be passed by subclasses of + /// [DirectoryDescriptor] that are recursively calling [load]. It's the + /// URL-format path of the directories that have been loaded so far. + Stream> load(url, [String parents]) { + String path; + if (url is String) { + path = url; + } else if (url is Uri) { + path = url.toString(); + } else { + throw new ArgumentError.value(url, "url", "must be a Uri or a String."); + } + + if (!p.url.isWithin('.', path)) { + throw new ArgumentError.value( + url, "url", "must be relative and beneath the base URL."); + } + + return StreamCompleter.fromFuture(new Future.sync(() { + var split = p.url.split(p.url.normalize(path)); + var file = split.length == 1; + var matchingEntries = contents.where((entry) { + return entry.name == split.first && + file + ? entry is FileDescriptor + : entry is DirectoryDescriptor; + }).toList(); + + var type = file ? 'file' : 'directory'; + var parentsAndSelf = parents == null ? name : p.url.join(parents, name); + if (matchingEntries.isEmpty) { + fail('Couldn\'t find a $type descriptor named "${split.first}" within ' + '"$parentsAndSelf".'); + } else if (matchingEntries.length > 1) { + fail('Found multiple $type descriptors named "${split.first}" within ' + '"$parentsAndSelf".'); + } else { + var remainingPath = split.sublist(1); + if (remainingPath.isEmpty) { + return (matchingEntries.first as FileDescriptor).readAsBytes(); + } else { + return (matchingEntries.first as DirectoryDescriptor) + .load(p.url.joinAll(remainingPath), parentsAndSelf); + } + } + })); + } + + String describe() { + if (contents.isEmpty) return name; + + var buffer = new StringBuffer(); + buffer.writeln(name); + for (var entry in contents.take(contents.length - 1)) { + var entryString = prefixLines( + entry.describe(), '${glyph.verticalLine} ', + first: '${glyph.teeRight}${glyph.horizontalLine}' + '${glyph.horizontalLine} '); + buffer.writeln(entryString); + } + + var lastEntryString = prefixLines(contents.last.describe(), ' ', + first: '${glyph.bottomLeftCorner}${glyph.horizontalLine}' + '${glyph.horizontalLine} '); + buffer.write(lastEntryString); + return buffer.toString(); + } +} diff --git a/pkgs/test_descriptor/lib/src/file_descriptor.dart b/pkgs/test_descriptor/lib/src/file_descriptor.dart new file mode 100644 index 000000000..d648894aa --- /dev/null +++ b/pkgs/test_descriptor/lib/src/file_descriptor.dart @@ -0,0 +1,194 @@ +// 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 'dart:async'; +import 'dart:convert'; +import 'dart:io'; +import 'dart:math' as math; + +import 'package:collection/collection.dart'; +import 'package:path/path.dart' as p; +import 'package:term_glyph/term_glyph.dart' as glyph; +import 'package:test/test.dart'; + +import 'descriptor.dart'; +import 'sandbox.dart'; +import 'utils.dart'; + +/// A descriptor describing a single file. +/// +/// In addition to the normal descriptor methods, this has [read] and +/// [readAsBytes] methods that allows its contents to be read. +/// +/// This may be extended outside this package. +abstract class FileDescriptor extends Descriptor { + /// Creates a new [FileDescriptor] with [name] and [contents]. + /// + /// The [contents] may be a `String`, a `List`, or a [Matcher]. If it's a + /// string, [create] creates a UTF-8 file and [validate] parses the physical + /// file as UTF-8. If it's a [Matcher], [validate] matches it against the + /// physical file's contents parsed as UTF-8, and [create], [read], and + /// [readAsBytes] are unsupported. + /// + /// If [contents] isn't passed, [create] creates an empty file and [validate] + /// verifies that the file is empty. + /// + /// To match a [Matcher] against a file's binary contents, use [new + /// FileDescriptor.binaryMatcher] instead. + factory FileDescriptor(String name, contents) { + if (contents is String) return new _StringFileDescriptor(name, contents); + if (contents is List) { + return new _BinaryFileDescriptor(name, DelegatingList.typed(contents)); + } + if (contents == null) return new _BinaryFileDescriptor(name, []); + return new _MatcherFileDescriptor(name, contents); + } + + /// Creates a new binary [FileDescriptor] with [name] that matches its binary + /// contents against [matcher]. + /// + /// The [create], [read], and [readAsBytes] methods are unsupported for this + /// descriptor. + factory FileDescriptor.binaryMatcher(String name, Matcher matcher) => + new _MatcherFileDescriptor(name, matcher, isBinary: true); + + /// A protected constructor that's only intended for subclasses. + FileDescriptor.protected(String name) : super(name); + + Future create([String parent]) async { + // Create the stream before we call [File.openWrite] because it may fail + // fast (e.g. if this is a matcher file). + var file = new File(p.join(parent ?? sandbox, name)).openWrite(); + try { + await readAsBytes().listen(file.add).asFuture(); + } finally { + await file.close(); + } + } + + Future validate([String parent]) async { + var fullPath = p.join(parent ?? sandbox, name); + var pretty = prettyPath(fullPath); + if (!(await new File(fullPath).exists())) { + fail('File not found: "$pretty".'); + } + + await _validate(pretty, await new File(fullPath).readAsBytes()); + } + + /// Validates that [binaryContents] matches the expected contents of + /// the descriptor. + /// + /// The [prettyPath] is a human-friendly representation of the path to the + /// descriptor. + void _validate(String prettyPath, List binaryContents); + + /// Reads and decodes the contents of this descriptor as a UTF-8 string. + /// + /// This isn't supported for matcher descriptors. + Future read() => UTF8.decodeStream(readAsBytes()); + + /// Reads the contents of this descriptor as a byte stream. + /// + /// This isn't supported for matcher descriptors. + Stream> readAsBytes(); + + String describe() => name; +} + +class _BinaryFileDescriptor extends FileDescriptor { + /// The contents of this descriptor's file. + final List _contents; + + _BinaryFileDescriptor(String name, this._contents) : super.protected(name); + + Stream> readAsBytes() => new Stream.fromIterable([_contents]); + + Future _validate(String prettPath, List actualContents) async { + if (const IterableEquality().equals(_contents, actualContents)) return null; + // TODO(nweiz): show a hex dump here if the data is small enough. + fail('File "$prettPath" didn\'t contain the expected binary data.'); + } +} + +class _StringFileDescriptor extends FileDescriptor { + /// The contents of this descriptor's file. + final String _contents; + + _StringFileDescriptor(String name, this._contents) : super.protected(name); + + Future read() async => _contents; + + Stream> readAsBytes() => + new Stream.fromIterable([UTF8.encode(_contents)]); + + Future _validate(String prettyPath, List actualContents) { + var actualContentsText = UTF8.decode(actualContents); + if (_contents == actualContentsText) return null; + throw fail(_textMismatchMessage(prettyPath, _contents, actualContentsText)); + } + + String _textMismatchMessage(String prettyPath, String expected, + String actual) { + final expectedLines = expected.split('\n'); + final actualLines = actual.split('\n'); + + var results = []; + + // Compare them line by line to see which ones match. + var length = math.max(expectedLines.length, actualLines.length); + for (var i = 0; i < length; i++) { + if (i >= actualLines.length) { + // Missing output. + results.add('? ${expectedLines[i]}'); + } else if (i >= expectedLines.length) { + // Unexpected extra output. + results.add('X ${actualLines[i]}'); + } else { + var expectedLine = expectedLines[i]; + var actualLine = actualLines[i]; + + if (expectedLine != actualLine) { + // Mismatched lines. + results.add('X $actualLine'); + } else { + // Matched lines. + results.add('${glyph.verticalLine} $actualLine'); + } + } + } + + return 'File "$prettyPath" should contain:\n' + "${addBar(expected)}\n" + "but actually contained:\n" + "${results.join('\n')}"; + } +} + +class _MatcherFileDescriptor extends FileDescriptor { + /// The matcher for this descriptor's contents. + final Matcher _matcher; + + /// Whether [_matcher] should match against the file's string or byte + /// contents. + final bool _isBinary; + + _MatcherFileDescriptor(String name, this._matcher, {bool isBinary: false}) + : _isBinary = isBinary, + super.protected(name); + + Stream> readAsBytes() => + throw new UnsupportedError("Matcher files can't be created or read."); + + void _validate(String prettyPath, List actualContents) { + try { + expect( + _isBinary ? actualContents : UTF8.decode(actualContents), + _matcher); + } on TestFailure catch (error) { + throw new TestFailure( + 'Invalid contents for file "$prettyPath":\n' + error.message); + } + } +} diff --git a/pkgs/test_descriptor/lib/src/nothing_descriptor.dart b/pkgs/test_descriptor/lib/src/nothing_descriptor.dart new file mode 100644 index 000000000..f067ba32b --- /dev/null +++ b/pkgs/test_descriptor/lib/src/nothing_descriptor.dart @@ -0,0 +1,37 @@ +// 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 'dart:async'; +import 'dart:io'; + +import 'package:path/path.dart' as p; +import 'package:test/test.dart'; + +import 'descriptor.dart'; +import 'sandbox.dart'; +import 'utils.dart'; + +/// A descriptor that validates that no file exists with the given name. +/// +/// Calling [create] does nothing. +class NothingDescriptor extends Descriptor { + NothingDescriptor(String name) + : super(name); + + Future create([String parent]) async {} + + Future validate([String parent]) async { + var fullPath = p.join(parent ?? sandbox, name); + var pretty = prettyPath(fullPath); + if (new File(fullPath).existsSync()) { + fail('Expected nothing to exist at "$pretty", but found a file.'); + } else if (new Directory(fullPath).existsSync()) { + fail('Expected nothing to exist at "$pretty", but found a directory.'); + } else if (new Link(fullPath).existsSync()) { + fail('Expected nothing to exist at "$pretty", but found a link.'); + } + } + + String describe() => 'nothing at "$name"'; +} diff --git a/pkgs/test_descriptor/lib/src/pattern_descriptor.dart b/pkgs/test_descriptor/lib/src/pattern_descriptor.dart new file mode 100644 index 000000000..251123822 --- /dev/null +++ b/pkgs/test_descriptor/lib/src/pattern_descriptor.dart @@ -0,0 +1,99 @@ +// 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 'dart:async'; +import 'dart:io'; + +import 'package:async/async.dart'; +import 'package:path/path.dart' as p; +import 'package:test/test.dart'; + +import 'descriptor.dart'; +import 'sandbox.dart'; +import 'utils.dart'; + +/// A function that takes a name for a [Descriptor] and returns a [Descriptor]. +/// This is used for [PatternDescriptor]s, where the name isn't known +/// ahead-of-time. +typedef Descriptor _EntryCreator(String name); + +/// A descriptor that matches filesystem entity names by [Pattern] rather than +/// by exact [String]. +/// +/// This descriptor may only be used for validation. +class PatternDescriptor extends Descriptor { + /// The [Pattern] this matches filenames against. Note that the pattern must + /// match the entire basename of the file. + final Pattern pattern; + + /// The function used to generate the [Descriptor] for filesystem entities + /// matching [pattern]. + final _EntryCreator _fn; + + PatternDescriptor(Pattern pattern, Descriptor child(String basename)) + : pattern = pattern, + _fn = child, + super('$pattern'); + + /// Validates that there is some filesystem entity in [parent] that matches + /// [pattern] and the child entry. This finds all entities in [parent] + /// matching [pattern], then passes each of their names to the [EntityCreator] + /// and validates the result. If exactly one succeeds, [this] is considered + /// valid. + Future validate([String parent]) async { + var inSandbox = parent == null; + parent ??= sandbox; + var matchingEntries = await new Directory(parent).list() + .map((entry) => + entry is File ? entry.resolveSymbolicLinksSync() : entry.path) + .where((entry) => matchesAll(pattern, p.basename(entry))) + .toList(); + matchingEntries.sort(); + + var location = inSandbox ? "sandbox" : '"${prettyPath(parent)}"'; + if (matchingEntries.isEmpty) { + fail('No entries found in $location matching ${_patternDescription}.'); + } + + var results = await Future.wait(matchingEntries.map((entry) { + var basename = p.basename(entry); + return runZoned(() { + return Result.capture/**/(new Future.sync(() async { + await _fn(basename).validate(parent); + return basename; + })); + }, onError: (_) { + // Validate may produce multiple errors, but we ignore all but the first + // to avoid cluttering the user with many different errors from many + // different un-matched entries. + }); + }).toList()); + + var successes = results.where((result) => result.isValue).toList(); + if (successes.length == 0) { + await waitAndReportErrors(results.map((result) => result.asFuture)); + } else if (successes.length > 1) { + fail('Multiple valid entries found in $location matching ' + '$_patternDescription:\n' + '${bullet(successes.map((result) => result.asValue.value))}'); + } + } + + String describe() => "entry matching $_patternDescription"; + + String get _patternDescription { + if (pattern is String) return '"$pattern"'; + if (pattern is! RegExp) return '$pattern'; + + var regExp = pattern as RegExp; + var flags = new StringBuffer(); + if (!regExp.isCaseSensitive) flags.write('i'); + if (regExp.isMultiLine) flags.write('m'); + return '/${regExp.pattern}/$flags'; + } + + Future create([String parent]) { + throw new UnsupportedError("Pattern descriptors don't support create()."); + } +} diff --git a/pkgs/test_descriptor/lib/src/sandbox.dart b/pkgs/test_descriptor/lib/src/sandbox.dart new file mode 100644 index 000000000..631162935 --- /dev/null +++ b/pkgs/test_descriptor/lib/src/sandbox.dart @@ -0,0 +1,33 @@ +// 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 'dart:io'; + +import 'package:test/test.dart'; + +/// The sandbox directory in which descriptors are created and validated by +/// default. +/// +/// This is a temporary directory beneath [Directory.systemTemp]. A new one is +/// created the first time [sandbox] is accessed for each test case, and +/// automatically deleted after the test finishes running. +String get sandbox { + if (_sandbox != null) return _sandbox; + // Resolve symlinks so we don't end up with inconsistent paths on Mac OS where + // /tmp is symlinked. + _sandbox = Directory.systemTemp.createTempSync('dart_test_') + .resolveSymbolicLinksSync(); + + addTearDown(() async { + var sandbox = _sandbox; + _sandbox = null; + await new Directory(sandbox).delete(recursive: true); + }); + + return _sandbox; +} +String _sandbox; + +/// Whether [sandbox] has been created. +bool get sandboxExists => _sandbox != null; diff --git a/pkgs/test_descriptor/lib/src/utils.dart b/pkgs/test_descriptor/lib/src/utils.dart new file mode 100644 index 000000000..385f4de3a --- /dev/null +++ b/pkgs/test_descriptor/lib/src/utils.dart @@ -0,0 +1,82 @@ +// 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 'dart:async'; + +import 'package:path/path.dart' as p; +import 'package:term_glyph/term_glyph.dart' as glyph; +import 'package:test/test.dart'; + +import 'sandbox.dart'; + +/// Prepends a vertical bar to [text]. +String addBar(String text) => prefixLines(text, "${glyph.verticalLine} ", + first: "${glyph.downEnd} ", + last: "${glyph.upEnd} ", + single: "| "); + +/// Indents [text], and adds a bullet at the beginning. +String addBullet(String text) => + prefixLines(text, " ", first: "${glyph.bullet} "); + +/// Converts [strings] to a bulleted list. +String bullet(Iterable strings) => strings.map(addBullet).join("\n"); + +/// Prepends each line in [text] with [prefix]. +/// +/// If [first] or [last] is passed, the first and last lines, respectively, are +/// prefixed with those instead. If [single] is passed, it's used if there's +/// only a single line; otherwise, [first], [last], or [prefix] is used, in that +/// order of precedence. +String prefixLines(String text, String prefix, {String first, String last, + String single}) { + first ??= prefix; + last ??= prefix; + single ??= first ?? last ?? prefix; + + var lines = text.split('\n'); + if (lines.length == 1) return "$single$text"; + + var buffer = new StringBuffer("$first${lines.first}\n"); + for (var line in lines.skip(1).take(lines.length - 2)) { + buffer.writeln("$prefix$line"); + } + buffer.write("$last${lines.last}"); + return buffer.toString(); +} + +/// Returns a representation of [path] that's easy for humans to read. +/// +/// This may not be a valid path relative to [p.current]. +String prettyPath(String path) { + if (sandboxExists && p.isWithin(sandbox, path)) { + return p.relative(path, from: sandbox); + } else if (p.isWithin(p.current, path)) { + return p.relative(path); + } else { + return path; + } +} + +/// Returns whether [pattern] matches all of [string]. +bool matchesAll(Pattern pattern, String string) => + pattern.matchAsPrefix(string)?.end == string.length; + +/// Like [Future.wait] with `eagerError: true`, but reports errors after the +/// first using [registerException] rather than silently ignoring them. +Future waitAndReportErrors(Iterable futures) { + var errored = false; + return Future.wait(futures.map((future) { + // Avoid async/await so that we synchronously add error handlers for the + // futures to keep them from top-leveling. + return future.catchError((error, stackTrace) { + if (!errored) { + errored = true; + throw error; + } else { + registerException(error, stackTrace); + } + }); + })); +} diff --git a/pkgs/test_descriptor/lib/test_descriptor.dart b/pkgs/test_descriptor/lib/test_descriptor.dart new file mode 100644 index 000000000..54649ab3c --- /dev/null +++ b/pkgs/test_descriptor/lib/test_descriptor.dart @@ -0,0 +1,72 @@ +// 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 'package:test/test.dart'; + +import 'src/descriptor.dart'; +import 'src/directory_descriptor.dart'; +import 'src/file_descriptor.dart'; +import 'src/nothing_descriptor.dart'; +import 'src/pattern_descriptor.dart'; + +export 'src/descriptor.dart'; +export 'src/directory_descriptor.dart'; +export 'src/file_descriptor.dart'; +export 'src/nothing_descriptor.dart'; +export 'src/pattern_descriptor.dart'; +export 'src/sandbox.dart' show sandbox; + +/// Creates a new [FileDescriptor] with [name] and [contents]. +/// +/// The [contents] may be a `String`, a `List`, or a [Matcher]. If it's a +/// string, [Descriptor.create] creates a UTF-8 file and [Descriptor.validate] +/// parses the physical file as UTF-8. If it's a [Matcher], +/// [Descriptor.validate] matches it against the physical file's contents parsed +/// as UTF-8, and [Descriptor.create] is unsupported. +/// +/// If [contents] isn't passed, [Descriptor.create] creates an empty file and +/// [Descriptor.validate] verifies that the file is empty. +/// +/// To match a [Matcher] against a file's binary contents, use [new +/// FileDescriptor.binaryMatcher] instead. +FileDescriptor file(String name, [contents]) => + new FileDescriptor(name, contents); + +/// Creates a new [DirectoryDescriptor] descriptor with [name] and [contents]. +/// +/// [Descriptor.validate] requires that all descriptors in [contents] match +/// children of the physical diretory, but it *doesn't* require that no other +/// children exist. To ensure that a particular child doesn't exist, use +/// [nothing]. +DirectoryDescriptor dir(String name, [Iterable contents]) => + new DirectoryDescriptor(name, contents == null ? [] : contents); + +/// Creates a new [NothingDescriptor] descriptor that asserts that no entry +/// named [name] exists. +/// +/// [Descriptor.create] does nothing for this descriptor. +NothingDescriptor nothing(String name) => new NothingDescriptor(name); + +/// Creates a new [PatternDescriptor] descriptor that asserts than an entry with +/// a name matching [pattern] exists, and matches the [Descriptor] returned +/// by [child]. +/// +/// The [child] callback is passed the basename of each entry matching [name]. +/// It returns a descriptor that should match that entry. It's valid for +/// multiple entries to match [name] as long as only one of them matches +/// [child]. +/// +/// [Descriptor.create] is not supported for this descriptor. +PatternDescriptor pattern(Pattern name, Descriptor child(String basename)) => + new PatternDescriptor(name, child); + +/// A convenience method for creating a [PatternDescriptor] descriptor that +/// constructs a [FileDescriptor] descriptor. +PatternDescriptor filePattern(Pattern name, [contents]) => + pattern(name, (realName) => file(realName, contents)); + +/// A convenience method for creating a [PatternDescriptor] descriptor that +/// constructs a [DirectoryDescriptor] descriptor. +PatternDescriptor dirPattern(Pattern name, [Iterable contents]) => + pattern(name, (realName) => dir(realName, contents)); diff --git a/pkgs/test_descriptor/pubspec.yaml b/pkgs/test_descriptor/pubspec.yaml index 97328ce8a..b762b9cfd 100644 --- a/pkgs/test_descriptor/pubspec.yaml +++ b/pkgs/test_descriptor/pubspec.yaml @@ -6,3 +6,12 @@ homepage: https://github.com/dart-lang/test_descriptor environment: sdk: '>=1.8.0 <2.0.0' + +dependencies: + async: '^1.10.0' + collection: '^1.5.0' + matcher: '^0.12.0' + path: '^1.0.0' + stack_trace: '^1.0.0' + test: '^0.12.19' + term_glyph: '^1.0.0' diff --git a/pkgs/test_descriptor/test/directory_test.dart b/pkgs/test_descriptor/test/directory_test.dart new file mode 100644 index 000000000..79cfd6a11 --- /dev/null +++ b/pkgs/test_descriptor/test/directory_test.dart @@ -0,0 +1,297 @@ +// 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. + +@TestOn('vm') + +import 'dart:async'; +import 'dart:convert'; +import 'dart:io'; + +import 'package:path/path.dart' as p; +import 'package:term_glyph/term_glyph.dart' as term_glyph; +import 'package:test/test.dart'; + +import 'package:test_descriptor/test_descriptor.dart' as d; + +import 'utils.dart'; + +void main() { + group("create()", () { + test("creates a directory and its contents", () async { + await d.dir('dir', [ + d.dir('subdir', [ + d.file('subfile1.txt', 'subcontents1'), + d.file('subfile2.txt', 'subcontents2') + ]), + d.file('file1.txt', 'contents1'), + d.file('file2.txt', 'contents2') + ]).create(); + + expect(new File(p.join(d.sandbox, 'dir', 'file1.txt')).readAsString(), + completion(equals('contents1'))); + expect(new File(p.join(d.sandbox, 'dir', 'file2.txt')).readAsString(), + completion(equals('contents2'))); + expect(new File(p.join(d.sandbox, 'dir', 'subdir', 'subfile1.txt')) + .readAsString(), + completion(equals('subcontents1'))); + expect(new File(p.join(d.sandbox, 'dir', 'subdir', 'subfile2.txt')) + .readAsString(), + completion(equals('subcontents2'))); + }); + + test("works if the directory already exists", () async { + await d.dir('dir').create(); + await d.dir('dir', [d.file('name.txt', 'contents')]).create(); + + expect(new File(p.join(d.sandbox, 'dir', 'name.txt')).readAsString(), + completion(equals('contents'))); + }); + }); + + group("validate()", () { + test("completes successfully if the filesystem matches the descriptor", + () async { + var dirPath = p.join(d.sandbox, 'dir'); + var subdirPath = p.join(dirPath, 'subdir'); + await new Directory(subdirPath).create(recursive: true); + await new File(p.join(dirPath, 'file1.txt')).writeAsString('contents1'); + await new File(p.join(dirPath, 'file2.txt')).writeAsString('contents2'); + await new File(p.join(subdirPath, 'subfile1.txt')) + .writeAsString('subcontents1'); + await new File(p.join(subdirPath, 'subfile2.txt')) + .writeAsString('subcontents2'); + + await d.dir('dir', [ + d.dir('subdir', [ + d.file('subfile1.txt', 'subcontents1'), + d.file('subfile2.txt', 'subcontents2') + ]), + d.file('file1.txt', 'contents1'), + d.file('file2.txt', 'contents2') + ]).validate(); + }); + + test("fails if the directory doesn't exist", () async { + var dirPath = p.join(d.sandbox, 'dir'); + await new Directory(dirPath).create(); + await new File(p.join(dirPath, 'file1.txt')).writeAsString('contents1'); + await new File(p.join(dirPath, 'file2.txt')).writeAsString('contents2'); + + expect(d.dir('dir', [ + d.dir('subdir', [ + d.file('subfile1.txt', 'subcontents1'), + d.file('subfile2.txt', 'subcontents2') + ]), + d.file('file1.txt', 'contents1'), + d.file('file2.txt', 'contents2') + ]).validate(), + throwsA(toString(equals( + 'Directory not found: "${p.join('dir', 'subdir')}".')))); + }); + + test("emits an error for each child that fails to validate", () async { + var dirPath = p.join(d.sandbox, 'dir'); + var subdirPath = p.join(dirPath, 'subdir'); + await new Directory(subdirPath).create(recursive: true); + await new File(p.join(dirPath, 'file1.txt')).writeAsString('contents1'); + await new File(p.join(subdirPath, 'subfile2.txt')) + .writeAsString('subwrongtents2'); + + var errors = 0; + var controller = new StreamController(); + runZoned(() { + d.dir('dir', [ + d.dir('subdir', [ + d.file('subfile1.txt', 'subcontents1'), + d.file('subfile2.txt', 'subcontents2') + ]), + d.file('file1.txt', 'contents1'), + d.file('file2.txt', 'contents2') + ]).validate(); + }, onError: expectAsync1((error) { + errors++; + controller.add(error.toString()); + if (errors == 3) controller.close(); + }, count: 3)); + + expect(controller.stream.toList(), completion(allOf([ + contains('File not found: "${p.join('dir', 'subdir', 'subfile1.txt')}".'), + contains('File not found: "${p.join('dir', 'file2.txt')}".'), + contains(startsWith('File "${p.join('dir', 'subdir', 'subfile2.txt')}" ' + 'should contain:')), + ]))); + }); + }); + + group("load()", () { + test("loads a file", () { + var dir = d.dir('dir', [d.file('name.txt', 'contents')]); + expect(UTF8.decodeStream(dir.load('name.txt')), + completion(equals('contents'))); + }); + + test("loads a deeply-nested file", () { + var dir = d.dir('dir', [ + d.dir('subdir', [ + d.file('name.txt', 'subcontents') + ]), + d.file('name.txt', 'contents') + ]); + + expect(UTF8.decodeStream(dir.load('subdir/name.txt')), + completion(equals('subcontents'))); + }); + + test("fails to load a nested directory", () { + var dir = d.dir('dir', [ + d.dir('subdir', [ + d.dir('subsubdir', [d.file('name.txt', 'subcontents')]) + ]), + d.file('name.txt', 'contents') + ]); + + expect(dir.load('subdir/subsubdir').toList(), + throwsA(toString(equals('Couldn\'t find a file descriptor named ' + '"subsubdir" within "dir/subdir".')))); + }); + + test("fails to load an absolute path", () { + var dir = d.dir('dir', [d.file('name.txt', 'contents')]); + expect(() => dir.load('/name.txt'), throwsArgumentError); + }); + + test("fails to load '..'", () { + var dir = d.dir('dir', [d.file('name.txt', 'contents')]); + expect(() => dir.load('..'), throwsArgumentError); + }); + + test("fails to load a file that doesn't exist", () { + var dir = d.dir('dir', [ + d.dir('subdir', [d.file('name.txt', 'contents')]) + ]); + + expect(dir.load('subdir/not-name.txt').toList(), + throwsA(toString(equals('Couldn\'t find a file descriptor named ' + '"not-name.txt" within "dir/subdir".')))); + }); + + test("fails to load a file that exists multiple times", () { + var dir = d.dir('dir', [ + d.dir('subdir', [ + d.file('name.txt', 'contents'), + d.file('name.txt', 'contents') + ]) + ]); + + expect(dir.load('subdir/name.txt').toList(), + throwsA(toString(equals('Found multiple file descriptors named ' + '"name.txt" within "dir/subdir".')))); + }); + + test("loads a file next to a subdirectory with the same name", () { + var dir = d.dir('dir', [ + d.file('name', 'contents'), + d.dir('name', [d.file('subfile', 'contents')]) + ]); + + expect(UTF8.decodeStream(dir.load('name')), + completion(equals('contents'))); + }); + }); + + group("describe()", () { + bool oldAscii; + setUpAll(() { + oldAscii = term_glyph.ascii; + term_glyph.ascii = true; + }); + + tearDownAll(() { + term_glyph.ascii = oldAscii; + }); + + test("lists the contents of the directory", () { + var dir = d.dir('dir', [ + d.file('file1.txt', 'contents1'), + d.file('file2.txt', 'contents2') + ]); + + expect(dir.describe(), equals( + "dir\n" + "+-- file1.txt\n" + "'-- file2.txt")); + }); + + test("lists the contents of nested directories", () { + var dir = d.dir('dir', [ + d.file('file1.txt', 'contents1'), + d.dir('subdir', [ + d.file('subfile1.txt', 'subcontents1'), + d.file('subfile2.txt', 'subcontents2'), + d.dir('subsubdir', [ + d.file('subsubfile.txt', 'subsubcontents') + ]) + ]), + d.file('file2.txt', 'contents2') + ]); + + expect(dir.describe(), equals( + "dir\n" + "+-- file1.txt\n" + "+-- subdir\n" + "| +-- subfile1.txt\n" + "| +-- subfile2.txt\n" + "| '-- subsubdir\n" + "| '-- subsubfile.txt\n" + "'-- file2.txt")); + }); + + test("with no contents returns the directory name", () { + expect(d.dir('dir').describe(), equals('dir')); + }); + }); + + group("fromFilesystem()", () { + test("creates a descriptor based on the physical filesystem", () async { + var dir = d.dir('dir', [ + d.dir('subdir', [ + d.file('subfile1.txt', 'subcontents1'), + d.file('subfile2.txt', 'subcontents2') + ]), + d.file('file1.txt', 'contents1'), + d.file('file2.txt', 'contents2') + ]); + + await dir.create(); + var descriptor = new d.DirectoryDescriptor.fromFilesystem( + "dir", p.join(d.sandbox, 'dir')); + await descriptor.create(p.join(d.sandbox, 'dir2')); + await dir.validate(p.join(d.sandbox, 'dir2')); + }); + + test("ignores hidden files", () async { + await d.dir('dir', [ + d.dir('subdir', [ + d.file('subfile1.txt', 'subcontents1'), + d.file('.hidden', 'subcontents2') + ]), + d.file('file1.txt', 'contents1'), + d.file('.DS_Store', 'contents2') + ]).create(); + + var descriptor = new d.DirectoryDescriptor.fromFilesystem( + "dir2", p.join(d.sandbox, 'dir')); + await descriptor.create(); + + await d.dir('dir2', [ + d.dir('subdir', [ + d.file('subfile1.txt', 'subcontents1'), + d.nothing('.hidden') + ]), + d.file('file1.txt', 'contents1'), + d.nothing('.DS_Store') + ]).validate(); + }); + }); +} diff --git a/pkgs/test_descriptor/test/file_test.dart b/pkgs/test_descriptor/test/file_test.dart new file mode 100644 index 000000000..08da999cc --- /dev/null +++ b/pkgs/test_descriptor/test/file_test.dart @@ -0,0 +1,141 @@ +// Copyright (c) 2013, 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. + +@TestOn('vm') + +import 'dart:io'; +import 'dart:convert'; + +import 'package:path/path.dart' as p; +import 'package:test/test.dart'; + +import 'package:test_descriptor/test_descriptor.dart' as d; + +import 'utils.dart'; + +void main() { + group("create()", () { + test('creates a text file', () async { + await d.file('name.txt', 'contents').create(); + + expect(new File(p.join(d.sandbox, 'name.txt')).readAsString(), + completion(equals('contents'))); + }); + + test('creates a binary file', () async { + await d.file('name.txt', [0, 1, 2, 3]).create(); + + expect(new File(p.join(d.sandbox, 'name.txt')).readAsBytes(), + completion(equals([0, 1, 2, 3]))); + }); + + test('fails to create a matcher file', () async { + expect(d.file('name.txt', contains('foo')).create(), + throwsUnsupportedError); + }); + + test('overwrites an existing file', () async { + await d.file('name.txt', 'contents1').create(); + await d.file('name.txt', 'contents2').create(); + + expect(new File(p.join(d.sandbox, 'name.txt')).readAsString(), + completion(equals('contents2'))); + }); + }); + + group("validate()", () { + test('succeeds if the filesystem matches a text descriptor', () async { + await new File(p.join(d.sandbox, 'name.txt')).writeAsString('contents'); + await d.file('name.txt', 'contents').validate(); + }); + + test('succeeds if the filesystem matches a binary descriptor', () async { + await new File(p.join(d.sandbox, 'name.txt')).writeAsBytes([0, 1, 2, 3]); + await d.file('name.txt', [0, 1, 2, 3]).validate(); + }); + + test('succeeds if the filesystem matches a text matcher', () async { + await new File(p.join(d.sandbox, 'name.txt')).writeAsString('contents'); + await d.file('name.txt', contains('ent')).validate(); + }); + + test('succeeds if the filesystem matches a binary matcher', () async { + await new File(p.join(d.sandbox, 'name.txt')).writeAsBytes([0, 1, 2, 3]); + await new d.FileDescriptor.binaryMatcher('name.txt', contains(2)) + .validate(); + }); + + test("fails if the text contents don't match", () async { + await new File(p.join(d.sandbox, 'name.txt')).writeAsString('wrong'); + + expect(d.file('name.txt', 'contents').validate(), + throwsA(toString(startsWith('File "name.txt" should contain:')))); + }); + + test("fails if the binary contents don't match", () async { + await new File(p.join(d.sandbox, 'name.txt')).writeAsBytes([5, 4, 3, 2]); + + expect(d.file('name.txt', [0, 1, 2, 3]).validate(), + throwsA(toString(equals( + 'File "name.txt" didn\'t contain the expected binary data.')))); + }); + + test("fails if the text contents don't match the matcher", () async { + await new File(p.join(d.sandbox, 'name.txt')).writeAsString('wrong'); + + expect(d.file('name.txt', contains('ent')).validate(), + throwsA(toString(startsWith( + 'Invalid contents for file "name.txt":')))); + }); + + test("fails if the binary contents don't match the matcher", () async { + await new File(p.join(d.sandbox, 'name.txt')).writeAsBytes([5, 4, 3, 2]); + + expect( + new d.FileDescriptor.binaryMatcher('name.txt', contains(1)) + .validate(), + throwsA(toString(startsWith( + 'Invalid contents for file "name.txt":')))); + }); + + test("fails if there's no file", () { + expect(d.file('name.txt', 'contents').validate(), + throwsA(toString(equals('File not found: "name.txt".')))); + }); + }); + + group("reading", () { + test("read() returns the contents of a text file as a string", () { + expect(d.file('name.txt', 'contents').read(), + completion(equals('contents'))); + }); + + test("read() returns the contents of a binary file as a string", () { + expect(d.file('name.txt', [0x68, 0x65, 0x6c, 0x6c, 0x6f]).read(), + completion(equals('hello'))); + }); + + test("read() fails for a matcher file", () { + expect(d.file('name.txt', contains('hi')).read, + throwsUnsupportedError); + }); + + test("readAsBytes() returns the contents of a text file as a byte stream", + () { + expect(UTF8.decodeStream(d.file('name.txt', 'contents').readAsBytes()), + completion(equals('contents'))); + }); + + test("readAsBytes() returns the contents of a binary file as a byte stream", + () { + expect(byteStreamToList(d.file('name.txt', [0, 1, 2, 3]).readAsBytes()), + completion(equals([0, 1, 2, 3]))); + }); + + test("readAsBytes() fails for a matcher file", () { + expect(d.file('name.txt', contains('hi')).readAsBytes, + throwsUnsupportedError); + }); + }); +} diff --git a/pkgs/test_descriptor/test/nothing_test.dart b/pkgs/test_descriptor/test/nothing_test.dart new file mode 100644 index 000000000..916c3960a --- /dev/null +++ b/pkgs/test_descriptor/test/nothing_test.dart @@ -0,0 +1,47 @@ +// Copyright (c) 2013, 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. + +@TestOn('vm') + +import 'dart:io'; + +import 'package:path/path.dart' as p; +import 'package:test/test.dart'; + +import 'package:test_descriptor/test_descriptor.dart' as d; + +import 'utils.dart'; + +void main() { + test("create() does nothing", () async { + await d.nothing('foo').create(); + expect(new File(p.join(d.sandbox, 'foo')).exists(), completion(isFalse)); + expect(new Directory(p.join(d.sandbox, 'foo')).exists(), + completion(isFalse)); + }); + + group("validate()", () { + test("succeeds if nothing's there", () async { + await d.nothing('foo').validate(); + }); + + test("fails if there's a file", () async { + await d.file('name.txt', 'contents').create(); + expect(d.nothing('name.txt').validate(), throwsA(toString(equals( + 'Expected nothing to exist at "name.txt", but found a file.')))); + }); + + test("fails if there's a directory", () async { + await d.dir('dir').create(); + expect(d.nothing('dir').validate(), throwsA(toString(equals( + 'Expected nothing to exist at "dir", but found a directory.')))); + }); + + test("fails if there's a broken link", () async { + await new Link(p.join(d.sandbox, 'link')).create('nonexistent'); + expect(d.nothing('link').validate(), throwsA(toString(equals( + 'Expected nothing to exist at "link", but found a link.')))); + }); + }); +} diff --git a/pkgs/test_descriptor/test/pattern_test.dart b/pkgs/test_descriptor/test/pattern_test.dart new file mode 100644 index 000000000..e5f196977 --- /dev/null +++ b/pkgs/test_descriptor/test/pattern_test.dart @@ -0,0 +1,76 @@ +// Copyright (c) 2013, 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. + +@TestOn('vm') + +import 'package:test/test.dart'; + +import 'package:test_descriptor/test_descriptor.dart' as d; + +import 'utils.dart'; + +void main() { + group("validate()", () { + test("succeeds if there's a file matching the pattern and the child", + () async { + await d.file('foo', 'blap').create(); + await d.filePattern(new RegExp(r'f..'), 'blap').validate(); + }); + + test("succeeds if there's a directory matching the pattern and the child", + () async { + await d.dir('foo', [ + d.file('bar', 'baz') + ]).create(); + + await d.dirPattern(new RegExp(r'f..'), [ + d.file('bar', 'baz') + ]).validate(); + }); + + test("succeeds if multiple files match the pattern but only one matches " + "the child entry", () async { + await d.file('foo', 'blap').create(); + await d.file('fee', 'blak').create(); + await d.file('faa', 'blut').create(); + + await d.filePattern(new RegExp(r'f..'), 'blap').validate(); + }); + + test("fails if there's no file matching the pattern", () { + expect(d.filePattern(new RegExp(r'f..'), 'bar').validate(), + throwsA(toString(equals( + 'No entries found in sandbox matching /f../.')))); + }); + + test("fails if there's a file matching the pattern but not the entry", + () async { + await d.file('foo', 'bap').create(); + expect(d.filePattern(new RegExp(r'f..'), 'bar').validate(), + throwsA(toString(startsWith('File "foo" should contain:')))); + }); + + test("fails if there's a dir matching the pattern but not the entry", + () async{ + await d.dir('foo', [ + d.file('bar', 'bap') + ]).create(); + + expect(d.dirPattern(new RegExp(r'f..'), [ + d.file('bar', 'baz') + ]).validate(), + throwsA(toString(startsWith('File "foo/bar" should contain:')))); + }); + + test("fails if there are multiple files matching the pattern and the child " + "entry", () async { + await d.file('foo', 'bar').create(); + await d.file('fee', 'bar').create(); + await d.file('faa', 'bar').create(); + expect(d.filePattern(new RegExp(r'f..'), 'bar').validate(), + throwsA(toString(startsWith( + "Multiple valid entries found in sandbox matching /f../:")))); + }); + }); +} diff --git a/pkgs/test_descriptor/test/utils.dart b/pkgs/test_descriptor/test/utils.dart new file mode 100644 index 000000000..d58f7bac6 --- /dev/null +++ b/pkgs/test_descriptor/test/utils.dart @@ -0,0 +1,25 @@ +// Copyright (c) 2013, 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:async'; + +import 'package:test_descriptor/test_descriptor.dart' as d; +import 'package:test/test.dart'; + +/// Converts a [Stream>] to a flat byte future. +Future> byteStreamToList(Stream> stream) { + return stream.fold([], (buffer, chunk) { + buffer.addAll(chunk); + return buffer; + }); +} + +/// Returns a matcher that verifies that the result of calling `toString()` +/// matches [matcher]. +Matcher toString(matcher) { + return predicate((object) { + expect(object.toString(), matcher); + return true; + }, "toString() matches $matcher"); +} From b16348df8f78ab69b66e128abc6b2a761b1b3135 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 1 Jun 2017 13:45:10 -0700 Subject: [PATCH 03/72] Allow malformed UTF-8. (dart-lang/test_descriptor#3) --- pkgs/test_descriptor/CHANGELOG.md | 4 ++++ pkgs/test_descriptor/lib/src/file_descriptor.dart | 9 ++++----- pkgs/test_descriptor/lib/src/utils.dart | 4 ++++ pkgs/test_descriptor/test/file_test.dart | 13 +++++++++++++ pkgs/test_descriptor/test/utils.dart | 1 - 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/pkgs/test_descriptor/CHANGELOG.md b/pkgs/test_descriptor/CHANGELOG.md index 5b26ad30f..77b356160 100644 --- a/pkgs/test_descriptor/CHANGELOG.md +++ b/pkgs/test_descriptor/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.1 + +* `FileDescriptor.validate()` now allows invalid UTF-8 files. + ## 1.0.0 * Initial version. diff --git a/pkgs/test_descriptor/lib/src/file_descriptor.dart b/pkgs/test_descriptor/lib/src/file_descriptor.dart index d648894aa..e10c2c61f 100644 --- a/pkgs/test_descriptor/lib/src/file_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/file_descriptor.dart @@ -3,7 +3,6 @@ // BSD-style license that can be found in the LICENSE file. import 'dart:async'; -import 'dart:convert'; import 'dart:io'; import 'dart:math' as math; @@ -87,7 +86,7 @@ abstract class FileDescriptor extends Descriptor { /// Reads and decodes the contents of this descriptor as a UTF-8 string. /// /// This isn't supported for matcher descriptors. - Future read() => UTF8.decodeStream(readAsBytes()); + Future read() => utf8.decodeStream(readAsBytes()); /// Reads the contents of this descriptor as a byte stream. /// @@ -121,10 +120,10 @@ class _StringFileDescriptor extends FileDescriptor { Future read() async => _contents; Stream> readAsBytes() => - new Stream.fromIterable([UTF8.encode(_contents)]); + new Stream.fromIterable([utf8.encode(_contents)]); Future _validate(String prettyPath, List actualContents) { - var actualContentsText = UTF8.decode(actualContents); + var actualContentsText = utf8.decode(actualContents); if (_contents == actualContentsText) return null; throw fail(_textMismatchMessage(prettyPath, _contents, actualContentsText)); } @@ -184,7 +183,7 @@ class _MatcherFileDescriptor extends FileDescriptor { void _validate(String prettyPath, List actualContents) { try { expect( - _isBinary ? actualContents : UTF8.decode(actualContents), + _isBinary ? actualContents : utf8.decode(actualContents), _matcher); } on TestFailure catch (error) { throw new TestFailure( diff --git a/pkgs/test_descriptor/lib/src/utils.dart b/pkgs/test_descriptor/lib/src/utils.dart index 385f4de3a..bd2d78cf8 100644 --- a/pkgs/test_descriptor/lib/src/utils.dart +++ b/pkgs/test_descriptor/lib/src/utils.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. import 'dart:async'; +import 'dart:convert'; import 'package:path/path.dart' as p; import 'package:term_glyph/term_glyph.dart' as glyph; @@ -10,6 +11,9 @@ import 'package:test/test.dart'; import 'sandbox.dart'; +/// A UTF-8 codec that allows malformed byte sequences. +final utf8 = const Utf8Codec(allowMalformed: true); + /// Prepends a vertical bar to [text]. String addBar(String text) => prefixLines(text, "${glyph.verticalLine} ", first: "${glyph.downEnd} ", diff --git a/pkgs/test_descriptor/test/file_test.dart b/pkgs/test_descriptor/test/file_test.dart index 08da999cc..4cdc184f1 100644 --- a/pkgs/test_descriptor/test/file_test.dart +++ b/pkgs/test_descriptor/test/file_test.dart @@ -66,6 +66,11 @@ void main() { .validate(); }); + test('succeeds if invalid UTF-8 matches a text matcher', () async { + await new File(p.join(d.sandbox, 'name.txt')).writeAsBytes([0xC3, 0x28]); + await d.file('name.txt', isNot(isEmpty)).validate(); + }); + test("fails if the text contents don't match", () async { await new File(p.join(d.sandbox, 'name.txt')).writeAsString('wrong'); @@ -99,6 +104,14 @@ void main() { 'Invalid contents for file "name.txt":')))); }); + test("fails if invalid UTF-8 doesn't match a text matcher", () async { + await new File(p.join(d.sandbox, 'name.txt')).writeAsBytes([0xC3, 0x28]); + expect(d.file('name.txt', isEmpty).validate(), throwsA(toString(allOf([ + startsWith('Invalid contents for file "name.txt":'), + contains('�') + ])))); + }); + test("fails if there's no file", () { expect(d.file('name.txt', 'contents').validate(), throwsA(toString(equals('File not found: "name.txt".')))); diff --git a/pkgs/test_descriptor/test/utils.dart b/pkgs/test_descriptor/test/utils.dart index d58f7bac6..d6359f12b 100644 --- a/pkgs/test_descriptor/test/utils.dart +++ b/pkgs/test_descriptor/test/utils.dart @@ -4,7 +4,6 @@ import 'dart:async'; -import 'package:test_descriptor/test_descriptor.dart' as d; import 'package:test/test.dart'; /// Converts a [Stream>] to a flat byte future. From 072014919edd57b977316198affd95cd3c211081 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 1 Jun 2017 14:04:31 -0700 Subject: [PATCH 04/72] Fix a precedence bug in DirectoryDescriptor.load(). (dart-lang/test_descriptor#2) --- pkgs/test_descriptor/CHANGELOG.md | 3 +++ pkgs/test_descriptor/lib/src/directory_descriptor.dart | 4 ++-- pkgs/test_descriptor/pubspec.yaml | 2 +- pkgs/test_descriptor/test/directory_test.dart | 9 +++++++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/pkgs/test_descriptor/CHANGELOG.md b/pkgs/test_descriptor/CHANGELOG.md index 77b356160..2c8a1ab75 100644 --- a/pkgs/test_descriptor/CHANGELOG.md +++ b/pkgs/test_descriptor/CHANGELOG.md @@ -2,6 +2,9 @@ * `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. diff --git a/pkgs/test_descriptor/lib/src/directory_descriptor.dart b/pkgs/test_descriptor/lib/src/directory_descriptor.dart index 1b2ca97f5..0034e61cd 100644 --- a/pkgs/test_descriptor/lib/src/directory_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/directory_descriptor.dart @@ -93,9 +93,9 @@ class DirectoryDescriptor extends Descriptor { var file = split.length == 1; var matchingEntries = contents.where((entry) { return entry.name == split.first && - file + (file ? entry is FileDescriptor - : entry is DirectoryDescriptor; + : entry is DirectoryDescriptor); }).toList(); var type = file ? 'file' : 'directory'; diff --git a/pkgs/test_descriptor/pubspec.yaml b/pkgs/test_descriptor/pubspec.yaml index b762b9cfd..1dba3f322 100644 --- a/pkgs/test_descriptor/pubspec.yaml +++ b/pkgs/test_descriptor/pubspec.yaml @@ -1,5 +1,5 @@ name: test_descriptor -version: 1.0.0 +version: 1.0.1 description: An API for defining and verifying directory structures. author: Dart Team homepage: https://github.com/dart-lang/test_descriptor diff --git a/pkgs/test_descriptor/test/directory_test.dart b/pkgs/test_descriptor/test/directory_test.dart index 79cfd6a11..cea9627b7 100644 --- a/pkgs/test_descriptor/test/directory_test.dart +++ b/pkgs/test_descriptor/test/directory_test.dart @@ -126,7 +126,10 @@ void main() { group("load()", () { test("loads a file", () { - var dir = d.dir('dir', [d.file('name.txt', 'contents')]); + var dir = d.dir('dir', [ + d.file('name.txt', 'contents'), + d.file('other.txt', 'wrong') + ]); expect(UTF8.decodeStream(dir.load('name.txt')), completion(equals('contents'))); }); @@ -134,8 +137,10 @@ void main() { test("loads a deeply-nested file", () { var dir = d.dir('dir', [ d.dir('subdir', [ - d.file('name.txt', 'subcontents') + d.file('name.txt', 'subcontents'), + d.file('other.txt', 'wrong') ]), + d.dir('otherdir', [d.file('other.txt', 'wrong')]), d.file('name.txt', 'contents') ]); From 92094aa7feead31e4721bb629aaacf24cfc4a91b Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Tue, 6 Jun 2017 15:46:29 -0700 Subject: [PATCH 05/72] Fix a broken link in the README. (dart-lang/test_descriptor#4) --- pkgs/test_descriptor/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/test_descriptor/README.md b/pkgs/test_descriptor/README.md index db47a2da0..6adc5b7ef 100644 --- a/pkgs/test_descriptor/README.md +++ b/pkgs/test_descriptor/README.md @@ -47,7 +47,7 @@ finishes running. [sandbox]: https://www.dartdocs.org/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`][glyph.ascii] attribute. +ASCII or Unicode glyphs based on the [`glyph.ascii`][ascii] attribute. [term_glyph]: https://pub.dartlang.org/packages/term_glyph -[gylph.ascii]: https://www.dartdocs.org/documentation/term_glyph/latest/term_glyph/ascii.html +[ascii]: https://www.dartdocs.org/documentation/term_glyph/latest/term_glyph/ascii.html From 941603775ba983bb68f59a40328342aa3875ca00 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Fri, 22 Sep 2017 13:47:01 -0700 Subject: [PATCH 06/72] Declare support for async 2.0.0 (dart-lang/test_descriptor#5) --- pkgs/test_descriptor/CHANGELOG.md | 4 ++++ pkgs/test_descriptor/pubspec.yaml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/test_descriptor/CHANGELOG.md b/pkgs/test_descriptor/CHANGELOG.md index 2c8a1ab75..3d9ab03a9 100644 --- a/pkgs/test_descriptor/CHANGELOG.md +++ b/pkgs/test_descriptor/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.2 + +* Declare support for `async` 2.0.0. + ## 1.0.1 * `FileDescriptor.validate()` now allows invalid UTF-8 files. diff --git a/pkgs/test_descriptor/pubspec.yaml b/pkgs/test_descriptor/pubspec.yaml index 1dba3f322..3a8472ec5 100644 --- a/pkgs/test_descriptor/pubspec.yaml +++ b/pkgs/test_descriptor/pubspec.yaml @@ -1,5 +1,5 @@ name: test_descriptor -version: 1.0.1 +version: 1.0.2 description: An API for defining and verifying directory structures. author: Dart Team homepage: https://github.com/dart-lang/test_descriptor @@ -8,7 +8,7 @@ environment: sdk: '>=1.8.0 <2.0.0' dependencies: - async: '^1.10.0' + async: '>=1.10.0 <3.0.0' collection: '^1.5.0' matcher: '^0.12.0' path: '^1.0.0' From 5365a29207faee8caa194b71f87be770b5d9cae6 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 13 Oct 2017 13:48:01 -0700 Subject: [PATCH 07/72] Enable Travis-CI (dart-lang/test_descriptor#8) * dartfmt * Rename analysis_options, enable travis --- pkgs/test_descriptor/.travis.yml | 25 ++++ ...analysis_options => analysis_options.yaml} | 0 .../lib/src/directory_descriptor.dart | 45 +++--- .../lib/src/file_descriptor.dart | 7 +- .../lib/src/nothing_descriptor.dart | 3 +- .../lib/src/pattern_descriptor.dart | 7 +- pkgs/test_descriptor/lib/src/sandbox.dart | 4 +- pkgs/test_descriptor/lib/src/utils.dart | 8 +- pkgs/test_descriptor/test/directory_test.dart | 133 +++++++++--------- pkgs/test_descriptor/test/file_test.dart | 31 ++-- pkgs/test_descriptor/test/nothing_test.dart | 22 +-- pkgs/test_descriptor/test/pattern_test.dart | 35 +++-- 12 files changed, 175 insertions(+), 145 deletions(-) create mode 100644 pkgs/test_descriptor/.travis.yml rename pkgs/test_descriptor/{.analysis_options => analysis_options.yaml} (100%) diff --git a/pkgs/test_descriptor/.travis.yml b/pkgs/test_descriptor/.travis.yml new file mode 100644 index 000000000..a0653e381 --- /dev/null +++ b/pkgs/test_descriptor/.travis.yml @@ -0,0 +1,25 @@ +language: dart + +dart: + - dev + - stable + +dart_task: + - test + +# Only run one instance of the formatter and the analyzer, rather than running +# them against each Dart version. +matrix: + include: + - dart: dev + dart_task: dartfmt + - dart: dev + dart_task: dartanalyzer + +# Only building master means that we don't run two builds for each pull request. +branches: + only: [master] + +cache: + directories: + - $HOME/.pub-cache diff --git a/pkgs/test_descriptor/.analysis_options b/pkgs/test_descriptor/analysis_options.yaml similarity index 100% rename from pkgs/test_descriptor/.analysis_options rename to pkgs/test_descriptor/analysis_options.yaml diff --git a/pkgs/test_descriptor/lib/src/directory_descriptor.dart b/pkgs/test_descriptor/lib/src/directory_descriptor.dart index 0034e61cd..32b2e0796 100644 --- a/pkgs/test_descriptor/lib/src/directory_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/directory_descriptor.dart @@ -34,20 +34,21 @@ class DirectoryDescriptor extends Descriptor { /// Creates a directory descriptor named [name] that describes the physical /// directory at [path]. factory DirectoryDescriptor.fromFilesystem(String name, String path) { - return new DirectoryDescriptor(name, + return new DirectoryDescriptor( + name, new Directory(path).listSync().map((entity) { - // Ignore hidden files. - if (p.basename(entity.path).startsWith(".")) return null; - - if (entity is Directory) { - return new DirectoryDescriptor.fromFilesystem( - p.basename(entity.path), entity.path); - } else if (entity is File) { - return new FileDescriptor( - p.basename(entity.path), entity.readAsBytesSync()); - } - // Ignore broken symlinks. - }).where((path) => path != null)); + // Ignore hidden files. + if (p.basename(entity.path).startsWith(".")) return null; + + if (entity is Directory) { + return new DirectoryDescriptor.fromFilesystem( + p.basename(entity.path), entity.path); + } else if (entity is File) { + return new FileDescriptor( + p.basename(entity.path), entity.readAsBytesSync()); + } + // Ignore broken symlinks. + }).where((path) => path != null)); } Future create([String parent]) async { @@ -93,19 +94,17 @@ class DirectoryDescriptor extends Descriptor { var file = split.length == 1; var matchingEntries = contents.where((entry) { return entry.name == split.first && - (file - ? entry is FileDescriptor - : entry is DirectoryDescriptor); + (file ? entry is FileDescriptor : entry is DirectoryDescriptor); }).toList(); var type = file ? 'file' : 'directory'; var parentsAndSelf = parents == null ? name : p.url.join(parents, name); if (matchingEntries.isEmpty) { fail('Couldn\'t find a $type descriptor named "${split.first}" within ' - '"$parentsAndSelf".'); + '"$parentsAndSelf".'); } else if (matchingEntries.length > 1) { fail('Found multiple $type descriptors named "${split.first}" within ' - '"$parentsAndSelf".'); + '"$parentsAndSelf".'); } else { var remainingPath = split.sublist(1); if (remainingPath.isEmpty) { @@ -124,16 +123,16 @@ class DirectoryDescriptor extends Descriptor { var buffer = new StringBuffer(); buffer.writeln(name); for (var entry in contents.take(contents.length - 1)) { - var entryString = prefixLines( - entry.describe(), '${glyph.verticalLine} ', - first: '${glyph.teeRight}${glyph.horizontalLine}' - '${glyph.horizontalLine} '); + var entryString = + prefixLines(entry.describe(), '${glyph.verticalLine} ', + first: '${glyph.teeRight}${glyph.horizontalLine}' + '${glyph.horizontalLine} '); buffer.writeln(entryString); } var lastEntryString = prefixLines(contents.last.describe(), ' ', first: '${glyph.bottomLeftCorner}${glyph.horizontalLine}' - '${glyph.horizontalLine} '); + '${glyph.horizontalLine} '); buffer.write(lastEntryString); return buffer.toString(); } diff --git a/pkgs/test_descriptor/lib/src/file_descriptor.dart b/pkgs/test_descriptor/lib/src/file_descriptor.dart index e10c2c61f..1d7a10928 100644 --- a/pkgs/test_descriptor/lib/src/file_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/file_descriptor.dart @@ -128,8 +128,8 @@ class _StringFileDescriptor extends FileDescriptor { throw fail(_textMismatchMessage(prettyPath, _contents, actualContentsText)); } - String _textMismatchMessage(String prettyPath, String expected, - String actual) { + String _textMismatchMessage( + String prettyPath, String expected, String actual) { final expectedLines = expected.split('\n'); final actualLines = actual.split('\n'); @@ -183,8 +183,7 @@ class _MatcherFileDescriptor extends FileDescriptor { void _validate(String prettyPath, List actualContents) { try { expect( - _isBinary ? actualContents : utf8.decode(actualContents), - _matcher); + _isBinary ? actualContents : utf8.decode(actualContents), _matcher); } on TestFailure catch (error) { throw new TestFailure( 'Invalid contents for file "$prettyPath":\n' + error.message); diff --git a/pkgs/test_descriptor/lib/src/nothing_descriptor.dart b/pkgs/test_descriptor/lib/src/nothing_descriptor.dart index f067ba32b..2d62cb09a 100644 --- a/pkgs/test_descriptor/lib/src/nothing_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/nothing_descriptor.dart @@ -16,8 +16,7 @@ import 'utils.dart'; /// /// Calling [create] does nothing. class NothingDescriptor extends Descriptor { - NothingDescriptor(String name) - : super(name); + NothingDescriptor(String name) : super(name); Future create([String parent]) async {} diff --git a/pkgs/test_descriptor/lib/src/pattern_descriptor.dart b/pkgs/test_descriptor/lib/src/pattern_descriptor.dart index 251123822..60cd1315b 100644 --- a/pkgs/test_descriptor/lib/src/pattern_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/pattern_descriptor.dart @@ -44,7 +44,8 @@ class PatternDescriptor extends Descriptor { Future validate([String parent]) async { var inSandbox = parent == null; parent ??= sandbox; - var matchingEntries = await new Directory(parent).list() + var matchingEntries = await new Directory(parent) + .list() .map((entry) => entry is File ? entry.resolveSymbolicLinksSync() : entry.path) .where((entry) => matchesAll(pattern, p.basename(entry))) @@ -75,8 +76,8 @@ class PatternDescriptor extends Descriptor { await waitAndReportErrors(results.map((result) => result.asFuture)); } else if (successes.length > 1) { fail('Multiple valid entries found in $location matching ' - '$_patternDescription:\n' - '${bullet(successes.map((result) => result.asValue.value))}'); + '$_patternDescription:\n' + '${bullet(successes.map((result) => result.asValue.value))}'); } } diff --git a/pkgs/test_descriptor/lib/src/sandbox.dart b/pkgs/test_descriptor/lib/src/sandbox.dart index 631162935..eee1252cc 100644 --- a/pkgs/test_descriptor/lib/src/sandbox.dart +++ b/pkgs/test_descriptor/lib/src/sandbox.dart @@ -16,7 +16,8 @@ String get sandbox { if (_sandbox != null) return _sandbox; // Resolve symlinks so we don't end up with inconsistent paths on Mac OS where // /tmp is symlinked. - _sandbox = Directory.systemTemp.createTempSync('dart_test_') + _sandbox = Directory.systemTemp + .createTempSync('dart_test_') .resolveSymbolicLinksSync(); addTearDown(() async { @@ -27,6 +28,7 @@ String get sandbox { return _sandbox; } + String _sandbox; /// Whether [sandbox] has been created. diff --git a/pkgs/test_descriptor/lib/src/utils.dart b/pkgs/test_descriptor/lib/src/utils.dart index bd2d78cf8..3e1d12eaf 100644 --- a/pkgs/test_descriptor/lib/src/utils.dart +++ b/pkgs/test_descriptor/lib/src/utils.dart @@ -16,9 +16,7 @@ final utf8 = const Utf8Codec(allowMalformed: true); /// Prepends a vertical bar to [text]. String addBar(String text) => prefixLines(text, "${glyph.verticalLine} ", - first: "${glyph.downEnd} ", - last: "${glyph.upEnd} ", - single: "| "); + first: "${glyph.downEnd} ", last: "${glyph.upEnd} ", single: "| "); /// Indents [text], and adds a bullet at the beginning. String addBullet(String text) => @@ -33,8 +31,8 @@ String bullet(Iterable strings) => strings.map(addBullet).join("\n"); /// prefixed with those instead. If [single] is passed, it's used if there's /// only a single line; otherwise, [first], [last], or [prefix] is used, in that /// order of precedence. -String prefixLines(String text, String prefix, {String first, String last, - String single}) { +String prefixLines(String text, String prefix, + {String first, String last, String single}) { first ??= prefix; last ??= prefix; single ??= first ?? last ?? prefix; diff --git a/pkgs/test_descriptor/test/directory_test.dart b/pkgs/test_descriptor/test/directory_test.dart index cea9627b7..5507ea493 100644 --- a/pkgs/test_descriptor/test/directory_test.dart +++ b/pkgs/test_descriptor/test/directory_test.dart @@ -32,10 +32,12 @@ void main() { completion(equals('contents1'))); expect(new File(p.join(d.sandbox, 'dir', 'file2.txt')).readAsString(), completion(equals('contents2'))); - expect(new File(p.join(d.sandbox, 'dir', 'subdir', 'subfile1.txt')) + expect( + new File(p.join(d.sandbox, 'dir', 'subdir', 'subfile1.txt')) .readAsString(), completion(equals('subcontents1'))); - expect(new File(p.join(d.sandbox, 'dir', 'subdir', 'subfile2.txt')) + expect( + new File(p.join(d.sandbox, 'dir', 'subdir', 'subfile2.txt')) .readAsString(), completion(equals('subcontents2'))); }); @@ -78,16 +80,17 @@ void main() { await new File(p.join(dirPath, 'file1.txt')).writeAsString('contents1'); await new File(p.join(dirPath, 'file2.txt')).writeAsString('contents2'); - expect(d.dir('dir', [ - d.dir('subdir', [ - d.file('subfile1.txt', 'subcontents1'), - d.file('subfile2.txt', 'subcontents2') - ]), - d.file('file1.txt', 'contents1'), - d.file('file2.txt', 'contents2') - ]).validate(), - throwsA(toString(equals( - 'Directory not found: "${p.join('dir', 'subdir')}".')))); + expect( + d.dir('dir', [ + d.dir('subdir', [ + d.file('subfile1.txt', 'subcontents1'), + d.file('subfile2.txt', 'subcontents2') + ]), + d.file('file1.txt', 'contents1'), + d.file('file2.txt', 'contents2') + ]).validate(), + throwsA(toString( + equals('Directory not found: "${p.join('dir', 'subdir')}".')))); }); test("emits an error for each child that fails to validate", () async { @@ -109,37 +112,38 @@ void main() { d.file('file1.txt', 'contents1'), d.file('file2.txt', 'contents2') ]).validate(); - }, onError: expectAsync1((error) { - errors++; - controller.add(error.toString()); - if (errors == 3) controller.close(); - }, count: 3)); - - expect(controller.stream.toList(), completion(allOf([ - contains('File not found: "${p.join('dir', 'subdir', 'subfile1.txt')}".'), - contains('File not found: "${p.join('dir', 'file2.txt')}".'), - contains(startsWith('File "${p.join('dir', 'subdir', 'subfile2.txt')}" ' - 'should contain:')), - ]))); + }, + onError: expectAsync1((error) { + errors++; + controller.add(error.toString()); + if (errors == 3) controller.close(); + }, count: 3)); + + expect( + controller.stream.toList(), + completion(allOf([ + contains( + 'File not found: "${p.join('dir', 'subdir', 'subfile1.txt')}".'), + contains('File not found: "${p.join('dir', 'file2.txt')}".'), + contains( + startsWith('File "${p.join('dir', 'subdir', 'subfile2.txt')}" ' + 'should contain:')), + ]))); }); }); group("load()", () { test("loads a file", () { - var dir = d.dir('dir', [ - d.file('name.txt', 'contents'), - d.file('other.txt', 'wrong') - ]); + var dir = d.dir('dir', + [d.file('name.txt', 'contents'), d.file('other.txt', 'wrong')]); expect(UTF8.decodeStream(dir.load('name.txt')), completion(equals('contents'))); }); test("loads a deeply-nested file", () { var dir = d.dir('dir', [ - d.dir('subdir', [ - d.file('name.txt', 'subcontents'), - d.file('other.txt', 'wrong') - ]), + d.dir('subdir', + [d.file('name.txt', 'subcontents'), d.file('other.txt', 'wrong')]), d.dir('otherdir', [d.file('other.txt', 'wrong')]), d.file('name.txt', 'contents') ]); @@ -156,7 +160,8 @@ void main() { d.file('name.txt', 'contents') ]); - expect(dir.load('subdir/subsubdir').toList(), + expect( + dir.load('subdir/subsubdir').toList(), throwsA(toString(equals('Couldn\'t find a file descriptor named ' '"subsubdir" within "dir/subdir".')))); }); @@ -176,20 +181,20 @@ void main() { d.dir('subdir', [d.file('name.txt', 'contents')]) ]); - expect(dir.load('subdir/not-name.txt').toList(), + expect( + dir.load('subdir/not-name.txt').toList(), throwsA(toString(equals('Couldn\'t find a file descriptor named ' '"not-name.txt" within "dir/subdir".')))); }); test("fails to load a file that exists multiple times", () { var dir = d.dir('dir', [ - d.dir('subdir', [ - d.file('name.txt', 'contents'), - d.file('name.txt', 'contents') - ]) + d.dir('subdir', + [d.file('name.txt', 'contents'), d.file('name.txt', 'contents')]) ]); - expect(dir.load('subdir/name.txt').toList(), + expect( + dir.load('subdir/name.txt').toList(), throwsA(toString(equals('Found multiple file descriptors named ' '"name.txt" within "dir/subdir".')))); }); @@ -200,8 +205,8 @@ void main() { d.dir('name', [d.file('subfile', 'contents')]) ]); - expect(UTF8.decodeStream(dir.load('name')), - completion(equals('contents'))); + expect( + UTF8.decodeStream(dir.load('name')), completion(equals('contents'))); }); }); @@ -217,15 +222,14 @@ void main() { }); test("lists the contents of the directory", () { - var dir = d.dir('dir', [ - d.file('file1.txt', 'contents1'), - d.file('file2.txt', 'contents2') - ]); - - expect(dir.describe(), equals( - "dir\n" - "+-- file1.txt\n" - "'-- file2.txt")); + var dir = d.dir('dir', + [d.file('file1.txt', 'contents1'), d.file('file2.txt', 'contents2')]); + + expect( + dir.describe(), + equals("dir\n" + "+-- file1.txt\n" + "'-- file2.txt")); }); test("lists the contents of nested directories", () { @@ -234,22 +238,21 @@ void main() { d.dir('subdir', [ d.file('subfile1.txt', 'subcontents1'), d.file('subfile2.txt', 'subcontents2'), - d.dir('subsubdir', [ - d.file('subsubfile.txt', 'subsubcontents') - ]) + d.dir('subsubdir', [d.file('subsubfile.txt', 'subsubcontents')]) ]), d.file('file2.txt', 'contents2') ]); - expect(dir.describe(), equals( - "dir\n" - "+-- file1.txt\n" - "+-- subdir\n" - "| +-- subfile1.txt\n" - "| +-- subfile2.txt\n" - "| '-- subsubdir\n" - "| '-- subsubfile.txt\n" - "'-- file2.txt")); + expect( + dir.describe(), + equals("dir\n" + "+-- file1.txt\n" + "+-- subdir\n" + "| +-- subfile1.txt\n" + "| +-- subfile2.txt\n" + "| '-- subsubdir\n" + "| '-- subsubfile.txt\n" + "'-- file2.txt")); }); test("with no contents returns the directory name", () { @@ -290,10 +293,8 @@ void main() { await descriptor.create(); await d.dir('dir2', [ - d.dir('subdir', [ - d.file('subfile1.txt', 'subcontents1'), - d.nothing('.hidden') - ]), + d.dir('subdir', + [d.file('subfile1.txt', 'subcontents1'), d.nothing('.hidden')]), d.file('file1.txt', 'contents1'), d.nothing('.DS_Store') ]).validate(); diff --git a/pkgs/test_descriptor/test/file_test.dart b/pkgs/test_descriptor/test/file_test.dart index 4cdc184f1..b3be84007 100644 --- a/pkgs/test_descriptor/test/file_test.dart +++ b/pkgs/test_descriptor/test/file_test.dart @@ -31,8 +31,8 @@ void main() { }); test('fails to create a matcher file', () async { - expect(d.file('name.txt', contains('foo')).create(), - throwsUnsupportedError); + expect( + d.file('name.txt', contains('foo')).create(), throwsUnsupportedError); }); test('overwrites an existing file', () async { @@ -81,7 +81,8 @@ void main() { test("fails if the binary contents don't match", () async { await new File(p.join(d.sandbox, 'name.txt')).writeAsBytes([5, 4, 3, 2]); - expect(d.file('name.txt', [0, 1, 2, 3]).validate(), + expect( + d.file('name.txt', [0, 1, 2, 3]).validate(), throwsA(toString(equals( 'File "name.txt" didn\'t contain the expected binary data.')))); }); @@ -89,9 +90,10 @@ void main() { test("fails if the text contents don't match the matcher", () async { await new File(p.join(d.sandbox, 'name.txt')).writeAsString('wrong'); - expect(d.file('name.txt', contains('ent')).validate(), - throwsA(toString(startsWith( - 'Invalid contents for file "name.txt":')))); + expect( + d.file('name.txt', contains('ent')).validate(), + throwsA( + toString(startsWith('Invalid contents for file "name.txt":')))); }); test("fails if the binary contents don't match the matcher", () async { @@ -100,16 +102,18 @@ void main() { expect( new d.FileDescriptor.binaryMatcher('name.txt', contains(1)) .validate(), - throwsA(toString(startsWith( - 'Invalid contents for file "name.txt":')))); + throwsA( + toString(startsWith('Invalid contents for file "name.txt":')))); }); test("fails if invalid UTF-8 doesn't match a text matcher", () async { await new File(p.join(d.sandbox, 'name.txt')).writeAsBytes([0xC3, 0x28]); - expect(d.file('name.txt', isEmpty).validate(), throwsA(toString(allOf([ - startsWith('Invalid contents for file "name.txt":'), - contains('�') - ])))); + expect( + d.file('name.txt', isEmpty).validate(), + throwsA(toString(allOf([ + startsWith('Invalid contents for file "name.txt":'), + contains('�') + ])))); }); test("fails if there's no file", () { @@ -130,8 +134,7 @@ void main() { }); test("read() fails for a matcher file", () { - expect(d.file('name.txt', contains('hi')).read, - throwsUnsupportedError); + expect(d.file('name.txt', contains('hi')).read, throwsUnsupportedError); }); test("readAsBytes() returns the contents of a text file as a byte stream", diff --git a/pkgs/test_descriptor/test/nothing_test.dart b/pkgs/test_descriptor/test/nothing_test.dart index 916c3960a..d2935d062 100644 --- a/pkgs/test_descriptor/test/nothing_test.dart +++ b/pkgs/test_descriptor/test/nothing_test.dart @@ -17,8 +17,8 @@ void main() { test("create() does nothing", () async { await d.nothing('foo').create(); expect(new File(p.join(d.sandbox, 'foo')).exists(), completion(isFalse)); - expect(new Directory(p.join(d.sandbox, 'foo')).exists(), - completion(isFalse)); + expect( + new Directory(p.join(d.sandbox, 'foo')).exists(), completion(isFalse)); }); group("validate()", () { @@ -28,20 +28,26 @@ void main() { test("fails if there's a file", () async { await d.file('name.txt', 'contents').create(); - expect(d.nothing('name.txt').validate(), throwsA(toString(equals( - 'Expected nothing to exist at "name.txt", but found a file.')))); + expect( + d.nothing('name.txt').validate(), + throwsA(toString(equals( + 'Expected nothing to exist at "name.txt", but found a file.')))); }); test("fails if there's a directory", () async { await d.dir('dir').create(); - expect(d.nothing('dir').validate(), throwsA(toString(equals( - 'Expected nothing to exist at "dir", but found a directory.')))); + expect( + d.nothing('dir').validate(), + throwsA(toString(equals( + 'Expected nothing to exist at "dir", but found a directory.')))); }); test("fails if there's a broken link", () async { await new Link(p.join(d.sandbox, 'link')).create('nonexistent'); - expect(d.nothing('link').validate(), throwsA(toString(equals( - 'Expected nothing to exist at "link", but found a link.')))); + expect( + d.nothing('link').validate(), + throwsA(toString(equals( + 'Expected nothing to exist at "link", but found a link.')))); }); }); } diff --git a/pkgs/test_descriptor/test/pattern_test.dart b/pkgs/test_descriptor/test/pattern_test.dart index e5f196977..fb9b5bb8e 100644 --- a/pkgs/test_descriptor/test/pattern_test.dart +++ b/pkgs/test_descriptor/test/pattern_test.dart @@ -20,16 +20,13 @@ void main() { test("succeeds if there's a directory matching the pattern and the child", () async { - await d.dir('foo', [ - d.file('bar', 'baz') - ]).create(); + await d.dir('foo', [d.file('bar', 'baz')]).create(); - await d.dirPattern(new RegExp(r'f..'), [ - d.file('bar', 'baz') - ]).validate(); + await d.dirPattern(new RegExp(r'f..'), [d.file('bar', 'baz')]).validate(); }); - test("succeeds if multiple files match the pattern but only one matches " + test( + "succeeds if multiple files match the pattern but only one matches " "the child entry", () async { await d.file('foo', 'blap').create(); await d.file('fee', 'blak').create(); @@ -39,9 +36,10 @@ void main() { }); test("fails if there's no file matching the pattern", () { - expect(d.filePattern(new RegExp(r'f..'), 'bar').validate(), - throwsA(toString(equals( - 'No entries found in sandbox matching /f../.')))); + expect( + d.filePattern(new RegExp(r'f..'), 'bar').validate(), + throwsA( + toString(equals('No entries found in sandbox matching /f../.')))); }); test("fails if there's a file matching the pattern but not the entry", @@ -52,23 +50,22 @@ void main() { }); test("fails if there's a dir matching the pattern but not the entry", - () async{ - await d.dir('foo', [ - d.file('bar', 'bap') - ]).create(); + () async { + await d.dir('foo', [d.file('bar', 'bap')]).create(); - expect(d.dirPattern(new RegExp(r'f..'), [ - d.file('bar', 'baz') - ]).validate(), + expect( + d.dirPattern(new RegExp(r'f..'), [d.file('bar', 'baz')]).validate(), throwsA(toString(startsWith('File "foo/bar" should contain:')))); }); - test("fails if there are multiple files matching the pattern and the child " + test( + "fails if there are multiple files matching the pattern and the child " "entry", () async { await d.file('foo', 'bar').create(); await d.file('fee', 'bar').create(); await d.file('faa', 'bar').create(); - expect(d.filePattern(new RegExp(r'f..'), 'bar').validate(), + expect( + d.filePattern(new RegExp(r'f..'), 'bar').validate(), throwsA(toString(startsWith( "Multiple valid entries found in sandbox matching /f../:")))); }); From f22a69b715275d134d9548fb54b506f5c927d8b7 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Tue, 17 Oct 2017 12:04:24 -0700 Subject: [PATCH 08/72] Remove comment-based generic syntax (dart-lang/test_descriptor#10) It looks like this explicit generic wasn't necessary anymore anyway. Closes dart-lang/test_descriptor#9 --- pkgs/test_descriptor/CHANGELOG.md | 4 ++++ pkgs/test_descriptor/lib/src/pattern_descriptor.dart | 2 +- pkgs/test_descriptor/pubspec.yaml | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pkgs/test_descriptor/CHANGELOG.md b/pkgs/test_descriptor/CHANGELOG.md index 3d9ab03a9..02a58d9e9 100644 --- a/pkgs/test_descriptor/CHANGELOG.md +++ b/pkgs/test_descriptor/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.3 + +* Stop using comment-based generics. + ## 1.0.2 * Declare support for `async` 2.0.0. diff --git a/pkgs/test_descriptor/lib/src/pattern_descriptor.dart b/pkgs/test_descriptor/lib/src/pattern_descriptor.dart index 60cd1315b..0d2b60dfc 100644 --- a/pkgs/test_descriptor/lib/src/pattern_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/pattern_descriptor.dart @@ -60,7 +60,7 @@ class PatternDescriptor extends Descriptor { var results = await Future.wait(matchingEntries.map((entry) { var basename = p.basename(entry); return runZoned(() { - return Result.capture/**/(new Future.sync(() async { + return Result.capture(new Future.sync(() async { await _fn(basename).validate(parent); return basename; })); diff --git a/pkgs/test_descriptor/pubspec.yaml b/pkgs/test_descriptor/pubspec.yaml index 3a8472ec5..b86ec355c 100644 --- a/pkgs/test_descriptor/pubspec.yaml +++ b/pkgs/test_descriptor/pubspec.yaml @@ -1,11 +1,11 @@ name: test_descriptor -version: 1.0.2 +version: 1.0.3 description: An API for defining and verifying directory structures. author: Dart Team homepage: https://github.com/dart-lang/test_descriptor environment: - sdk: '>=1.8.0 <2.0.0' + sdk: '>=1.21.0 <2.0.0' dependencies: async: '>=1.10.0 <3.0.0' From f188cdf41590976b745ea1ec4474864b805bc5e4 Mon Sep 17 00:00:00 2001 From: Gary Roumanis Date: Fri, 15 Jun 2018 12:50:08 -0700 Subject: [PATCH 09/72] Support test 1.x.x --- pkgs/test_descriptor/.gitignore | 2 +- pkgs/test_descriptor/CHANGELOG.md | 4 ++++ pkgs/test_descriptor/pubspec.yaml | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pkgs/test_descriptor/.gitignore b/pkgs/test_descriptor/.gitignore index 25a1df332..0659a3398 100644 --- a/pkgs/test_descriptor/.gitignore +++ b/pkgs/test_descriptor/.gitignore @@ -1,9 +1,9 @@ .buildlog .DS_Store .idea -.pub/ .settings/ build/ packages .packages pubspec.lock +.dart_tool/ diff --git a/pkgs/test_descriptor/CHANGELOG.md b/pkgs/test_descriptor/CHANGELOG.md index 02a58d9e9..81c546147 100644 --- a/pkgs/test_descriptor/CHANGELOG.md +++ b/pkgs/test_descriptor/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.4 + +* Support test `1.x.x'. + ## 1.0.3 * Stop using comment-based generics. diff --git a/pkgs/test_descriptor/pubspec.yaml b/pkgs/test_descriptor/pubspec.yaml index b86ec355c..c304171da 100644 --- a/pkgs/test_descriptor/pubspec.yaml +++ b/pkgs/test_descriptor/pubspec.yaml @@ -1,5 +1,5 @@ name: test_descriptor -version: 1.0.3 +version: 1.0.4 description: An API for defining and verifying directory structures. author: Dart Team homepage: https://github.com/dart-lang/test_descriptor @@ -13,5 +13,5 @@ dependencies: matcher: '^0.12.0' path: '^1.0.0' stack_trace: '^1.0.0' - test: '^0.12.19' + test: '>=0.12.19 <2.0.0' term_glyph: '^1.0.0' From d9a6cac0bf17320709e1f26a8dd95e3df43da25b Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Mon, 18 Jun 2018 16:50:27 -0700 Subject: [PATCH 10/72] Add helpers to make it easier to do stuff in the sandbox (dart-lang/test_descriptor#13) --- pkgs/test_descriptor/CHANGELOG.md | 8 +++++ .../lib/src/directory_descriptor.dart | 4 +++ .../lib/src/file_descriptor.dart | 4 +++ pkgs/test_descriptor/lib/test_descriptor.dart | 5 +++ pkgs/test_descriptor/pubspec.yaml | 2 +- pkgs/test_descriptor/test/directory_test.dart | 4 +++ pkgs/test_descriptor/test/file_test.dart | 4 +++ pkgs/test_descriptor/test/sandbox_test.dart | 35 +++++++++++++++++++ 8 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 pkgs/test_descriptor/test/sandbox_test.dart diff --git a/pkgs/test_descriptor/CHANGELOG.md b/pkgs/test_descriptor/CHANGELOG.md index 81c546147..cbdb5cdaa 100644 --- a/pkgs/test_descriptor/CHANGELOG.md +++ b/pkgs/test_descriptor/CHANGELOG.md @@ -1,3 +1,11 @@ +## 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'. diff --git a/pkgs/test_descriptor/lib/src/directory_descriptor.dart b/pkgs/test_descriptor/lib/src/directory_descriptor.dart index 32b2e0796..0b9f36fd8 100644 --- a/pkgs/test_descriptor/lib/src/directory_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/directory_descriptor.dart @@ -27,6 +27,10 @@ class DirectoryDescriptor extends Descriptor { /// This may be modified. final List contents; + /// Returns a `dart:io` [Directory] object that refers to this file within + /// [sandbox]. + Directory get io => new Directory(p.join(sandbox, name)); + DirectoryDescriptor(String name, Iterable contents) : contents = contents.toList(), super(name); diff --git a/pkgs/test_descriptor/lib/src/file_descriptor.dart b/pkgs/test_descriptor/lib/src/file_descriptor.dart index 1d7a10928..ef030f0c9 100644 --- a/pkgs/test_descriptor/lib/src/file_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/file_descriptor.dart @@ -44,6 +44,10 @@ abstract class FileDescriptor extends Descriptor { return new _MatcherFileDescriptor(name, contents); } + /// Returns a `dart:io` [File] object that refers to this file within + /// [sandbox]. + File get io => new File(p.join(sandbox, name)); + /// Creates a new binary [FileDescriptor] with [name] that matches its binary /// contents against [matcher]. /// diff --git a/pkgs/test_descriptor/lib/test_descriptor.dart b/pkgs/test_descriptor/lib/test_descriptor.dart index 54649ab3c..fe27b9246 100644 --- a/pkgs/test_descriptor/lib/test_descriptor.dart +++ b/pkgs/test_descriptor/lib/test_descriptor.dart @@ -2,6 +2,7 @@ // 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 'package:path/path.dart' as p; import 'package:test/test.dart'; import 'src/descriptor.dart'; @@ -9,6 +10,7 @@ import 'src/directory_descriptor.dart'; import 'src/file_descriptor.dart'; import 'src/nothing_descriptor.dart'; import 'src/pattern_descriptor.dart'; +import 'src/sandbox.dart'; export 'src/descriptor.dart'; export 'src/directory_descriptor.dart'; @@ -70,3 +72,6 @@ PatternDescriptor filePattern(Pattern name, [contents]) => /// constructs a [DirectoryDescriptor] descriptor. PatternDescriptor dirPattern(Pattern name, [Iterable contents]) => pattern(name, (realName) => dir(realName, contents)); + +/// Returns [path] within the [sandbox] directory. +String path(String path) => p.join(sandbox, path); diff --git a/pkgs/test_descriptor/pubspec.yaml b/pkgs/test_descriptor/pubspec.yaml index c304171da..af77fab26 100644 --- a/pkgs/test_descriptor/pubspec.yaml +++ b/pkgs/test_descriptor/pubspec.yaml @@ -1,5 +1,5 @@ name: test_descriptor -version: 1.0.4 +version: 1.1.0 description: An API for defining and verifying directory structures. author: Dart Team homepage: https://github.com/dart-lang/test_descriptor diff --git a/pkgs/test_descriptor/test/directory_test.dart b/pkgs/test_descriptor/test/directory_test.dart index 5507ea493..97dcacb4d 100644 --- a/pkgs/test_descriptor/test/directory_test.dart +++ b/pkgs/test_descriptor/test/directory_test.dart @@ -300,4 +300,8 @@ void main() { ]).validate(); }); }); + + test("io refers to the directory within the sandbox", () { + expect(d.file('dir').io.path, equals(p.join(d.sandbox, 'dir'))); + }); } diff --git a/pkgs/test_descriptor/test/file_test.dart b/pkgs/test_descriptor/test/file_test.dart index b3be84007..70093c10e 100644 --- a/pkgs/test_descriptor/test/file_test.dart +++ b/pkgs/test_descriptor/test/file_test.dart @@ -154,4 +154,8 @@ void main() { throwsUnsupportedError); }); }); + + test("io refers to the file within the sandbox", () { + expect(d.file('name.txt').io.path, equals(p.join(d.sandbox, 'name.txt'))); + }); } diff --git a/pkgs/test_descriptor/test/sandbox_test.dart b/pkgs/test_descriptor/test/sandbox_test.dart new file mode 100644 index 000000000..34c90ac79 --- /dev/null +++ b/pkgs/test_descriptor/test/sandbox_test.dart @@ -0,0 +1,35 @@ +// Copyright (c) 2018, 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. + +@TestOn('vm') + +import 'dart:async'; +import 'dart:convert'; +import 'dart:io'; + +import 'package:path/path.dart' as p; +import 'package:test/test.dart'; + +import 'package:test_descriptor/test_descriptor.dart' as d; + +import 'utils.dart'; + +void main() { + test("accessing the getter creates the directory", () { + expect(new Directory(d.sandbox).existsSync(), isTrue); + }); + + test("the directory is deleted after the test", () { + String sandbox; + addTearDown(() { + expect(new Directory(sandbox).existsSync(), isFalse); + }); + + sandbox = d.sandbox; + }); + + test("path() returns a path in the sandbox", () { + expect(d.path("foo"), equals(p.join(d.sandbox, "foo"))); + }); +} From 0f753c2a7c9a2dfe89ea1075014297c57f010881 Mon Sep 17 00:00:00 2001 From: Mike Fairhurst Date: Fri, 29 Jun 2018 12:05:31 -0700 Subject: [PATCH 11/72] Fix code awaiting void values, for dart 2. --- pkgs/test_descriptor/lib/src/file_descriptor.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/test_descriptor/lib/src/file_descriptor.dart b/pkgs/test_descriptor/lib/src/file_descriptor.dart index ef030f0c9..93dec586a 100644 --- a/pkgs/test_descriptor/lib/src/file_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/file_descriptor.dart @@ -85,7 +85,7 @@ abstract class FileDescriptor extends Descriptor { /// /// The [prettyPath] is a human-friendly representation of the path to the /// descriptor. - void _validate(String prettyPath, List binaryContents); + Future _validate(String prettyPath, List binaryContents); /// Reads and decodes the contents of this descriptor as a UTF-8 string. /// @@ -184,7 +184,7 @@ class _MatcherFileDescriptor extends FileDescriptor { Stream> readAsBytes() => throw new UnsupportedError("Matcher files can't be created or read."); - void _validate(String prettyPath, List actualContents) { + Future _validate(String prettyPath, List actualContents) async { try { expect( _isBinary ? actualContents : utf8.decode(actualContents), _matcher); From c2dab5a2ae337cdb88b0c84c3c4ed1e20b299b60 Mon Sep 17 00:00:00 2001 From: Bob Nystrom Date: Thu, 12 Jul 2018 14:34:33 -0700 Subject: [PATCH 12/72] Fix dart:convert "UTF8" -> "utf8". While I was at it, I: - Removed some unused imports. - Fixed a deprecated API call. - Removed the no-longer needed analysis options file. --- pkgs/test_descriptor/CHANGELOG.md | 4 ++++ pkgs/test_descriptor/analysis_options.yaml | 2 -- pkgs/test_descriptor/lib/src/file_descriptor.dart | 2 +- pkgs/test_descriptor/pubspec.yaml | 4 ++-- pkgs/test_descriptor/test/directory_test.dart | 6 +++--- pkgs/test_descriptor/test/file_test.dart | 2 +- pkgs/test_descriptor/test/sandbox_test.dart | 4 ---- 7 files changed, 11 insertions(+), 13 deletions(-) delete mode 100644 pkgs/test_descriptor/analysis_options.yaml diff --git a/pkgs/test_descriptor/CHANGELOG.md b/pkgs/test_descriptor/CHANGELOG.md index cbdb5cdaa..46908ef16 100644 --- a/pkgs/test_descriptor/CHANGELOG.md +++ b/pkgs/test_descriptor/CHANGELOG.md @@ -1,3 +1,7 @@ +## 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. diff --git a/pkgs/test_descriptor/analysis_options.yaml b/pkgs/test_descriptor/analysis_options.yaml deleted file mode 100644 index a10d4c5a0..000000000 --- a/pkgs/test_descriptor/analysis_options.yaml +++ /dev/null @@ -1,2 +0,0 @@ -analyzer: - strong-mode: true diff --git a/pkgs/test_descriptor/lib/src/file_descriptor.dart b/pkgs/test_descriptor/lib/src/file_descriptor.dart index 93dec586a..5220b6ea7 100644 --- a/pkgs/test_descriptor/lib/src/file_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/file_descriptor.dart @@ -38,7 +38,7 @@ abstract class FileDescriptor extends Descriptor { factory FileDescriptor(String name, contents) { if (contents is String) return new _StringFileDescriptor(name, contents); if (contents is List) { - return new _BinaryFileDescriptor(name, DelegatingList.typed(contents)); + return new _BinaryFileDescriptor(name, contents.cast()); } if (contents == null) return new _BinaryFileDescriptor(name, []); return new _MatcherFileDescriptor(name, contents); diff --git a/pkgs/test_descriptor/pubspec.yaml b/pkgs/test_descriptor/pubspec.yaml index af77fab26..68e91dbbf 100644 --- a/pkgs/test_descriptor/pubspec.yaml +++ b/pkgs/test_descriptor/pubspec.yaml @@ -1,11 +1,11 @@ name: test_descriptor -version: 1.1.0 +version: 1.1.1 description: An API for defining and verifying directory structures. author: Dart Team homepage: https://github.com/dart-lang/test_descriptor environment: - sdk: '>=1.21.0 <2.0.0' + sdk: '>=2.0.0-dev.36.0 <3.0.0' dependencies: async: '>=1.10.0 <3.0.0' diff --git a/pkgs/test_descriptor/test/directory_test.dart b/pkgs/test_descriptor/test/directory_test.dart index 97dcacb4d..d455e16fb 100644 --- a/pkgs/test_descriptor/test/directory_test.dart +++ b/pkgs/test_descriptor/test/directory_test.dart @@ -136,7 +136,7 @@ void main() { test("loads a file", () { var dir = d.dir('dir', [d.file('name.txt', 'contents'), d.file('other.txt', 'wrong')]); - expect(UTF8.decodeStream(dir.load('name.txt')), + expect(utf8.decodeStream(dir.load('name.txt')), completion(equals('contents'))); }); @@ -148,7 +148,7 @@ void main() { d.file('name.txt', 'contents') ]); - expect(UTF8.decodeStream(dir.load('subdir/name.txt')), + expect(utf8.decodeStream(dir.load('subdir/name.txt')), completion(equals('subcontents'))); }); @@ -206,7 +206,7 @@ void main() { ]); expect( - UTF8.decodeStream(dir.load('name')), completion(equals('contents'))); + utf8.decodeStream(dir.load('name')), completion(equals('contents'))); }); }); diff --git a/pkgs/test_descriptor/test/file_test.dart b/pkgs/test_descriptor/test/file_test.dart index 70093c10e..cbc670acd 100644 --- a/pkgs/test_descriptor/test/file_test.dart +++ b/pkgs/test_descriptor/test/file_test.dart @@ -139,7 +139,7 @@ void main() { test("readAsBytes() returns the contents of a text file as a byte stream", () { - expect(UTF8.decodeStream(d.file('name.txt', 'contents').readAsBytes()), + expect(utf8.decodeStream(d.file('name.txt', 'contents').readAsBytes()), completion(equals('contents'))); }); diff --git a/pkgs/test_descriptor/test/sandbox_test.dart b/pkgs/test_descriptor/test/sandbox_test.dart index 34c90ac79..be4a95949 100644 --- a/pkgs/test_descriptor/test/sandbox_test.dart +++ b/pkgs/test_descriptor/test/sandbox_test.dart @@ -4,8 +4,6 @@ @TestOn('vm') -import 'dart:async'; -import 'dart:convert'; import 'dart:io'; import 'package:path/path.dart' as p; @@ -13,8 +11,6 @@ import 'package:test/test.dart'; import 'package:test_descriptor/test_descriptor.dart' as d; -import 'utils.dart'; - void main() { test("accessing the getter creates the directory", () { expect(new Directory(d.sandbox).existsSync(), isTrue); From 9f15b417295db37aa520bba1084e0ed13e041837 Mon Sep 17 00:00:00 2001 From: Bob Nystrom Date: Thu, 12 Jul 2018 16:30:30 -0700 Subject: [PATCH 13/72] Don't run Travis on stable. --- pkgs/test_descriptor/.travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/test_descriptor/.travis.yml b/pkgs/test_descriptor/.travis.yml index a0653e381..1acfc69f3 100644 --- a/pkgs/test_descriptor/.travis.yml +++ b/pkgs/test_descriptor/.travis.yml @@ -2,7 +2,6 @@ language: dart dart: - dev - - stable dart_task: - test From a115baf3aa58d8de610d6c9bc01148c31fe7ee63 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 29 Apr 2019 17:30:26 -0700 Subject: [PATCH 14/72] Enable and fix a number of lints, test on the oldest supported SDK (dart-lang/test_descriptor#19) --- pkgs/test_descriptor/.travis.yml | 14 ++-- pkgs/test_descriptor/analysis_options.yaml | 65 +++++++++++++++++++ pkgs/test_descriptor/lib/src/descriptor.dart | 2 + .../lib/src/directory_descriptor.dart | 24 +++---- .../lib/src/file_descriptor.dart | 31 +++++---- .../lib/src/nothing_descriptor.dart | 6 +- .../lib/src/pattern_descriptor.dart | 25 ++++--- pkgs/test_descriptor/lib/src/sandbox.dart | 2 +- pkgs/test_descriptor/lib/src/utils.dart | 4 +- pkgs/test_descriptor/lib/test_descriptor.dart | 9 ++- pkgs/test_descriptor/pubspec.yaml | 5 +- pkgs/test_descriptor/test/directory_test.dart | 40 ++++++------ pkgs/test_descriptor/test/file_test.dart | 36 +++++----- pkgs/test_descriptor/test/nothing_test.dart | 7 +- pkgs/test_descriptor/test/pattern_test.dart | 15 ++--- pkgs/test_descriptor/test/sandbox_test.dart | 4 +- 16 files changed, 176 insertions(+), 113 deletions(-) create mode 100644 pkgs/test_descriptor/analysis_options.yaml diff --git a/pkgs/test_descriptor/.travis.yml b/pkgs/test_descriptor/.travis.yml index 1acfc69f3..415bad401 100644 --- a/pkgs/test_descriptor/.travis.yml +++ b/pkgs/test_descriptor/.travis.yml @@ -2,23 +2,25 @@ language: dart dart: - dev + - 2.0.0 dart_task: - test -# Only run one instance of the formatter and the analyzer, rather than running -# them against each Dart version. matrix: include: - dart: dev dart_task: dartfmt - dart: dev - dart_task: dartanalyzer + dart_task: + dartanalyzer: --fatal-infos --fatal-warnings . + - dart: 2.0.0 + dart_task: + dartanalyzer: --fatal-warnings . -# Only building master means that we don't run two builds for each pull request. branches: only: [master] cache: - directories: - - $HOME/.pub-cache + directories: + - $HOME/.pub-cache diff --git a/pkgs/test_descriptor/analysis_options.yaml b/pkgs/test_descriptor/analysis_options.yaml new file mode 100644 index 000000000..1384ade90 --- /dev/null +++ b/pkgs/test_descriptor/analysis_options.yaml @@ -0,0 +1,65 @@ +include: package:pedantic/analysis_options.yaml +analyzer: + strong-mode: + implicit-casts: false + errors: + unused_element: error + unused_import: error + unused_local_variable: error + dead_code: error +linter: + rules: + #- annotate_overrides + - avoid_function_literals_in_foreach_calls + - avoid_init_to_null + - avoid_null_checks_in_equality_operators + - avoid_relative_lib_imports + - avoid_returning_null + - avoid_unused_constructor_parameters + - await_only_futures + - camel_case_types + - cancel_subscriptions + - comment_references + - constant_identifier_names + - control_flow_in_finally + - directives_ordering + - empty_catches + - empty_constructor_bodies + - empty_statements + - hash_and_equals + - implementation_imports + - invariant_booleans + - iterable_contains_unrelated_type + - library_names + - library_prefixes + - list_remove_unrelated_type + - no_adjacent_strings_in_list + - non_constant_identifier_names + - omit_local_variable_types + - only_throw_errors + - overridden_fields + - package_api_docs + - package_names + - package_prefixed_library_names + - prefer_adjacent_string_concatenation + - prefer_collection_literals + - prefer_conditional_assignment + - prefer_const_constructors + - prefer_final_fields + - prefer_generic_function_type_aliases + - prefer_initializing_formals + - prefer_interpolation_to_compose_strings + #- prefer_single_quotes + - prefer_typing_uninitialized_variables + - slash_for_doc_comments + - test_types_in_equals + - throw_in_finally + - type_init_formals + - unnecessary_brace_in_string_interps + - unnecessary_const + - unnecessary_getters_setters + - unnecessary_lambdas + - unnecessary_new + - unnecessary_null_aware_assignments + - unnecessary_statements + - unnecessary_this diff --git a/pkgs/test_descriptor/lib/src/descriptor.dart b/pkgs/test_descriptor/lib/src/descriptor.dart index 363bc90a6..43de75d11 100644 --- a/pkgs/test_descriptor/lib/src/descriptor.dart +++ b/pkgs/test_descriptor/lib/src/descriptor.dart @@ -4,6 +4,8 @@ import 'dart:async'; +import 'sandbox.dart'; + /// A declarative description of a filesystem entry. /// /// This may be extended outside this package. diff --git a/pkgs/test_descriptor/lib/src/directory_descriptor.dart b/pkgs/test_descriptor/lib/src/directory_descriptor.dart index 0b9f36fd8..4674a107e 100644 --- a/pkgs/test_descriptor/lib/src/directory_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/directory_descriptor.dart @@ -29,7 +29,7 @@ class DirectoryDescriptor extends Descriptor { /// Returns a `dart:io` [Directory] object that refers to this file within /// [sandbox]. - Directory get io => new Directory(p.join(sandbox, name)); + Directory get io => Directory(p.join(sandbox, name)); DirectoryDescriptor(String name, Iterable contents) : contents = contents.toList(), @@ -38,17 +38,17 @@ class DirectoryDescriptor extends Descriptor { /// Creates a directory descriptor named [name] that describes the physical /// directory at [path]. factory DirectoryDescriptor.fromFilesystem(String name, String path) { - return new DirectoryDescriptor( + return DirectoryDescriptor( name, - new Directory(path).listSync().map((entity) { + Directory(path).listSync().map((entity) { // Ignore hidden files. if (p.basename(entity.path).startsWith(".")) return null; if (entity is Directory) { - return new DirectoryDescriptor.fromFilesystem( + return DirectoryDescriptor.fromFilesystem( p.basename(entity.path), entity.path); } else if (entity is File) { - return new FileDescriptor( + return FileDescriptor( p.basename(entity.path), entity.readAsBytesSync()); } // Ignore broken symlinks. @@ -57,13 +57,13 @@ class DirectoryDescriptor extends Descriptor { Future create([String parent]) async { var fullPath = p.join(parent ?? sandbox, name); - await new Directory(fullPath).create(recursive: true); + await Directory(fullPath).create(recursive: true); await Future.wait(contents.map((entry) => entry.create(fullPath))); } Future validate([String parent]) async { var fullPath = p.join(parent ?? sandbox, name); - if (!(await new Directory(fullPath).exists())) { + if (!(await Directory(fullPath).exists())) { fail('Directory not found: "${prettyPath(fullPath)}".'); } @@ -75,7 +75,7 @@ class DirectoryDescriptor extends Descriptor { /// contents of the [FileDescriptor] at the given relative [url], which may be /// a [Uri] or a [String]. /// - /// The [parent] parameter should only be passed by subclasses of + /// The [parents] parameter should only be passed by subclasses of /// [DirectoryDescriptor] that are recursively calling [load]. It's the /// URL-format path of the directories that have been loaded so far. Stream> load(url, [String parents]) { @@ -85,15 +85,15 @@ class DirectoryDescriptor extends Descriptor { } else if (url is Uri) { path = url.toString(); } else { - throw new ArgumentError.value(url, "url", "must be a Uri or a String."); + throw ArgumentError.value(url, "url", "must be a Uri or a String."); } if (!p.url.isWithin('.', path)) { - throw new ArgumentError.value( + throw ArgumentError.value( url, "url", "must be relative and beneath the base URL."); } - return StreamCompleter.fromFuture(new Future.sync(() { + return StreamCompleter.fromFuture(Future.sync(() { var split = p.url.split(p.url.normalize(path)); var file = split.length == 1; var matchingEntries = contents.where((entry) { @@ -124,7 +124,7 @@ class DirectoryDescriptor extends Descriptor { String describe() { if (contents.isEmpty) return name; - var buffer = new StringBuffer(); + var buffer = StringBuffer(); buffer.writeln(name); for (var entry in contents.take(contents.length - 1)) { var entryString = diff --git a/pkgs/test_descriptor/lib/src/file_descriptor.dart b/pkgs/test_descriptor/lib/src/file_descriptor.dart index 5220b6ea7..b755ee50e 100644 --- a/pkgs/test_descriptor/lib/src/file_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/file_descriptor.dart @@ -36,17 +36,17 @@ abstract class FileDescriptor extends Descriptor { /// To match a [Matcher] against a file's binary contents, use [new /// FileDescriptor.binaryMatcher] instead. factory FileDescriptor(String name, contents) { - if (contents is String) return new _StringFileDescriptor(name, contents); + if (contents is String) return _StringFileDescriptor(name, contents); if (contents is List) { - return new _BinaryFileDescriptor(name, contents.cast()); + return _BinaryFileDescriptor(name, contents.cast()); } - if (contents == null) return new _BinaryFileDescriptor(name, []); - return new _MatcherFileDescriptor(name, contents); + if (contents == null) return _BinaryFileDescriptor(name, []); + return _MatcherFileDescriptor(name, contents as Matcher); } /// Returns a `dart:io` [File] object that refers to this file within /// [sandbox]. - File get io => new File(p.join(sandbox, name)); + File get io => File(p.join(sandbox, name)); /// Creates a new binary [FileDescriptor] with [name] that matches its binary /// contents against [matcher]. @@ -54,7 +54,7 @@ abstract class FileDescriptor extends Descriptor { /// The [create], [read], and [readAsBytes] methods are unsupported for this /// descriptor. factory FileDescriptor.binaryMatcher(String name, Matcher matcher) => - new _MatcherFileDescriptor(name, matcher, isBinary: true); + _MatcherFileDescriptor(name, matcher, isBinary: true); /// A protected constructor that's only intended for subclasses. FileDescriptor.protected(String name) : super(name); @@ -62,7 +62,7 @@ abstract class FileDescriptor extends Descriptor { Future create([String parent]) async { // Create the stream before we call [File.openWrite] because it may fail // fast (e.g. if this is a matcher file). - var file = new File(p.join(parent ?? sandbox, name)).openWrite(); + var file = File(p.join(parent ?? sandbox, name)).openWrite(); try { await readAsBytes().listen(file.add).asFuture(); } finally { @@ -73,11 +73,11 @@ abstract class FileDescriptor extends Descriptor { Future validate([String parent]) async { var fullPath = p.join(parent ?? sandbox, name); var pretty = prettyPath(fullPath); - if (!(await new File(fullPath).exists())) { + if (!(await File(fullPath).exists())) { fail('File not found: "$pretty".'); } - await _validate(pretty, await new File(fullPath).readAsBytes()); + await _validate(pretty, await File(fullPath).readAsBytes()); } /// Validates that [binaryContents] matches the expected contents of @@ -106,7 +106,7 @@ class _BinaryFileDescriptor extends FileDescriptor { _BinaryFileDescriptor(String name, this._contents) : super.protected(name); - Stream> readAsBytes() => new Stream.fromIterable([_contents]); + Stream> readAsBytes() => Stream.fromIterable([_contents]); Future _validate(String prettPath, List actualContents) async { if (const IterableEquality().equals(_contents, actualContents)) return null; @@ -124,12 +124,12 @@ class _StringFileDescriptor extends FileDescriptor { Future read() async => _contents; Stream> readAsBytes() => - new Stream.fromIterable([utf8.encode(_contents)]); + Stream.fromIterable([utf8.encode(_contents)]); Future _validate(String prettyPath, List actualContents) { var actualContentsText = utf8.decode(actualContents); if (_contents == actualContentsText) return null; - throw fail(_textMismatchMessage(prettyPath, _contents, actualContentsText)); + fail(_textMismatchMessage(prettyPath, _contents, actualContentsText)); } String _textMismatchMessage( @@ -177,20 +177,19 @@ class _MatcherFileDescriptor extends FileDescriptor { /// contents. final bool _isBinary; - _MatcherFileDescriptor(String name, this._matcher, {bool isBinary: false}) + _MatcherFileDescriptor(String name, this._matcher, {bool isBinary = false}) : _isBinary = isBinary, super.protected(name); Stream> readAsBytes() => - throw new UnsupportedError("Matcher files can't be created or read."); + throw UnsupportedError("Matcher files can't be created or read."); Future _validate(String prettyPath, List actualContents) async { try { expect( _isBinary ? actualContents : utf8.decode(actualContents), _matcher); } on TestFailure catch (error) { - throw new TestFailure( - 'Invalid contents for file "$prettyPath":\n' + error.message); + fail('Invalid contents for file "$prettyPath":\n${error.message}'); } } } diff --git a/pkgs/test_descriptor/lib/src/nothing_descriptor.dart b/pkgs/test_descriptor/lib/src/nothing_descriptor.dart index 2d62cb09a..98abe61cd 100644 --- a/pkgs/test_descriptor/lib/src/nothing_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/nothing_descriptor.dart @@ -23,11 +23,11 @@ class NothingDescriptor extends Descriptor { Future validate([String parent]) async { var fullPath = p.join(parent ?? sandbox, name); var pretty = prettyPath(fullPath); - if (new File(fullPath).existsSync()) { + if (File(fullPath).existsSync()) { fail('Expected nothing to exist at "$pretty", but found a file.'); - } else if (new Directory(fullPath).existsSync()) { + } else if (Directory(fullPath).existsSync()) { fail('Expected nothing to exist at "$pretty", but found a directory.'); - } else if (new Link(fullPath).existsSync()) { + } else if (Link(fullPath).existsSync()) { fail('Expected nothing to exist at "$pretty", but found a link.'); } } diff --git a/pkgs/test_descriptor/lib/src/pattern_descriptor.dart b/pkgs/test_descriptor/lib/src/pattern_descriptor.dart index 0d2b60dfc..3432876f0 100644 --- a/pkgs/test_descriptor/lib/src/pattern_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/pattern_descriptor.dart @@ -16,7 +16,7 @@ import 'utils.dart'; /// A function that takes a name for a [Descriptor] and returns a [Descriptor]. /// This is used for [PatternDescriptor]s, where the name isn't known /// ahead-of-time. -typedef Descriptor _EntryCreator(String name); +typedef _EntryCreator = Descriptor Function(String name); /// A descriptor that matches filesystem entity names by [Pattern] rather than /// by exact [String]. @@ -31,20 +31,19 @@ class PatternDescriptor extends Descriptor { /// matching [pattern]. final _EntryCreator _fn; - PatternDescriptor(Pattern pattern, Descriptor child(String basename)) - : pattern = pattern, - _fn = child, + PatternDescriptor(this.pattern, Descriptor child(String basename)) + : _fn = child, super('$pattern'); /// Validates that there is some filesystem entity in [parent] that matches /// [pattern] and the child entry. This finds all entities in [parent] - /// matching [pattern], then passes each of their names to the [EntityCreator] - /// and validates the result. If exactly one succeeds, [this] is considered - /// valid. + /// matching [pattern], then passes each of their names to `child` provided + /// in the constructor and validates the result. If exactly one succeeds, + /// `this` is considered valid. Future validate([String parent]) async { var inSandbox = parent == null; parent ??= sandbox; - var matchingEntries = await new Directory(parent) + var matchingEntries = await Directory(parent) .list() .map((entry) => entry is File ? entry.resolveSymbolicLinksSync() : entry.path) @@ -54,13 +53,13 @@ class PatternDescriptor extends Descriptor { var location = inSandbox ? "sandbox" : '"${prettyPath(parent)}"'; if (matchingEntries.isEmpty) { - fail('No entries found in $location matching ${_patternDescription}.'); + fail('No entries found in $location matching $_patternDescription.'); } var results = await Future.wait(matchingEntries.map((entry) { var basename = p.basename(entry); return runZoned(() { - return Result.capture(new Future.sync(() async { + return Result.capture(Future.sync(() async { await _fn(basename).validate(parent); return basename; })); @@ -72,7 +71,7 @@ class PatternDescriptor extends Descriptor { }).toList()); var successes = results.where((result) => result.isValue).toList(); - if (successes.length == 0) { + if (successes.isEmpty) { await waitAndReportErrors(results.map((result) => result.asFuture)); } else if (successes.length > 1) { fail('Multiple valid entries found in $location matching ' @@ -88,13 +87,13 @@ class PatternDescriptor extends Descriptor { if (pattern is! RegExp) return '$pattern'; var regExp = pattern as RegExp; - var flags = new StringBuffer(); + var flags = StringBuffer(); if (!regExp.isCaseSensitive) flags.write('i'); if (regExp.isMultiLine) flags.write('m'); return '/${regExp.pattern}/$flags'; } Future create([String parent]) { - throw new UnsupportedError("Pattern descriptors don't support create()."); + throw UnsupportedError("Pattern descriptors don't support create()."); } } diff --git a/pkgs/test_descriptor/lib/src/sandbox.dart b/pkgs/test_descriptor/lib/src/sandbox.dart index eee1252cc..a09145ee4 100644 --- a/pkgs/test_descriptor/lib/src/sandbox.dart +++ b/pkgs/test_descriptor/lib/src/sandbox.dart @@ -23,7 +23,7 @@ String get sandbox { addTearDown(() async { var sandbox = _sandbox; _sandbox = null; - await new Directory(sandbox).delete(recursive: true); + await Directory(sandbox).delete(recursive: true); }); return _sandbox; diff --git a/pkgs/test_descriptor/lib/src/utils.dart b/pkgs/test_descriptor/lib/src/utils.dart index 3e1d12eaf..9a14b7000 100644 --- a/pkgs/test_descriptor/lib/src/utils.dart +++ b/pkgs/test_descriptor/lib/src/utils.dart @@ -40,7 +40,7 @@ String prefixLines(String text, String prefix, var lines = text.split('\n'); if (lines.length == 1) return "$single$text"; - var buffer = new StringBuffer("$first${lines.first}\n"); + var buffer = StringBuffer("$first${lines.first}\n"); for (var line in lines.skip(1).take(lines.length - 2)) { buffer.writeln("$prefix$line"); } @@ -72,7 +72,7 @@ Future waitAndReportErrors(Iterable futures) { return Future.wait(futures.map((future) { // Avoid async/await so that we synchronously add error handlers for the // futures to keep them from top-leveling. - return future.catchError((error, stackTrace) { + return future.catchError((error, StackTrace stackTrace) { if (!errored) { errored = true; throw error; diff --git a/pkgs/test_descriptor/lib/test_descriptor.dart b/pkgs/test_descriptor/lib/test_descriptor.dart index fe27b9246..cc3371425 100644 --- a/pkgs/test_descriptor/lib/test_descriptor.dart +++ b/pkgs/test_descriptor/lib/test_descriptor.dart @@ -32,8 +32,7 @@ export 'src/sandbox.dart' show sandbox; /// /// To match a [Matcher] against a file's binary contents, use [new /// FileDescriptor.binaryMatcher] instead. -FileDescriptor file(String name, [contents]) => - new FileDescriptor(name, contents); +FileDescriptor file(String name, [contents]) => FileDescriptor(name, contents); /// Creates a new [DirectoryDescriptor] descriptor with [name] and [contents]. /// @@ -42,13 +41,13 @@ FileDescriptor file(String name, [contents]) => /// children exist. To ensure that a particular child doesn't exist, use /// [nothing]. DirectoryDescriptor dir(String name, [Iterable contents]) => - new DirectoryDescriptor(name, contents == null ? [] : contents); + DirectoryDescriptor(name, contents == null ? [] : contents); /// Creates a new [NothingDescriptor] descriptor that asserts that no entry /// named [name] exists. /// /// [Descriptor.create] does nothing for this descriptor. -NothingDescriptor nothing(String name) => new NothingDescriptor(name); +NothingDescriptor nothing(String name) => NothingDescriptor(name); /// Creates a new [PatternDescriptor] descriptor that asserts than an entry with /// a name matching [pattern] exists, and matches the [Descriptor] returned @@ -61,7 +60,7 @@ NothingDescriptor nothing(String name) => new NothingDescriptor(name); /// /// [Descriptor.create] is not supported for this descriptor. PatternDescriptor pattern(Pattern name, Descriptor child(String basename)) => - new PatternDescriptor(name, child); + PatternDescriptor(name, child); /// A convenience method for creating a [PatternDescriptor] descriptor that /// constructs a [FileDescriptor] descriptor. diff --git a/pkgs/test_descriptor/pubspec.yaml b/pkgs/test_descriptor/pubspec.yaml index 68e91dbbf..d39384e23 100644 --- a/pkgs/test_descriptor/pubspec.yaml +++ b/pkgs/test_descriptor/pubspec.yaml @@ -5,7 +5,7 @@ author: Dart Team homepage: https://github.com/dart-lang/test_descriptor environment: - sdk: '>=2.0.0-dev.36.0 <3.0.0' + sdk: '>=2.0.0 <3.0.0' dependencies: async: '>=1.10.0 <3.0.0' @@ -15,3 +15,6 @@ dependencies: stack_trace: '^1.0.0' test: '>=0.12.19 <2.0.0' term_glyph: '^1.0.0' + +dev_dependencies: + pedantic: ^1.0.0 diff --git a/pkgs/test_descriptor/test/directory_test.dart b/pkgs/test_descriptor/test/directory_test.dart index d455e16fb..b03edc343 100644 --- a/pkgs/test_descriptor/test/directory_test.dart +++ b/pkgs/test_descriptor/test/directory_test.dart @@ -28,16 +28,16 @@ void main() { d.file('file2.txt', 'contents2') ]).create(); - expect(new File(p.join(d.sandbox, 'dir', 'file1.txt')).readAsString(), + expect(File(p.join(d.sandbox, 'dir', 'file1.txt')).readAsString(), completion(equals('contents1'))); - expect(new File(p.join(d.sandbox, 'dir', 'file2.txt')).readAsString(), + expect(File(p.join(d.sandbox, 'dir', 'file2.txt')).readAsString(), completion(equals('contents2'))); expect( - new File(p.join(d.sandbox, 'dir', 'subdir', 'subfile1.txt')) + File(p.join(d.sandbox, 'dir', 'subdir', 'subfile1.txt')) .readAsString(), completion(equals('subcontents1'))); expect( - new File(p.join(d.sandbox, 'dir', 'subdir', 'subfile2.txt')) + File(p.join(d.sandbox, 'dir', 'subdir', 'subfile2.txt')) .readAsString(), completion(equals('subcontents2'))); }); @@ -46,7 +46,7 @@ void main() { await d.dir('dir').create(); await d.dir('dir', [d.file('name.txt', 'contents')]).create(); - expect(new File(p.join(d.sandbox, 'dir', 'name.txt')).readAsString(), + expect(File(p.join(d.sandbox, 'dir', 'name.txt')).readAsString(), completion(equals('contents'))); }); }); @@ -56,12 +56,12 @@ void main() { () async { var dirPath = p.join(d.sandbox, 'dir'); var subdirPath = p.join(dirPath, 'subdir'); - await new Directory(subdirPath).create(recursive: true); - await new File(p.join(dirPath, 'file1.txt')).writeAsString('contents1'); - await new File(p.join(dirPath, 'file2.txt')).writeAsString('contents2'); - await new File(p.join(subdirPath, 'subfile1.txt')) + await Directory(subdirPath).create(recursive: true); + await File(p.join(dirPath, 'file1.txt')).writeAsString('contents1'); + await File(p.join(dirPath, 'file2.txt')).writeAsString('contents2'); + await File(p.join(subdirPath, 'subfile1.txt')) .writeAsString('subcontents1'); - await new File(p.join(subdirPath, 'subfile2.txt')) + await File(p.join(subdirPath, 'subfile2.txt')) .writeAsString('subcontents2'); await d.dir('dir', [ @@ -76,9 +76,9 @@ void main() { test("fails if the directory doesn't exist", () async { var dirPath = p.join(d.sandbox, 'dir'); - await new Directory(dirPath).create(); - await new File(p.join(dirPath, 'file1.txt')).writeAsString('contents1'); - await new File(p.join(dirPath, 'file2.txt')).writeAsString('contents2'); + await Directory(dirPath).create(); + await File(p.join(dirPath, 'file1.txt')).writeAsString('contents1'); + await File(p.join(dirPath, 'file2.txt')).writeAsString('contents2'); expect( d.dir('dir', [ @@ -96,13 +96,13 @@ void main() { test("emits an error for each child that fails to validate", () async { var dirPath = p.join(d.sandbox, 'dir'); var subdirPath = p.join(dirPath, 'subdir'); - await new Directory(subdirPath).create(recursive: true); - await new File(p.join(dirPath, 'file1.txt')).writeAsString('contents1'); - await new File(p.join(subdirPath, 'subfile2.txt')) + await Directory(subdirPath).create(recursive: true); + await File(p.join(dirPath, 'file1.txt')).writeAsString('contents1'); + await File(p.join(subdirPath, 'subfile2.txt')) .writeAsString('subwrongtents2'); var errors = 0; - var controller = new StreamController(); + var controller = StreamController(); runZoned(() { d.dir('dir', [ d.dir('subdir', [ @@ -272,8 +272,8 @@ void main() { ]); await dir.create(); - var descriptor = new d.DirectoryDescriptor.fromFilesystem( - "dir", p.join(d.sandbox, 'dir')); + var descriptor = + d.DirectoryDescriptor.fromFilesystem("dir", p.join(d.sandbox, 'dir')); await descriptor.create(p.join(d.sandbox, 'dir2')); await dir.validate(p.join(d.sandbox, 'dir2')); }); @@ -288,7 +288,7 @@ void main() { d.file('.DS_Store', 'contents2') ]).create(); - var descriptor = new d.DirectoryDescriptor.fromFilesystem( + var descriptor = d.DirectoryDescriptor.fromFilesystem( "dir2", p.join(d.sandbox, 'dir')); await descriptor.create(); diff --git a/pkgs/test_descriptor/test/file_test.dart b/pkgs/test_descriptor/test/file_test.dart index cbc670acd..a1e803b06 100644 --- a/pkgs/test_descriptor/test/file_test.dart +++ b/pkgs/test_descriptor/test/file_test.dart @@ -2,14 +2,12 @@ // 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:convert'; @TestOn('vm') - import 'dart:io'; -import 'dart:convert'; import 'package:path/path.dart' as p; import 'package:test/test.dart'; - import 'package:test_descriptor/test_descriptor.dart' as d; import 'utils.dart'; @@ -19,14 +17,14 @@ void main() { test('creates a text file', () async { await d.file('name.txt', 'contents').create(); - expect(new File(p.join(d.sandbox, 'name.txt')).readAsString(), + expect(File(p.join(d.sandbox, 'name.txt')).readAsString(), completion(equals('contents'))); }); test('creates a binary file', () async { await d.file('name.txt', [0, 1, 2, 3]).create(); - expect(new File(p.join(d.sandbox, 'name.txt')).readAsBytes(), + expect(File(p.join(d.sandbox, 'name.txt')).readAsBytes(), completion(equals([0, 1, 2, 3]))); }); @@ -39,47 +37,46 @@ void main() { await d.file('name.txt', 'contents1').create(); await d.file('name.txt', 'contents2').create(); - expect(new File(p.join(d.sandbox, 'name.txt')).readAsString(), + expect(File(p.join(d.sandbox, 'name.txt')).readAsString(), completion(equals('contents2'))); }); }); group("validate()", () { test('succeeds if the filesystem matches a text descriptor', () async { - await new File(p.join(d.sandbox, 'name.txt')).writeAsString('contents'); + await File(p.join(d.sandbox, 'name.txt')).writeAsString('contents'); await d.file('name.txt', 'contents').validate(); }); test('succeeds if the filesystem matches a binary descriptor', () async { - await new File(p.join(d.sandbox, 'name.txt')).writeAsBytes([0, 1, 2, 3]); + await File(p.join(d.sandbox, 'name.txt')).writeAsBytes([0, 1, 2, 3]); await d.file('name.txt', [0, 1, 2, 3]).validate(); }); test('succeeds if the filesystem matches a text matcher', () async { - await new File(p.join(d.sandbox, 'name.txt')).writeAsString('contents'); + await File(p.join(d.sandbox, 'name.txt')).writeAsString('contents'); await d.file('name.txt', contains('ent')).validate(); }); test('succeeds if the filesystem matches a binary matcher', () async { - await new File(p.join(d.sandbox, 'name.txt')).writeAsBytes([0, 1, 2, 3]); - await new d.FileDescriptor.binaryMatcher('name.txt', contains(2)) - .validate(); + await File(p.join(d.sandbox, 'name.txt')).writeAsBytes([0, 1, 2, 3]); + await d.FileDescriptor.binaryMatcher('name.txt', contains(2)).validate(); }); test('succeeds if invalid UTF-8 matches a text matcher', () async { - await new File(p.join(d.sandbox, 'name.txt')).writeAsBytes([0xC3, 0x28]); + await File(p.join(d.sandbox, 'name.txt')).writeAsBytes([0xC3, 0x28]); await d.file('name.txt', isNot(isEmpty)).validate(); }); test("fails if the text contents don't match", () async { - await new File(p.join(d.sandbox, 'name.txt')).writeAsString('wrong'); + await File(p.join(d.sandbox, 'name.txt')).writeAsString('wrong'); expect(d.file('name.txt', 'contents').validate(), throwsA(toString(startsWith('File "name.txt" should contain:')))); }); test("fails if the binary contents don't match", () async { - await new File(p.join(d.sandbox, 'name.txt')).writeAsBytes([5, 4, 3, 2]); + await File(p.join(d.sandbox, 'name.txt')).writeAsBytes([5, 4, 3, 2]); expect( d.file('name.txt', [0, 1, 2, 3]).validate(), @@ -88,7 +85,7 @@ void main() { }); test("fails if the text contents don't match the matcher", () async { - await new File(p.join(d.sandbox, 'name.txt')).writeAsString('wrong'); + await File(p.join(d.sandbox, 'name.txt')).writeAsString('wrong'); expect( d.file('name.txt', contains('ent')).validate(), @@ -97,17 +94,16 @@ void main() { }); test("fails if the binary contents don't match the matcher", () async { - await new File(p.join(d.sandbox, 'name.txt')).writeAsBytes([5, 4, 3, 2]); + await File(p.join(d.sandbox, 'name.txt')).writeAsBytes([5, 4, 3, 2]); expect( - new d.FileDescriptor.binaryMatcher('name.txt', contains(1)) - .validate(), + d.FileDescriptor.binaryMatcher('name.txt', contains(1)).validate(), throwsA( toString(startsWith('Invalid contents for file "name.txt":')))); }); test("fails if invalid UTF-8 doesn't match a text matcher", () async { - await new File(p.join(d.sandbox, 'name.txt')).writeAsBytes([0xC3, 0x28]); + await File(p.join(d.sandbox, 'name.txt')).writeAsBytes([0xC3, 0x28]); expect( d.file('name.txt', isEmpty).validate(), throwsA(toString(allOf([ diff --git a/pkgs/test_descriptor/test/nothing_test.dart b/pkgs/test_descriptor/test/nothing_test.dart index d2935d062..d1172605f 100644 --- a/pkgs/test_descriptor/test/nothing_test.dart +++ b/pkgs/test_descriptor/test/nothing_test.dart @@ -16,9 +16,8 @@ import 'utils.dart'; void main() { test("create() does nothing", () async { await d.nothing('foo').create(); - expect(new File(p.join(d.sandbox, 'foo')).exists(), completion(isFalse)); - expect( - new Directory(p.join(d.sandbox, 'foo')).exists(), completion(isFalse)); + expect(File(p.join(d.sandbox, 'foo')).exists(), completion(isFalse)); + expect(Directory(p.join(d.sandbox, 'foo')).exists(), completion(isFalse)); }); group("validate()", () { @@ -43,7 +42,7 @@ void main() { }); test("fails if there's a broken link", () async { - await new Link(p.join(d.sandbox, 'link')).create('nonexistent'); + await Link(p.join(d.sandbox, 'link')).create('nonexistent'); expect( d.nothing('link').validate(), throwsA(toString(equals( diff --git a/pkgs/test_descriptor/test/pattern_test.dart b/pkgs/test_descriptor/test/pattern_test.dart index fb9b5bb8e..d337b1fd4 100644 --- a/pkgs/test_descriptor/test/pattern_test.dart +++ b/pkgs/test_descriptor/test/pattern_test.dart @@ -15,14 +15,14 @@ void main() { test("succeeds if there's a file matching the pattern and the child", () async { await d.file('foo', 'blap').create(); - await d.filePattern(new RegExp(r'f..'), 'blap').validate(); + await d.filePattern(RegExp(r'f..'), 'blap').validate(); }); test("succeeds if there's a directory matching the pattern and the child", () async { await d.dir('foo', [d.file('bar', 'baz')]).create(); - await d.dirPattern(new RegExp(r'f..'), [d.file('bar', 'baz')]).validate(); + await d.dirPattern(RegExp(r'f..'), [d.file('bar', 'baz')]).validate(); }); test( @@ -32,12 +32,12 @@ void main() { await d.file('fee', 'blak').create(); await d.file('faa', 'blut').create(); - await d.filePattern(new RegExp(r'f..'), 'blap').validate(); + await d.filePattern(RegExp(r'f..'), 'blap').validate(); }); test("fails if there's no file matching the pattern", () { expect( - d.filePattern(new RegExp(r'f..'), 'bar').validate(), + d.filePattern(RegExp(r'f..'), 'bar').validate(), throwsA( toString(equals('No entries found in sandbox matching /f../.')))); }); @@ -45,7 +45,7 @@ void main() { test("fails if there's a file matching the pattern but not the entry", () async { await d.file('foo', 'bap').create(); - expect(d.filePattern(new RegExp(r'f..'), 'bar').validate(), + expect(d.filePattern(RegExp(r'f..'), 'bar').validate(), throwsA(toString(startsWith('File "foo" should contain:')))); }); @@ -53,8 +53,7 @@ void main() { () async { await d.dir('foo', [d.file('bar', 'bap')]).create(); - expect( - d.dirPattern(new RegExp(r'f..'), [d.file('bar', 'baz')]).validate(), + expect(d.dirPattern(RegExp(r'f..'), [d.file('bar', 'baz')]).validate(), throwsA(toString(startsWith('File "foo/bar" should contain:')))); }); @@ -65,7 +64,7 @@ void main() { await d.file('fee', 'bar').create(); await d.file('faa', 'bar').create(); expect( - d.filePattern(new RegExp(r'f..'), 'bar').validate(), + d.filePattern(RegExp(r'f..'), 'bar').validate(), throwsA(toString(startsWith( "Multiple valid entries found in sandbox matching /f../:")))); }); diff --git a/pkgs/test_descriptor/test/sandbox_test.dart b/pkgs/test_descriptor/test/sandbox_test.dart index be4a95949..c34c5c63b 100644 --- a/pkgs/test_descriptor/test/sandbox_test.dart +++ b/pkgs/test_descriptor/test/sandbox_test.dart @@ -13,13 +13,13 @@ import 'package:test_descriptor/test_descriptor.dart' as d; void main() { test("accessing the getter creates the directory", () { - expect(new Directory(d.sandbox).existsSync(), isTrue); + expect(Directory(d.sandbox).existsSync(), isTrue); }); test("the directory is deleted after the test", () { String sandbox; addTearDown(() { - expect(new Directory(sandbox).existsSync(), isFalse); + expect(Directory(sandbox).existsSync(), isFalse); }); sandbox = d.sandbox; From 139dfc9ad6257bd64facb3892c6c0d4e2010a724 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Thu, 23 May 2019 11:35:12 -0700 Subject: [PATCH 15/72] Fix missing_return violation newly enforced in Dart ~2.3.2-dev.0.1 (dart-lang/test_descriptor#20) --- pkgs/test_descriptor/lib/src/directory_descriptor.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/test_descriptor/lib/src/directory_descriptor.dart b/pkgs/test_descriptor/lib/src/directory_descriptor.dart index 4674a107e..d6ba56a81 100644 --- a/pkgs/test_descriptor/lib/src/directory_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/directory_descriptor.dart @@ -52,6 +52,7 @@ class DirectoryDescriptor extends Descriptor { p.basename(entity.path), entity.readAsBytesSync()); } // Ignore broken symlinks. + return null; }).where((path) => path != null)); } From bf11985ca6fde8939cc2ef7ea1da74421d65b6aa Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Wed, 12 Jun 2019 01:48:45 +0100 Subject: [PATCH 16/72] Add an archive descriptor (dart-lang/test_descriptor#21) --- pkgs/test_descriptor/.travis.yml | 4 +- pkgs/test_descriptor/CHANGELOG.md | 5 + .../lib/src/archive_descriptor.dart | 180 +++++++++++ .../lib/src/directory_descriptor.dart | 21 +- pkgs/test_descriptor/lib/src/utils.dart | 24 +- pkgs/test_descriptor/lib/test_descriptor.dart | 15 + pkgs/test_descriptor/pubspec.yaml | 8 +- pkgs/test_descriptor/test/archive_test.dart | 281 ++++++++++++++++++ 8 files changed, 512 insertions(+), 26 deletions(-) create mode 100644 pkgs/test_descriptor/lib/src/archive_descriptor.dart create mode 100644 pkgs/test_descriptor/test/archive_test.dart diff --git a/pkgs/test_descriptor/.travis.yml b/pkgs/test_descriptor/.travis.yml index 415bad401..48803a1c0 100644 --- a/pkgs/test_descriptor/.travis.yml +++ b/pkgs/test_descriptor/.travis.yml @@ -2,7 +2,7 @@ language: dart dart: - dev - - 2.0.0 + - stable dart_task: - test @@ -14,7 +14,7 @@ matrix: - dart: dev dart_task: dartanalyzer: --fatal-infos --fatal-warnings . - - dart: 2.0.0 + - dart: stable dart_task: dartanalyzer: --fatal-warnings . diff --git a/pkgs/test_descriptor/CHANGELOG.md b/pkgs/test_descriptor/CHANGELOG.md index 46908ef16..a3b352908 100644 --- a/pkgs/test_descriptor/CHANGELOG.md +++ b/pkgs/test_descriptor/CHANGELOG.md @@ -1,3 +1,8 @@ +## 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. diff --git a/pkgs/test_descriptor/lib/src/archive_descriptor.dart b/pkgs/test_descriptor/lib/src/archive_descriptor.dart new file mode 100644 index 000000000..564958da3 --- /dev/null +++ b/pkgs/test_descriptor/lib/src/archive_descriptor.dart @@ -0,0 +1,180 @@ +// Copyright (c) 2019, 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:async'; +import 'dart:io'; + +import 'package:archive/archive.dart'; +import 'package:async/async.dart'; +import 'package:meta/meta.dart'; +import 'package:path/path.dart' as p; +import 'package:test/test.dart'; + +import 'descriptor.dart'; +import 'directory_descriptor.dart'; +import 'file_descriptor.dart'; +import 'sandbox.dart'; +import 'utils.dart'; + +/// A [Descriptor] describing files in a Tar or Zip archive. +/// +/// The format is determined by the descriptor's file extension. +@sealed +class ArchiveDescriptor extends Descriptor implements FileDescriptor { + /// Descriptors for entries in this archive. + final List contents; + + /// Returns a `package:archive` [Archive] object that contains the contents of + /// this file. + Future get archive async { + var archive = Archive(); + (await _files(contents)).forEach(archive.addFile); + return archive; + } + + File get io => File(p.join(sandbox, name)); + + /// Returns [ArchiveFile]s for each file in [descriptors]. + /// + /// If [parent] is passed, it's used as the parent directory for filenames. + Future> _files(Iterable descriptors, + [String parent]) async { + return (await waitAndReportErrors(descriptors.map((descriptor) async { + var fullName = + parent == null ? descriptor.name : "$parent/${descriptor.name}"; + + if (descriptor is FileDescriptor) { + var bytes = await collectBytes(descriptor.readAsBytes()); + return [ + ArchiveFile(fullName, bytes.length, bytes) + // Setting the mode and mod time are necessary to work around + // brendan-duncan/archive#76. + ..mode = 428 + ..lastModTime = DateTime.now().millisecondsSinceEpoch ~/ 1000 + ]; + } else if (descriptor is DirectoryDescriptor) { + return await _files(descriptor.contents, fullName); + } else { + throw UnsupportedError( + "An archive can only be created from FileDescriptors and " + "DirectoryDescriptors."); + } + }))) + .expand((files) => files); + } + + ArchiveDescriptor(String name, Iterable contents) + : contents = List.unmodifiable(contents), + super(name); + + Future create([String parent]) async { + var path = p.join(parent ?? sandbox, name); + var file = File(path).openWrite(); + try { + try { + await readAsBytes().listen(file.add).asFuture(); + } finally { + await file.close(); + } + } catch (_) { + await File(path).delete(); + rethrow; + } + } + + Future read() async => throw UnsupportedError( + "ArchiveDescriptor.read() is not supported. Use Archive.readAsBytes() " + "instead."); + + Stream> readAsBytes() => Stream.fromFuture(() async { + return _encodeFunction()(await archive); + }()); + + Future validate([String parent]) async { + // Access this first so we eaerly throw an error for a path with an invalid + // extension. + var decoder = _decodeFunction(); + + var fullPath = p.join(parent ?? sandbox, name); + var pretty = prettyPath(fullPath); + if (!(await File(fullPath).exists())) { + fail('File not found: "$pretty".'); + } + + var bytes = await File(fullPath).readAsBytes(); + Archive archive; + try { + archive = decoder(bytes); + } catch (_) { + // Catch every error to work around brendan-duncan/archive#77. + fail('File "$pretty" is not a valid archive.'); + } + + // Because validators expect to validate against a real filesystem, we have + // to extract the archive to a temp directory and run validation on that. + var tempDir = await Directory.systemTemp + .createTempSync('dart_test_') + .resolveSymbolicLinks(); + + try { + await waitAndReportErrors(archive.files.map((file) async { + var path = p.join(tempDir, file.name); + await Directory(p.dirname(path)).create(recursive: true); + await File(path).writeAsBytes(file.content as List); + })); + + await waitAndReportErrors(contents.map((entry) async { + try { + await entry.validate(tempDir); + } on TestFailure catch (error) { + // Replace the temporary directory with the path to the archive to + // make the error more user-friendly. + fail(error.message.replaceAll(tempDir, pretty)); + } + })); + } finally { + await Directory(tempDir).delete(recursive: true); + } + } + + /// Returns the function to use to encode this file to binary, based on its + /// [name]. + List Function(Archive) _encodeFunction() { + if (name.endsWith(".zip")) { + return ZipEncoder().encode; + } else if (name.endsWith(".tar")) { + return TarEncoder().encode; + } else if (name.endsWith(".tar.gz") || + name.endsWith(".tar.gzip") || + name.endsWith(".tgz")) { + return (archive) => GZipEncoder().encode(TarEncoder().encode(archive)); + } else if (name.endsWith(".tar.bz2") || name.endsWith(".tar.bzip2")) { + return (archive) => BZip2Encoder().encode(TarEncoder().encode(archive)); + } else { + throw UnsupportedError("Unknown file format $name."); + } + } + + /// Returns the function to use to decode this file from binary, based on its + /// [name]. + Archive Function(List) _decodeFunction() { + if (name.endsWith(".zip")) { + return ZipDecoder().decodeBytes; + } else if (name.endsWith(".tar")) { + return TarDecoder().decodeBytes; + } else if (name.endsWith(".tar.gz") || + name.endsWith(".tar.gzip") || + name.endsWith(".tgz")) { + return (archive) => + TarDecoder().decodeBytes(GZipDecoder().decodeBytes(archive)); + } else if (name.endsWith(".tar.bz2") || name.endsWith(".tar.bzip2")) { + return (archive) => + TarDecoder().decodeBytes(BZip2Decoder().decodeBytes(archive)); + } else { + throw UnsupportedError("Unknown file format $name."); + } + } + + String describe() => describeDirectory(name, contents); +} diff --git a/pkgs/test_descriptor/lib/src/directory_descriptor.dart b/pkgs/test_descriptor/lib/src/directory_descriptor.dart index d6ba56a81..c505885e4 100644 --- a/pkgs/test_descriptor/lib/src/directory_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/directory_descriptor.dart @@ -7,7 +7,6 @@ import 'dart:io'; import 'package:async/async.dart'; import 'package:path/path.dart' as p; -import 'package:term_glyph/term_glyph.dart' as glyph; import 'package:test/test.dart'; import 'descriptor.dart'; @@ -122,23 +121,5 @@ class DirectoryDescriptor extends Descriptor { })); } - String describe() { - if (contents.isEmpty) return name; - - var buffer = StringBuffer(); - buffer.writeln(name); - for (var entry in contents.take(contents.length - 1)) { - var entryString = - prefixLines(entry.describe(), '${glyph.verticalLine} ', - first: '${glyph.teeRight}${glyph.horizontalLine}' - '${glyph.horizontalLine} '); - buffer.writeln(entryString); - } - - var lastEntryString = prefixLines(contents.last.describe(), ' ', - first: '${glyph.bottomLeftCorner}${glyph.horizontalLine}' - '${glyph.horizontalLine} '); - buffer.write(lastEntryString); - return buffer.toString(); - } + String describe() => describeDirectory(name, contents); } diff --git a/pkgs/test_descriptor/lib/src/utils.dart b/pkgs/test_descriptor/lib/src/utils.dart index 9a14b7000..5dad79479 100644 --- a/pkgs/test_descriptor/lib/src/utils.dart +++ b/pkgs/test_descriptor/lib/src/utils.dart @@ -9,6 +9,7 @@ import 'package:path/path.dart' as p; import 'package:term_glyph/term_glyph.dart' as glyph; import 'package:test/test.dart'; +import 'descriptor.dart'; import 'sandbox.dart'; /// A UTF-8 codec that allows malformed byte sequences. @@ -25,6 +26,27 @@ String addBullet(String text) => /// Converts [strings] to a bulleted list. String bullet(Iterable strings) => strings.map(addBullet).join("\n"); +/// Returns a human-readable description of a directory with the given [name] +/// and [contents]. +String describeDirectory(String name, List contents) { + if (contents.isEmpty) return name; + + var buffer = StringBuffer(); + buffer.writeln(name); + for (var entry in contents.take(contents.length - 1)) { + var entryString = prefixLines(entry.describe(), '${glyph.verticalLine} ', + first: '${glyph.teeRight}${glyph.horizontalLine}' + '${glyph.horizontalLine} '); + buffer.writeln(entryString); + } + + var lastEntryString = prefixLines(contents.last.describe(), ' ', + first: '${glyph.bottomLeftCorner}${glyph.horizontalLine}' + '${glyph.horizontalLine} '); + buffer.write(lastEntryString); + return buffer.toString(); +} + /// Prepends each line in [text] with [prefix]. /// /// If [first] or [last] is passed, the first and last lines, respectively, are @@ -67,7 +89,7 @@ bool matchesAll(Pattern pattern, String string) => /// Like [Future.wait] with `eagerError: true`, but reports errors after the /// first using [registerException] rather than silently ignoring them. -Future waitAndReportErrors(Iterable futures) { +Future> waitAndReportErrors(Iterable> futures) { var errored = false; return Future.wait(futures.map((future) { // Avoid async/await so that we synchronously add error handlers for the diff --git a/pkgs/test_descriptor/lib/test_descriptor.dart b/pkgs/test_descriptor/lib/test_descriptor.dart index cc3371425..ea576454a 100644 --- a/pkgs/test_descriptor/lib/test_descriptor.dart +++ b/pkgs/test_descriptor/lib/test_descriptor.dart @@ -5,6 +5,7 @@ import 'package:path/path.dart' as p; import 'package:test/test.dart'; +import 'src/archive_descriptor.dart'; import 'src/descriptor.dart'; import 'src/directory_descriptor.dart'; import 'src/file_descriptor.dart'; @@ -12,6 +13,7 @@ import 'src/nothing_descriptor.dart'; import 'src/pattern_descriptor.dart'; import 'src/sandbox.dart'; +export 'src/archive_descriptor.dart'; export 'src/descriptor.dart'; export 'src/directory_descriptor.dart'; export 'src/file_descriptor.dart'; @@ -72,5 +74,18 @@ PatternDescriptor filePattern(Pattern name, [contents]) => PatternDescriptor dirPattern(Pattern name, [Iterable contents]) => pattern(name, (realName) => dir(realName, contents)); +/// Creates a new [ArchiveDescriptor] with [name] and [contents]. +/// +/// [Descriptor.create] creates an archive with the given files and directories +/// within it, and [Descriptor.validate] validates that the archive contains the +/// given contents. It *doesn't* require that no other children exist. To ensure +/// that a particular child doesn't exist, use [nothing]. +/// +/// The type of the archive is determined by [name]'s file extension. It +/// supports `.zip`, `.tar`, `.tar.gz`/`.tar.gzip`/`.tgz`, and +/// `.tar.bz2`/`.tar.bzip2` files. +ArchiveDescriptor archive(String name, [Iterable contents]) => + ArchiveDescriptor(name, contents ?? []); + /// Returns [path] within the [sandbox] directory. String path(String path) => p.join(sandbox, path); diff --git a/pkgs/test_descriptor/pubspec.yaml b/pkgs/test_descriptor/pubspec.yaml index d39384e23..b50a18b91 100644 --- a/pkgs/test_descriptor/pubspec.yaml +++ b/pkgs/test_descriptor/pubspec.yaml @@ -1,5 +1,5 @@ name: test_descriptor -version: 1.1.1 +version: 1.2.0 description: An API for defining and verifying directory structures. author: Dart Team homepage: https://github.com/dart-lang/test_descriptor @@ -8,12 +8,14 @@ environment: sdk: '>=2.0.0 <3.0.0' dependencies: - async: '>=1.10.0 <3.0.0' + archive: '^2.0.0' + async: '>=1.13.0 <3.0.0' collection: '^1.5.0' matcher: '^0.12.0' + meta: '^1.1.7' path: '^1.0.0' stack_trace: '^1.0.0' - test: '>=0.12.19 <2.0.0' + test: '^1.6.0' term_glyph: '^1.0.0' dev_dependencies: diff --git a/pkgs/test_descriptor/test/archive_test.dart b/pkgs/test_descriptor/test/archive_test.dart new file mode 100644 index 000000000..a413fb96d --- /dev/null +++ b/pkgs/test_descriptor/test/archive_test.dart @@ -0,0 +1,281 @@ +// Copyright (c) 2019, 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. + +@TestOn('vm') + +import 'dart:convert'; +import 'dart:io'; + +import 'package:archive/archive.dart'; +import 'package:async/async.dart'; +import 'package:path/path.dart' as p; +import 'package:test/test.dart'; +import 'package:test_descriptor/test_descriptor.dart' as d; + +import 'utils.dart'; + +void main() { + group("create()", () { + test("creates an empty archive", () async { + await d.archive("test.tar").create(); + + var archive = + TarDecoder().decodeBytes(File(d.path("test.tar")).readAsBytesSync()); + expect(archive.files, isEmpty); + }); + + test("creates an archive with files", () async { + await d.archive("test.tar", [ + d.file("file1.txt", "contents 1"), + d.file("file2.txt", "contents 2") + ]).create(); + + var files = TarDecoder() + .decodeBytes(File(d.path("test.tar")).readAsBytesSync()) + .files; + expect(files.length, equals(2)); + _expectFile(files[0], "file1.txt", "contents 1"); + _expectFile(files[1], "file2.txt", "contents 2"); + }); + + test("creates an archive with files in a directory", () async { + await d.archive("test.tar", [ + d.dir("dir", [ + d.file("file1.txt", "contents 1"), + d.file("file2.txt", "contents 2") + ]) + ]).create(); + + var files = TarDecoder() + .decodeBytes(File(d.path("test.tar")).readAsBytesSync()) + .files; + expect(files.length, equals(2)); + _expectFile(files[0], "dir/file1.txt", "contents 1"); + _expectFile(files[1], "dir/file2.txt", "contents 2"); + }); + + test("creates an archive with files in a nested directory", () async { + await d.archive("test.tar", [ + d.dir("dir", [ + d.dir("subdir", [ + d.file("file1.txt", "contents 1"), + d.file("file2.txt", "contents 2") + ]) + ]) + ]).create(); + + var files = TarDecoder() + .decodeBytes(File(d.path("test.tar")).readAsBytesSync()) + .files; + expect(files.length, equals(2)); + _expectFile(files[0], "dir/subdir/file1.txt", "contents 1"); + _expectFile(files[1], "dir/subdir/file2.txt", "contents 2"); + }); + + group("creates a file in", () { + test("zip format", () async { + await d.archive("test.zip", [d.file("file.txt", "contents")]).create(); + + var archive = ZipDecoder() + .decodeBytes(File(d.path("test.zip")).readAsBytesSync()); + _expectFile(archive.files.single, "file.txt", "contents"); + }); + + group("gzip tar format", () { + for (var extension in [".tar.gz", ".tar.gzip", ".tgz"]) { + test("with $extension", () async { + await d.archive( + "test$extension", [d.file("file.txt", "contents")]).create(); + + var archive = TarDecoder().decodeBytes(GZipDecoder() + .decodeBytes(File(d.path("test$extension")).readAsBytesSync())); + _expectFile(archive.files.single, "file.txt", "contents"); + }); + } + }); + + group("bzip2 tar format", () { + for (var extension in [".tar.bz2", ".tar.bzip2"]) { + test("with $extension", () async { + await d.archive( + "test$extension", [d.file("file.txt", "contents")]).create(); + + var archive = TarDecoder().decodeBytes(BZip2Decoder() + .decodeBytes(File(d.path("test$extension")).readAsBytesSync())); + _expectFile(archive.files.single, "file.txt", "contents"); + }); + } + }); + }); + + group("gracefully rejects", () { + test("an uncreatable descriptor", () async { + await expectLater( + d.archive("test.tar", [d.filePattern(RegExp(r"^foo-"))]).create(), + throwsUnsupportedError); + await d.nothing("test.tar").validate(); + }); + + test("a non-file non-directory descriptor", () async { + await expectLater( + d.archive("test.tar", [d.nothing("file.txt")]).create(), + throwsUnsupportedError); + await d.nothing("test.tar").validate(); + }); + + test("an unknown file extension", () async { + await expectLater( + d.archive("test.asdf", [d.nothing("file.txt")]).create(), + throwsUnsupportedError); + }); + }); + }); + + group("validate()", () { + group("with an empty archive", () { + test("succeeds if an empty archive exists", () async { + File(d.path("test.tar")) + .writeAsBytesSync(TarEncoder().encode(Archive())); + await d.archive("test.tar").validate(); + }); + + test("succeeds if a non-empty archive exists", () async { + File(d.path("test.tar")).writeAsBytesSync( + TarEncoder().encode(Archive()..addFile(_file("file.txt")))); + await d.archive("test.tar").validate(); + }); + + test("fails if no archive exists", () { + expect(d.archive("test.tar").validate(), + throwsA(toString(startsWith('File not found: "test.tar".')))); + }); + + test("fails if an invalid archive exists", () { + d.file("test.tar", "not a valid tar file").create(); + expect( + d.archive("test.tar").validate(), + throwsA(toString( + startsWith('File "test.tar" is not a valid archive.')))); + }); + }); + + test("succeeds if an archive contains a matching file", () async { + File(d.path("test.tar")).writeAsBytesSync(TarEncoder() + .encode(Archive()..addFile(_file("file.txt", "contents")))); + await d.archive("test.tar", [d.file("file.txt", "contents")]).validate(); + }); + + test("fails if an archive doesn't contain a file", () async { + File(d.path("test.tar")).writeAsBytesSync(TarEncoder().encode(Archive())); + expect( + d.archive("test.tar", [d.file("file.txt", "contents")]).validate(), + throwsA( + toString(startsWith('File not found: "test.tar/file.txt".')))); + }); + + test("fails if an archive contains a non-matching file", () async { + File(d.path("test.tar")).writeAsBytesSync(TarEncoder() + .encode(Archive()..addFile(_file("file.txt", "wrong contents")))); + expect( + d.archive("test.tar", [d.file("file.txt", "contents")]).validate(), + throwsA(toString( + startsWith('File "test.tar/file.txt" should contain:')))); + }); + + test("succeeds if an archive contains a file matching a pattern", () async { + File(d.path("test.tar")).writeAsBytesSync(TarEncoder() + .encode(Archive()..addFile(_file("file.txt", "contents")))); + await d.archive("test.tar", + [d.filePattern(RegExp(r"f..e\.txt"), "contents")]).validate(); + }); + + group("validates a file in", () { + test("zip format", () async { + File(d.path("test.zip")).writeAsBytesSync(ZipEncoder() + .encode(Archive()..addFile(_file("file.txt", "contents")))); + + await d + .archive("test.zip", [d.file("file.txt", "contents")]).validate(); + }); + + group("gzip tar format", () { + for (var extension in [".tar.gz", ".tar.gzip", ".tgz"]) { + test("with $extension", () async { + File(d.path("test$extension")).writeAsBytesSync(GZipEncoder() + .encode(TarEncoder().encode( + Archive()..addFile(_file("file.txt", "contents"))))); + + await d.archive( + "test$extension", [d.file("file.txt", "contents")]).validate(); + }); + } + }); + + group("bzip2 tar format", () { + for (var extension in [".tar.bz2", ".tar.bzip2"]) { + test("with $extension", () async { + File(d.path("test$extension")).writeAsBytesSync(BZip2Encoder() + .encode(TarEncoder().encode( + Archive()..addFile(_file("file.txt", "contents"))))); + + await d.archive( + "test$extension", [d.file("file.txt", "contents")]).validate(); + }); + } + }); + }); + + test("gracefully rejects an unknown file format", () { + expect(d.archive("test.asdf").validate(), throwsUnsupportedError); + }); + }); + + test("read() is unsupported", () { + expect(d.archive("test.tar").read(), throwsUnsupportedError); + }); + + test("readAsBytes() returns the contents of the archive", () async { + var descriptor = d.archive("test.tar", + [d.file("file1.txt", "contents 1"), d.file("file2.txt", "contents 2")]); + + var files = TarDecoder() + .decodeBytes(await collectBytes(descriptor.readAsBytes())) + .files; + expect(files.length, equals(2)); + _expectFile(files[0], "file1.txt", "contents 1"); + _expectFile(files[1], "file2.txt", "contents 2"); + }); + + test("archive returns the in-memory contents", () async { + var archive = await d.archive("test.tar", [ + d.file("file1.txt", "contents 1"), + d.file("file2.txt", "contents 2") + ]).archive; + + var files = archive.files; + expect(files.length, equals(2)); + _expectFile(files[0], "file1.txt", "contents 1"); + _expectFile(files[1], "file2.txt", "contents 2"); + }); + + test("io refers to the file within the sandbox", () { + expect(d.file('test.tar').io.path, equals(p.join(d.sandbox, 'test.tar'))); + }); +} + +/// Asserts that [file] has the given [name] and [contents]. +void _expectFile(ArchiveFile file, String name, String contents) { + expect(file.name, equals(name)); + expect(utf8.decode(file.content as List), equals(contents)); +} + +/// Creates an [ArchiveFile] with the given [name] and [contents]. +ArchiveFile _file(String name, [String contents]) { + var bytes = utf8.encode(contents ?? ""); + return ArchiveFile(name, bytes.length, bytes) + // Setting the mode and mod time are necessary to work around + // brendan-duncan/archive#76. + ..mode = 428 + ..lastModTime = DateTime.now().millisecondsSinceEpoch ~/ 1000; +} From 7237f10363c41e5e3fa3ace1eaed668753376d29 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 10 Sep 2019 12:20:41 -0700 Subject: [PATCH 17/72] Test on oldest supported Dart SDK (2.0.0) --- pkgs/test_descriptor/.travis.yml | 4 ++-- pkgs/test_descriptor/pubspec.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/test_descriptor/.travis.yml b/pkgs/test_descriptor/.travis.yml index 48803a1c0..3fa092b30 100644 --- a/pkgs/test_descriptor/.travis.yml +++ b/pkgs/test_descriptor/.travis.yml @@ -2,7 +2,7 @@ language: dart dart: - dev - - stable + - 2.1.0 dart_task: - test @@ -14,7 +14,7 @@ matrix: - dart: dev dart_task: dartanalyzer: --fatal-infos --fatal-warnings . - - dart: stable + - dart: 2.1.0 dart_task: dartanalyzer: --fatal-warnings . diff --git a/pkgs/test_descriptor/pubspec.yaml b/pkgs/test_descriptor/pubspec.yaml index b50a18b91..e268ab569 100644 --- a/pkgs/test_descriptor/pubspec.yaml +++ b/pkgs/test_descriptor/pubspec.yaml @@ -5,7 +5,7 @@ author: Dart Team homepage: https://github.com/dart-lang/test_descriptor environment: - sdk: '>=2.0.0 <3.0.0' + sdk: '>=2.1.0 <3.0.0' dependencies: archive: '^2.0.0' From 5defcba3448c5f4d4a089f19b066437ab6b978c8 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 10 Sep 2019 12:21:47 -0700 Subject: [PATCH 18/72] Fix URLs --- pkgs/test_descriptor/CHANGELOG.md | 4 ++++ pkgs/test_descriptor/README.md | 14 +++++++------- pkgs/test_descriptor/pubspec.yaml | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/pkgs/test_descriptor/CHANGELOG.md b/pkgs/test_descriptor/CHANGELOG.md index a3b352908..8fbc4b798 100644 --- a/pkgs/test_descriptor/CHANGELOG.md +++ b/pkgs/test_descriptor/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.2.1 + +* Fix outdated URLs in `README.md`. + ## 1.2.0 * Add an `ArchiveDescriptor` class and a corresponding `archive()` function that diff --git a/pkgs/test_descriptor/README.md b/pkgs/test_descriptor/README.md index 6adc5b7ef..d20100488 100644 --- a/pkgs/test_descriptor/README.md +++ b/pkgs/test_descriptor/README.md @@ -7,10 +7,10 @@ define a filesystem structure that can be created using [`Descriptor.create()`][create] and verified using [`Descriptor.validate()`][validate]. For example: -[dir]: https://www.dartdocs.org/documentation/test_descriptor/latest/test_descriptor/dir.html -[file]: https://www.dartdocs.org/documentation/test_descriptor/latest/test_descriptor/file.html -[create]: https://www.dartdocs.org/documentation/test_descriptor/latest/test_descriptor/Descriptor/create.html -[validate]: https://www.dartdocs.org/documentation/test_descriptor/latest/test_descriptor/Descriptor/validate.html +[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'; @@ -44,10 +44,10 @@ By default, descriptors create entries in a temporary sandbox directory, you create a descriptor in a given test, and automatically deleted once the test finishes running. -[sandbox]: https://www.dartdocs.org/documentation/test_descriptor/latest/test_descriptor/sandbox.html +[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.dartlang.org/packages/term_glyph -[ascii]: https://www.dartdocs.org/documentation/term_glyph/latest/term_glyph/ascii.html +[term_glyph]: https://pub.dev/packages/term_glyph +[ascii]: https://pub.dev/documentation/term_glyph/latest/term_glyph/ascii.html diff --git a/pkgs/test_descriptor/pubspec.yaml b/pkgs/test_descriptor/pubspec.yaml index e268ab569..31bef959c 100644 --- a/pkgs/test_descriptor/pubspec.yaml +++ b/pkgs/test_descriptor/pubspec.yaml @@ -1,5 +1,5 @@ name: test_descriptor -version: 1.2.0 +version: 1.2.1-dev description: An API for defining and verifying directory structures. author: Dart Team homepage: https://github.com/dart-lang/test_descriptor From 1959a778ee87a87d4b658022157619c09785e792 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Mon, 9 Dec 2019 15:53:32 -0800 Subject: [PATCH 19/72] Fix newly enforced package:pedantic lints (dart-lang/test_descriptor#23) - annotate_overrides - prefer_if_null_operators - prefer_single_quotes - use_function_type_syntax_for_parameters --- .../lib/src/archive_descriptor.dart | 44 ++-- .../lib/src/directory_descriptor.dart | 9 +- .../lib/src/file_descriptor.dart | 14 +- .../lib/src/nothing_descriptor.dart | 3 + .../lib/src/pattern_descriptor.dart | 9 +- pkgs/test_descriptor/lib/src/utils.dart | 16 +- pkgs/test_descriptor/lib/test_descriptor.dart | 5 +- pkgs/test_descriptor/test/archive_test.dart | 234 +++++++++--------- pkgs/test_descriptor/test/directory_test.dart | 60 ++--- pkgs/test_descriptor/test/file_test.dart | 20 +- pkgs/test_descriptor/test/nothing_test.dart | 4 +- pkgs/test_descriptor/test/pattern_test.dart | 12 +- pkgs/test_descriptor/test/sandbox_test.dart | 8 +- pkgs/test_descriptor/test/utils.dart | 2 +- 14 files changed, 233 insertions(+), 207 deletions(-) diff --git a/pkgs/test_descriptor/lib/src/archive_descriptor.dart b/pkgs/test_descriptor/lib/src/archive_descriptor.dart index 564958da3..7d96ce80a 100644 --- a/pkgs/test_descriptor/lib/src/archive_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/archive_descriptor.dart @@ -33,6 +33,7 @@ class ArchiveDescriptor extends Descriptor implements FileDescriptor { return archive; } + @override File get io => File(p.join(sandbox, name)); /// Returns [ArchiveFile]s for each file in [descriptors]. @@ -42,7 +43,7 @@ class ArchiveDescriptor extends Descriptor implements FileDescriptor { [String parent]) async { return (await waitAndReportErrors(descriptors.map((descriptor) async { var fullName = - parent == null ? descriptor.name : "$parent/${descriptor.name}"; + parent == null ? descriptor.name : '$parent/${descriptor.name}'; if (descriptor is FileDescriptor) { var bytes = await collectBytes(descriptor.readAsBytes()); @@ -57,8 +58,8 @@ class ArchiveDescriptor extends Descriptor implements FileDescriptor { return await _files(descriptor.contents, fullName); } else { throw UnsupportedError( - "An archive can only be created from FileDescriptors and " - "DirectoryDescriptors."); + 'An archive can only be created from FileDescriptors and ' + 'DirectoryDescriptors.'); } }))) .expand((files) => files); @@ -68,6 +69,7 @@ class ArchiveDescriptor extends Descriptor implements FileDescriptor { : contents = List.unmodifiable(contents), super(name); + @override Future create([String parent]) async { var path = p.join(parent ?? sandbox, name); var file = File(path).openWrite(); @@ -83,14 +85,17 @@ class ArchiveDescriptor extends Descriptor implements FileDescriptor { } } + @override Future read() async => throw UnsupportedError( - "ArchiveDescriptor.read() is not supported. Use Archive.readAsBytes() " - "instead."); + 'ArchiveDescriptor.read() is not supported. Use Archive.readAsBytes() ' + 'instead.'); + @override Stream> readAsBytes() => Stream.fromFuture(() async { return _encodeFunction()(await archive); }()); + @override Future validate([String parent]) async { // Access this first so we eaerly throw an error for a path with an invalid // extension. @@ -141,40 +146,41 @@ class ArchiveDescriptor extends Descriptor implements FileDescriptor { /// Returns the function to use to encode this file to binary, based on its /// [name]. List Function(Archive) _encodeFunction() { - if (name.endsWith(".zip")) { + if (name.endsWith('.zip')) { return ZipEncoder().encode; - } else if (name.endsWith(".tar")) { + } else if (name.endsWith('.tar')) { return TarEncoder().encode; - } else if (name.endsWith(".tar.gz") || - name.endsWith(".tar.gzip") || - name.endsWith(".tgz")) { + } else if (name.endsWith('.tar.gz') || + name.endsWith('.tar.gzip') || + name.endsWith('.tgz')) { return (archive) => GZipEncoder().encode(TarEncoder().encode(archive)); - } else if (name.endsWith(".tar.bz2") || name.endsWith(".tar.bzip2")) { + } else if (name.endsWith('.tar.bz2') || name.endsWith('.tar.bzip2')) { return (archive) => BZip2Encoder().encode(TarEncoder().encode(archive)); } else { - throw UnsupportedError("Unknown file format $name."); + throw UnsupportedError('Unknown file format $name.'); } } /// Returns the function to use to decode this file from binary, based on its /// [name]. Archive Function(List) _decodeFunction() { - if (name.endsWith(".zip")) { + if (name.endsWith('.zip')) { return ZipDecoder().decodeBytes; - } else if (name.endsWith(".tar")) { + } else if (name.endsWith('.tar')) { return TarDecoder().decodeBytes; - } else if (name.endsWith(".tar.gz") || - name.endsWith(".tar.gzip") || - name.endsWith(".tgz")) { + } else if (name.endsWith('.tar.gz') || + name.endsWith('.tar.gzip') || + name.endsWith('.tgz')) { return (archive) => TarDecoder().decodeBytes(GZipDecoder().decodeBytes(archive)); - } else if (name.endsWith(".tar.bz2") || name.endsWith(".tar.bzip2")) { + } else if (name.endsWith('.tar.bz2') || name.endsWith('.tar.bzip2')) { return (archive) => TarDecoder().decodeBytes(BZip2Decoder().decodeBytes(archive)); } else { - throw UnsupportedError("Unknown file format $name."); + throw UnsupportedError('Unknown file format $name.'); } } + @override String describe() => describeDirectory(name, contents); } diff --git a/pkgs/test_descriptor/lib/src/directory_descriptor.dart b/pkgs/test_descriptor/lib/src/directory_descriptor.dart index c505885e4..1a8fe6501 100644 --- a/pkgs/test_descriptor/lib/src/directory_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/directory_descriptor.dart @@ -41,7 +41,7 @@ class DirectoryDescriptor extends Descriptor { name, Directory(path).listSync().map((entity) { // Ignore hidden files. - if (p.basename(entity.path).startsWith(".")) return null; + if (p.basename(entity.path).startsWith('.')) return null; if (entity is Directory) { return DirectoryDescriptor.fromFilesystem( @@ -55,12 +55,14 @@ class DirectoryDescriptor extends Descriptor { }).where((path) => path != null)); } + @override Future create([String parent]) async { var fullPath = p.join(parent ?? sandbox, name); await Directory(fullPath).create(recursive: true); await Future.wait(contents.map((entry) => entry.create(fullPath))); } + @override Future validate([String parent]) async { var fullPath = p.join(parent ?? sandbox, name); if (!(await Directory(fullPath).exists())) { @@ -85,12 +87,12 @@ class DirectoryDescriptor extends Descriptor { } else if (url is Uri) { path = url.toString(); } else { - throw ArgumentError.value(url, "url", "must be a Uri or a String."); + throw ArgumentError.value(url, 'url', 'must be a Uri or a String.'); } if (!p.url.isWithin('.', path)) { throw ArgumentError.value( - url, "url", "must be relative and beneath the base URL."); + url, 'url', 'must be relative and beneath the base URL.'); } return StreamCompleter.fromFuture(Future.sync(() { @@ -121,5 +123,6 @@ class DirectoryDescriptor extends Descriptor { })); } + @override String describe() => describeDirectory(name, contents); } diff --git a/pkgs/test_descriptor/lib/src/file_descriptor.dart b/pkgs/test_descriptor/lib/src/file_descriptor.dart index b755ee50e..3d634b670 100644 --- a/pkgs/test_descriptor/lib/src/file_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/file_descriptor.dart @@ -59,6 +59,7 @@ abstract class FileDescriptor extends Descriptor { /// A protected constructor that's only intended for subclasses. FileDescriptor.protected(String name) : super(name); + @override Future create([String parent]) async { // Create the stream before we call [File.openWrite] because it may fail // fast (e.g. if this is a matcher file). @@ -70,6 +71,7 @@ abstract class FileDescriptor extends Descriptor { } } + @override Future validate([String parent]) async { var fullPath = p.join(parent ?? sandbox, name); var pretty = prettyPath(fullPath); @@ -97,6 +99,7 @@ abstract class FileDescriptor extends Descriptor { /// This isn't supported for matcher descriptors. Stream> readAsBytes(); + @override String describe() => name; } @@ -106,8 +109,10 @@ class _BinaryFileDescriptor extends FileDescriptor { _BinaryFileDescriptor(String name, this._contents) : super.protected(name); + @override Stream> readAsBytes() => Stream.fromIterable([_contents]); + @override Future _validate(String prettPath, List actualContents) async { if (const IterableEquality().equals(_contents, actualContents)) return null; // TODO(nweiz): show a hex dump here if the data is small enough. @@ -121,11 +126,14 @@ class _StringFileDescriptor extends FileDescriptor { _StringFileDescriptor(String name, this._contents) : super.protected(name); + @override Future read() async => _contents; + @override Stream> readAsBytes() => Stream.fromIterable([utf8.encode(_contents)]); + @override Future _validate(String prettyPath, List actualContents) { var actualContentsText = utf8.decode(actualContents); if (_contents == actualContentsText) return null; @@ -163,8 +171,8 @@ class _StringFileDescriptor extends FileDescriptor { } return 'File "$prettyPath" should contain:\n' - "${addBar(expected)}\n" - "but actually contained:\n" + '${addBar(expected)}\n' + 'but actually contained:\n' "${results.join('\n')}"; } } @@ -181,9 +189,11 @@ class _MatcherFileDescriptor extends FileDescriptor { : _isBinary = isBinary, super.protected(name); + @override Stream> readAsBytes() => throw UnsupportedError("Matcher files can't be created or read."); + @override Future _validate(String prettyPath, List actualContents) async { try { expect( diff --git a/pkgs/test_descriptor/lib/src/nothing_descriptor.dart b/pkgs/test_descriptor/lib/src/nothing_descriptor.dart index 98abe61cd..5dd9b8a72 100644 --- a/pkgs/test_descriptor/lib/src/nothing_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/nothing_descriptor.dart @@ -18,8 +18,10 @@ import 'utils.dart'; class NothingDescriptor extends Descriptor { NothingDescriptor(String name) : super(name); + @override Future create([String parent]) async {} + @override Future validate([String parent]) async { var fullPath = p.join(parent ?? sandbox, name); var pretty = prettyPath(fullPath); @@ -32,5 +34,6 @@ class NothingDescriptor extends Descriptor { } } + @override String describe() => 'nothing at "$name"'; } diff --git a/pkgs/test_descriptor/lib/src/pattern_descriptor.dart b/pkgs/test_descriptor/lib/src/pattern_descriptor.dart index 3432876f0..9de3b9935 100644 --- a/pkgs/test_descriptor/lib/src/pattern_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/pattern_descriptor.dart @@ -31,7 +31,7 @@ class PatternDescriptor extends Descriptor { /// matching [pattern]. final _EntryCreator _fn; - PatternDescriptor(this.pattern, Descriptor child(String basename)) + PatternDescriptor(this.pattern, Descriptor Function(String basename) child) : _fn = child, super('$pattern'); @@ -40,6 +40,7 @@ class PatternDescriptor extends Descriptor { /// matching [pattern], then passes each of their names to `child` provided /// in the constructor and validates the result. If exactly one succeeds, /// `this` is considered valid. + @override Future validate([String parent]) async { var inSandbox = parent == null; parent ??= sandbox; @@ -51,7 +52,7 @@ class PatternDescriptor extends Descriptor { .toList(); matchingEntries.sort(); - var location = inSandbox ? "sandbox" : '"${prettyPath(parent)}"'; + var location = inSandbox ? 'sandbox' : '"${prettyPath(parent)}"'; if (matchingEntries.isEmpty) { fail('No entries found in $location matching $_patternDescription.'); } @@ -80,7 +81,8 @@ class PatternDescriptor extends Descriptor { } } - String describe() => "entry matching $_patternDescription"; + @override + String describe() => 'entry matching $_patternDescription'; String get _patternDescription { if (pattern is String) return '"$pattern"'; @@ -93,6 +95,7 @@ class PatternDescriptor extends Descriptor { return '/${regExp.pattern}/$flags'; } + @override Future create([String parent]) { throw UnsupportedError("Pattern descriptors don't support create()."); } diff --git a/pkgs/test_descriptor/lib/src/utils.dart b/pkgs/test_descriptor/lib/src/utils.dart index 5dad79479..85d339f6c 100644 --- a/pkgs/test_descriptor/lib/src/utils.dart +++ b/pkgs/test_descriptor/lib/src/utils.dart @@ -16,15 +16,15 @@ import 'sandbox.dart'; final utf8 = const Utf8Codec(allowMalformed: true); /// Prepends a vertical bar to [text]. -String addBar(String text) => prefixLines(text, "${glyph.verticalLine} ", - first: "${glyph.downEnd} ", last: "${glyph.upEnd} ", single: "| "); +String addBar(String text) => prefixLines(text, '${glyph.verticalLine} ', + first: '${glyph.downEnd} ', last: '${glyph.upEnd} ', single: '| '); /// Indents [text], and adds a bullet at the beginning. String addBullet(String text) => - prefixLines(text, " ", first: "${glyph.bullet} "); + prefixLines(text, ' ', first: '${glyph.bullet} '); /// Converts [strings] to a bulleted list. -String bullet(Iterable strings) => strings.map(addBullet).join("\n"); +String bullet(Iterable strings) => strings.map(addBullet).join('\n'); /// Returns a human-readable description of a directory with the given [name] /// and [contents]. @@ -60,13 +60,13 @@ String prefixLines(String text, String prefix, single ??= first ?? last ?? prefix; var lines = text.split('\n'); - if (lines.length == 1) return "$single$text"; + if (lines.length == 1) return '$single$text'; - var buffer = StringBuffer("$first${lines.first}\n"); + var buffer = StringBuffer('$first${lines.first}\n'); for (var line in lines.skip(1).take(lines.length - 2)) { - buffer.writeln("$prefix$line"); + buffer.writeln('$prefix$line'); } - buffer.write("$last${lines.last}"); + buffer.write('$last${lines.last}'); return buffer.toString(); } diff --git a/pkgs/test_descriptor/lib/test_descriptor.dart b/pkgs/test_descriptor/lib/test_descriptor.dart index ea576454a..343a2747d 100644 --- a/pkgs/test_descriptor/lib/test_descriptor.dart +++ b/pkgs/test_descriptor/lib/test_descriptor.dart @@ -43,7 +43,7 @@ FileDescriptor file(String name, [contents]) => FileDescriptor(name, contents); /// children exist. To ensure that a particular child doesn't exist, use /// [nothing]. DirectoryDescriptor dir(String name, [Iterable contents]) => - DirectoryDescriptor(name, contents == null ? [] : contents); + DirectoryDescriptor(name, contents ?? []); /// Creates a new [NothingDescriptor] descriptor that asserts that no entry /// named [name] exists. @@ -61,7 +61,8 @@ NothingDescriptor nothing(String name) => NothingDescriptor(name); /// [child]. /// /// [Descriptor.create] is not supported for this descriptor. -PatternDescriptor pattern(Pattern name, Descriptor child(String basename)) => +PatternDescriptor pattern( + Pattern name, Descriptor Function(String basename) child) => PatternDescriptor(name, child); /// A convenience method for creating a [PatternDescriptor] descriptor that diff --git a/pkgs/test_descriptor/test/archive_test.dart b/pkgs/test_descriptor/test/archive_test.dart index a413fb96d..751afdcf7 100644 --- a/pkgs/test_descriptor/test/archive_test.dart +++ b/pkgs/test_descriptor/test/archive_test.dart @@ -16,250 +16,250 @@ import 'package:test_descriptor/test_descriptor.dart' as d; import 'utils.dart'; void main() { - group("create()", () { - test("creates an empty archive", () async { - await d.archive("test.tar").create(); + group('create()', () { + test('creates an empty archive', () async { + await d.archive('test.tar').create(); var archive = - TarDecoder().decodeBytes(File(d.path("test.tar")).readAsBytesSync()); + TarDecoder().decodeBytes(File(d.path('test.tar')).readAsBytesSync()); expect(archive.files, isEmpty); }); - test("creates an archive with files", () async { - await d.archive("test.tar", [ - d.file("file1.txt", "contents 1"), - d.file("file2.txt", "contents 2") + test('creates an archive with files', () async { + await d.archive('test.tar', [ + d.file('file1.txt', 'contents 1'), + d.file('file2.txt', 'contents 2') ]).create(); var files = TarDecoder() - .decodeBytes(File(d.path("test.tar")).readAsBytesSync()) + .decodeBytes(File(d.path('test.tar')).readAsBytesSync()) .files; expect(files.length, equals(2)); - _expectFile(files[0], "file1.txt", "contents 1"); - _expectFile(files[1], "file2.txt", "contents 2"); + _expectFile(files[0], 'file1.txt', 'contents 1'); + _expectFile(files[1], 'file2.txt', 'contents 2'); }); - test("creates an archive with files in a directory", () async { - await d.archive("test.tar", [ - d.dir("dir", [ - d.file("file1.txt", "contents 1"), - d.file("file2.txt", "contents 2") + test('creates an archive with files in a directory', () async { + await d.archive('test.tar', [ + d.dir('dir', [ + d.file('file1.txt', 'contents 1'), + d.file('file2.txt', 'contents 2') ]) ]).create(); var files = TarDecoder() - .decodeBytes(File(d.path("test.tar")).readAsBytesSync()) + .decodeBytes(File(d.path('test.tar')).readAsBytesSync()) .files; expect(files.length, equals(2)); - _expectFile(files[0], "dir/file1.txt", "contents 1"); - _expectFile(files[1], "dir/file2.txt", "contents 2"); + _expectFile(files[0], 'dir/file1.txt', 'contents 1'); + _expectFile(files[1], 'dir/file2.txt', 'contents 2'); }); - test("creates an archive with files in a nested directory", () async { - await d.archive("test.tar", [ - d.dir("dir", [ - d.dir("subdir", [ - d.file("file1.txt", "contents 1"), - d.file("file2.txt", "contents 2") + test('creates an archive with files in a nested directory', () async { + await d.archive('test.tar', [ + d.dir('dir', [ + d.dir('subdir', [ + d.file('file1.txt', 'contents 1'), + d.file('file2.txt', 'contents 2') ]) ]) ]).create(); var files = TarDecoder() - .decodeBytes(File(d.path("test.tar")).readAsBytesSync()) + .decodeBytes(File(d.path('test.tar')).readAsBytesSync()) .files; expect(files.length, equals(2)); - _expectFile(files[0], "dir/subdir/file1.txt", "contents 1"); - _expectFile(files[1], "dir/subdir/file2.txt", "contents 2"); + _expectFile(files[0], 'dir/subdir/file1.txt', 'contents 1'); + _expectFile(files[1], 'dir/subdir/file2.txt', 'contents 2'); }); - group("creates a file in", () { - test("zip format", () async { - await d.archive("test.zip", [d.file("file.txt", "contents")]).create(); + group('creates a file in', () { + test('zip format', () async { + await d.archive('test.zip', [d.file('file.txt', 'contents')]).create(); var archive = ZipDecoder() - .decodeBytes(File(d.path("test.zip")).readAsBytesSync()); - _expectFile(archive.files.single, "file.txt", "contents"); + .decodeBytes(File(d.path('test.zip')).readAsBytesSync()); + _expectFile(archive.files.single, 'file.txt', 'contents'); }); - group("gzip tar format", () { - for (var extension in [".tar.gz", ".tar.gzip", ".tgz"]) { - test("with $extension", () async { + group('gzip tar format', () { + for (var extension in ['.tar.gz', '.tar.gzip', '.tgz']) { + test('with $extension', () async { await d.archive( - "test$extension", [d.file("file.txt", "contents")]).create(); + 'test$extension', [d.file('file.txt', 'contents')]).create(); var archive = TarDecoder().decodeBytes(GZipDecoder() - .decodeBytes(File(d.path("test$extension")).readAsBytesSync())); - _expectFile(archive.files.single, "file.txt", "contents"); + .decodeBytes(File(d.path('test$extension')).readAsBytesSync())); + _expectFile(archive.files.single, 'file.txt', 'contents'); }); } }); - group("bzip2 tar format", () { - for (var extension in [".tar.bz2", ".tar.bzip2"]) { - test("with $extension", () async { + group('bzip2 tar format', () { + for (var extension in ['.tar.bz2', '.tar.bzip2']) { + test('with $extension', () async { await d.archive( - "test$extension", [d.file("file.txt", "contents")]).create(); + 'test$extension', [d.file('file.txt', 'contents')]).create(); var archive = TarDecoder().decodeBytes(BZip2Decoder() - .decodeBytes(File(d.path("test$extension")).readAsBytesSync())); - _expectFile(archive.files.single, "file.txt", "contents"); + .decodeBytes(File(d.path('test$extension')).readAsBytesSync())); + _expectFile(archive.files.single, 'file.txt', 'contents'); }); } }); }); - group("gracefully rejects", () { - test("an uncreatable descriptor", () async { + group('gracefully rejects', () { + test('an uncreatable descriptor', () async { await expectLater( - d.archive("test.tar", [d.filePattern(RegExp(r"^foo-"))]).create(), + d.archive('test.tar', [d.filePattern(RegExp(r'^foo-'))]).create(), throwsUnsupportedError); - await d.nothing("test.tar").validate(); + await d.nothing('test.tar').validate(); }); - test("a non-file non-directory descriptor", () async { + test('a non-file non-directory descriptor', () async { await expectLater( - d.archive("test.tar", [d.nothing("file.txt")]).create(), + d.archive('test.tar', [d.nothing('file.txt')]).create(), throwsUnsupportedError); - await d.nothing("test.tar").validate(); + await d.nothing('test.tar').validate(); }); - test("an unknown file extension", () async { + test('an unknown file extension', () async { await expectLater( - d.archive("test.asdf", [d.nothing("file.txt")]).create(), + d.archive('test.asdf', [d.nothing('file.txt')]).create(), throwsUnsupportedError); }); }); }); - group("validate()", () { - group("with an empty archive", () { - test("succeeds if an empty archive exists", () async { - File(d.path("test.tar")) + group('validate()', () { + group('with an empty archive', () { + test('succeeds if an empty archive exists', () async { + File(d.path('test.tar')) .writeAsBytesSync(TarEncoder().encode(Archive())); - await d.archive("test.tar").validate(); + await d.archive('test.tar').validate(); }); - test("succeeds if a non-empty archive exists", () async { - File(d.path("test.tar")).writeAsBytesSync( - TarEncoder().encode(Archive()..addFile(_file("file.txt")))); - await d.archive("test.tar").validate(); + test('succeeds if a non-empty archive exists', () async { + File(d.path('test.tar')).writeAsBytesSync( + TarEncoder().encode(Archive()..addFile(_file('file.txt')))); + await d.archive('test.tar').validate(); }); - test("fails if no archive exists", () { - expect(d.archive("test.tar").validate(), + test('fails if no archive exists', () { + expect(d.archive('test.tar').validate(), throwsA(toString(startsWith('File not found: "test.tar".')))); }); - test("fails if an invalid archive exists", () { - d.file("test.tar", "not a valid tar file").create(); + test('fails if an invalid archive exists', () { + d.file('test.tar', 'not a valid tar file').create(); expect( - d.archive("test.tar").validate(), + d.archive('test.tar').validate(), throwsA(toString( startsWith('File "test.tar" is not a valid archive.')))); }); }); - test("succeeds if an archive contains a matching file", () async { - File(d.path("test.tar")).writeAsBytesSync(TarEncoder() - .encode(Archive()..addFile(_file("file.txt", "contents")))); - await d.archive("test.tar", [d.file("file.txt", "contents")]).validate(); + test('succeeds if an archive contains a matching file', () async { + File(d.path('test.tar')).writeAsBytesSync(TarEncoder() + .encode(Archive()..addFile(_file('file.txt', 'contents')))); + await d.archive('test.tar', [d.file('file.txt', 'contents')]).validate(); }); test("fails if an archive doesn't contain a file", () async { - File(d.path("test.tar")).writeAsBytesSync(TarEncoder().encode(Archive())); + File(d.path('test.tar')).writeAsBytesSync(TarEncoder().encode(Archive())); expect( - d.archive("test.tar", [d.file("file.txt", "contents")]).validate(), + d.archive('test.tar', [d.file('file.txt', 'contents')]).validate(), throwsA( toString(startsWith('File not found: "test.tar/file.txt".')))); }); - test("fails if an archive contains a non-matching file", () async { - File(d.path("test.tar")).writeAsBytesSync(TarEncoder() - .encode(Archive()..addFile(_file("file.txt", "wrong contents")))); + test('fails if an archive contains a non-matching file', () async { + File(d.path('test.tar')).writeAsBytesSync(TarEncoder() + .encode(Archive()..addFile(_file('file.txt', 'wrong contents')))); expect( - d.archive("test.tar", [d.file("file.txt", "contents")]).validate(), + d.archive('test.tar', [d.file('file.txt', 'contents')]).validate(), throwsA(toString( startsWith('File "test.tar/file.txt" should contain:')))); }); - test("succeeds if an archive contains a file matching a pattern", () async { - File(d.path("test.tar")).writeAsBytesSync(TarEncoder() - .encode(Archive()..addFile(_file("file.txt", "contents")))); - await d.archive("test.tar", - [d.filePattern(RegExp(r"f..e\.txt"), "contents")]).validate(); + test('succeeds if an archive contains a file matching a pattern', () async { + File(d.path('test.tar')).writeAsBytesSync(TarEncoder() + .encode(Archive()..addFile(_file('file.txt', 'contents')))); + await d.archive('test.tar', + [d.filePattern(RegExp(r'f..e\.txt'), 'contents')]).validate(); }); - group("validates a file in", () { - test("zip format", () async { - File(d.path("test.zip")).writeAsBytesSync(ZipEncoder() - .encode(Archive()..addFile(_file("file.txt", "contents")))); + group('validates a file in', () { + test('zip format', () async { + File(d.path('test.zip')).writeAsBytesSync(ZipEncoder() + .encode(Archive()..addFile(_file('file.txt', 'contents')))); await d - .archive("test.zip", [d.file("file.txt", "contents")]).validate(); + .archive('test.zip', [d.file('file.txt', 'contents')]).validate(); }); - group("gzip tar format", () { - for (var extension in [".tar.gz", ".tar.gzip", ".tgz"]) { - test("with $extension", () async { - File(d.path("test$extension")).writeAsBytesSync(GZipEncoder() + group('gzip tar format', () { + for (var extension in ['.tar.gz', '.tar.gzip', '.tgz']) { + test('with $extension', () async { + File(d.path('test$extension')).writeAsBytesSync(GZipEncoder() .encode(TarEncoder().encode( - Archive()..addFile(_file("file.txt", "contents"))))); + Archive()..addFile(_file('file.txt', 'contents'))))); await d.archive( - "test$extension", [d.file("file.txt", "contents")]).validate(); + 'test$extension', [d.file('file.txt', 'contents')]).validate(); }); } }); - group("bzip2 tar format", () { - for (var extension in [".tar.bz2", ".tar.bzip2"]) { - test("with $extension", () async { - File(d.path("test$extension")).writeAsBytesSync(BZip2Encoder() + group('bzip2 tar format', () { + for (var extension in ['.tar.bz2', '.tar.bzip2']) { + test('with $extension', () async { + File(d.path('test$extension')).writeAsBytesSync(BZip2Encoder() .encode(TarEncoder().encode( - Archive()..addFile(_file("file.txt", "contents"))))); + Archive()..addFile(_file('file.txt', 'contents'))))); await d.archive( - "test$extension", [d.file("file.txt", "contents")]).validate(); + 'test$extension', [d.file('file.txt', 'contents')]).validate(); }); } }); }); - test("gracefully rejects an unknown file format", () { - expect(d.archive("test.asdf").validate(), throwsUnsupportedError); + test('gracefully rejects an unknown file format', () { + expect(d.archive('test.asdf').validate(), throwsUnsupportedError); }); }); - test("read() is unsupported", () { - expect(d.archive("test.tar").read(), throwsUnsupportedError); + test('read() is unsupported', () { + expect(d.archive('test.tar').read(), throwsUnsupportedError); }); - test("readAsBytes() returns the contents of the archive", () async { - var descriptor = d.archive("test.tar", - [d.file("file1.txt", "contents 1"), d.file("file2.txt", "contents 2")]); + test('readAsBytes() returns the contents of the archive', () async { + var descriptor = d.archive('test.tar', + [d.file('file1.txt', 'contents 1'), d.file('file2.txt', 'contents 2')]); var files = TarDecoder() .decodeBytes(await collectBytes(descriptor.readAsBytes())) .files; expect(files.length, equals(2)); - _expectFile(files[0], "file1.txt", "contents 1"); - _expectFile(files[1], "file2.txt", "contents 2"); + _expectFile(files[0], 'file1.txt', 'contents 1'); + _expectFile(files[1], 'file2.txt', 'contents 2'); }); - test("archive returns the in-memory contents", () async { - var archive = await d.archive("test.tar", [ - d.file("file1.txt", "contents 1"), - d.file("file2.txt", "contents 2") + test('archive returns the in-memory contents', () async { + var archive = await d.archive('test.tar', [ + d.file('file1.txt', 'contents 1'), + d.file('file2.txt', 'contents 2') ]).archive; var files = archive.files; expect(files.length, equals(2)); - _expectFile(files[0], "file1.txt", "contents 1"); - _expectFile(files[1], "file2.txt", "contents 2"); + _expectFile(files[0], 'file1.txt', 'contents 1'); + _expectFile(files[1], 'file2.txt', 'contents 2'); }); - test("io refers to the file within the sandbox", () { + test('io refers to the file within the sandbox', () { expect(d.file('test.tar').io.path, equals(p.join(d.sandbox, 'test.tar'))); }); } @@ -272,7 +272,7 @@ void _expectFile(ArchiveFile file, String name, String contents) { /// Creates an [ArchiveFile] with the given [name] and [contents]. ArchiveFile _file(String name, [String contents]) { - var bytes = utf8.encode(contents ?? ""); + var bytes = utf8.encode(contents ?? ''); return ArchiveFile(name, bytes.length, bytes) // Setting the mode and mod time are necessary to work around // brendan-duncan/archive#76. diff --git a/pkgs/test_descriptor/test/directory_test.dart b/pkgs/test_descriptor/test/directory_test.dart index b03edc343..71b998ed3 100644 --- a/pkgs/test_descriptor/test/directory_test.dart +++ b/pkgs/test_descriptor/test/directory_test.dart @@ -17,8 +17,8 @@ import 'package:test_descriptor/test_descriptor.dart' as d; import 'utils.dart'; void main() { - group("create()", () { - test("creates a directory and its contents", () async { + group('create()', () { + test('creates a directory and its contents', () async { await d.dir('dir', [ d.dir('subdir', [ d.file('subfile1.txt', 'subcontents1'), @@ -42,7 +42,7 @@ void main() { completion(equals('subcontents2'))); }); - test("works if the directory already exists", () async { + test('works if the directory already exists', () async { await d.dir('dir').create(); await d.dir('dir', [d.file('name.txt', 'contents')]).create(); @@ -51,8 +51,8 @@ void main() { }); }); - group("validate()", () { - test("completes successfully if the filesystem matches the descriptor", + group('validate()', () { + test('completes successfully if the filesystem matches the descriptor', () async { var dirPath = p.join(d.sandbox, 'dir'); var subdirPath = p.join(dirPath, 'subdir'); @@ -93,7 +93,7 @@ void main() { equals('Directory not found: "${p.join('dir', 'subdir')}".')))); }); - test("emits an error for each child that fails to validate", () async { + test('emits an error for each child that fails to validate', () async { var dirPath = p.join(d.sandbox, 'dir'); var subdirPath = p.join(dirPath, 'subdir'); await Directory(subdirPath).create(recursive: true); @@ -132,15 +132,15 @@ void main() { }); }); - group("load()", () { - test("loads a file", () { + group('load()', () { + test('loads a file', () { var dir = d.dir('dir', [d.file('name.txt', 'contents'), d.file('other.txt', 'wrong')]); expect(utf8.decodeStream(dir.load('name.txt')), completion(equals('contents'))); }); - test("loads a deeply-nested file", () { + test('loads a deeply-nested file', () { var dir = d.dir('dir', [ d.dir('subdir', [d.file('name.txt', 'subcontents'), d.file('other.txt', 'wrong')]), @@ -152,7 +152,7 @@ void main() { completion(equals('subcontents'))); }); - test("fails to load a nested directory", () { + test('fails to load a nested directory', () { var dir = d.dir('dir', [ d.dir('subdir', [ d.dir('subsubdir', [d.file('name.txt', 'subcontents')]) @@ -166,7 +166,7 @@ void main() { '"subsubdir" within "dir/subdir".')))); }); - test("fails to load an absolute path", () { + test('fails to load an absolute path', () { var dir = d.dir('dir', [d.file('name.txt', 'contents')]); expect(() => dir.load('/name.txt'), throwsArgumentError); }); @@ -187,7 +187,7 @@ void main() { '"not-name.txt" within "dir/subdir".')))); }); - test("fails to load a file that exists multiple times", () { + test('fails to load a file that exists multiple times', () { var dir = d.dir('dir', [ d.dir('subdir', [d.file('name.txt', 'contents'), d.file('name.txt', 'contents')]) @@ -199,7 +199,7 @@ void main() { '"name.txt" within "dir/subdir".')))); }); - test("loads a file next to a subdirectory with the same name", () { + test('loads a file next to a subdirectory with the same name', () { var dir = d.dir('dir', [ d.file('name', 'contents'), d.dir('name', [d.file('subfile', 'contents')]) @@ -210,7 +210,7 @@ void main() { }); }); - group("describe()", () { + group('describe()', () { bool oldAscii; setUpAll(() { oldAscii = term_glyph.ascii; @@ -221,18 +221,18 @@ void main() { term_glyph.ascii = oldAscii; }); - test("lists the contents of the directory", () { + test('lists the contents of the directory', () { var dir = d.dir('dir', [d.file('file1.txt', 'contents1'), d.file('file2.txt', 'contents2')]); expect( dir.describe(), - equals("dir\n" - "+-- file1.txt\n" + equals('dir\n' + '+-- file1.txt\n' "'-- file2.txt")); }); - test("lists the contents of nested directories", () { + test('lists the contents of nested directories', () { var dir = d.dir('dir', [ d.file('file1.txt', 'contents1'), d.dir('subdir', [ @@ -245,23 +245,23 @@ void main() { expect( dir.describe(), - equals("dir\n" - "+-- file1.txt\n" - "+-- subdir\n" - "| +-- subfile1.txt\n" - "| +-- subfile2.txt\n" + equals('dir\n' + '+-- file1.txt\n' + '+-- subdir\n' + '| +-- subfile1.txt\n' + '| +-- subfile2.txt\n' "| '-- subsubdir\n" "| '-- subsubfile.txt\n" "'-- file2.txt")); }); - test("with no contents returns the directory name", () { + test('with no contents returns the directory name', () { expect(d.dir('dir').describe(), equals('dir')); }); }); - group("fromFilesystem()", () { - test("creates a descriptor based on the physical filesystem", () async { + group('fromFilesystem()', () { + test('creates a descriptor based on the physical filesystem', () async { var dir = d.dir('dir', [ d.dir('subdir', [ d.file('subfile1.txt', 'subcontents1'), @@ -273,12 +273,12 @@ void main() { await dir.create(); var descriptor = - d.DirectoryDescriptor.fromFilesystem("dir", p.join(d.sandbox, 'dir')); + d.DirectoryDescriptor.fromFilesystem('dir', p.join(d.sandbox, 'dir')); await descriptor.create(p.join(d.sandbox, 'dir2')); await dir.validate(p.join(d.sandbox, 'dir2')); }); - test("ignores hidden files", () async { + test('ignores hidden files', () async { await d.dir('dir', [ d.dir('subdir', [ d.file('subfile1.txt', 'subcontents1'), @@ -289,7 +289,7 @@ void main() { ]).create(); var descriptor = d.DirectoryDescriptor.fromFilesystem( - "dir2", p.join(d.sandbox, 'dir')); + 'dir2', p.join(d.sandbox, 'dir')); await descriptor.create(); await d.dir('dir2', [ @@ -301,7 +301,7 @@ void main() { }); }); - test("io refers to the directory within the sandbox", () { + test('io refers to the directory within the sandbox', () { expect(d.file('dir').io.path, equals(p.join(d.sandbox, 'dir'))); }); } diff --git a/pkgs/test_descriptor/test/file_test.dart b/pkgs/test_descriptor/test/file_test.dart index a1e803b06..8b111f965 100644 --- a/pkgs/test_descriptor/test/file_test.dart +++ b/pkgs/test_descriptor/test/file_test.dart @@ -13,7 +13,7 @@ import 'package:test_descriptor/test_descriptor.dart' as d; import 'utils.dart'; void main() { - group("create()", () { + group('create()', () { test('creates a text file', () async { await d.file('name.txt', 'contents').create(); @@ -42,7 +42,7 @@ void main() { }); }); - group("validate()", () { + group('validate()', () { test('succeeds if the filesystem matches a text descriptor', () async { await File(p.join(d.sandbox, 'name.txt')).writeAsString('contents'); await d.file('name.txt', 'contents').validate(); @@ -118,40 +118,40 @@ void main() { }); }); - group("reading", () { - test("read() returns the contents of a text file as a string", () { + group('reading', () { + test('read() returns the contents of a text file as a string', () { expect(d.file('name.txt', 'contents').read(), completion(equals('contents'))); }); - test("read() returns the contents of a binary file as a string", () { + test('read() returns the contents of a binary file as a string', () { expect(d.file('name.txt', [0x68, 0x65, 0x6c, 0x6c, 0x6f]).read(), completion(equals('hello'))); }); - test("read() fails for a matcher file", () { + test('read() fails for a matcher file', () { expect(d.file('name.txt', contains('hi')).read, throwsUnsupportedError); }); - test("readAsBytes() returns the contents of a text file as a byte stream", + test('readAsBytes() returns the contents of a text file as a byte stream', () { expect(utf8.decodeStream(d.file('name.txt', 'contents').readAsBytes()), completion(equals('contents'))); }); - test("readAsBytes() returns the contents of a binary file as a byte stream", + test('readAsBytes() returns the contents of a binary file as a byte stream', () { expect(byteStreamToList(d.file('name.txt', [0, 1, 2, 3]).readAsBytes()), completion(equals([0, 1, 2, 3]))); }); - test("readAsBytes() fails for a matcher file", () { + test('readAsBytes() fails for a matcher file', () { expect(d.file('name.txt', contains('hi')).readAsBytes, throwsUnsupportedError); }); }); - test("io refers to the file within the sandbox", () { + test('io refers to the file within the sandbox', () { expect(d.file('name.txt').io.path, equals(p.join(d.sandbox, 'name.txt'))); }); } diff --git a/pkgs/test_descriptor/test/nothing_test.dart b/pkgs/test_descriptor/test/nothing_test.dart index d1172605f..a192087a8 100644 --- a/pkgs/test_descriptor/test/nothing_test.dart +++ b/pkgs/test_descriptor/test/nothing_test.dart @@ -14,13 +14,13 @@ import 'package:test_descriptor/test_descriptor.dart' as d; import 'utils.dart'; void main() { - test("create() does nothing", () async { + test('create() does nothing', () async { await d.nothing('foo').create(); expect(File(p.join(d.sandbox, 'foo')).exists(), completion(isFalse)); expect(Directory(p.join(d.sandbox, 'foo')).exists(), completion(isFalse)); }); - group("validate()", () { + group('validate()', () { test("succeeds if nothing's there", () async { await d.nothing('foo').validate(); }); diff --git a/pkgs/test_descriptor/test/pattern_test.dart b/pkgs/test_descriptor/test/pattern_test.dart index d337b1fd4..eb7b81528 100644 --- a/pkgs/test_descriptor/test/pattern_test.dart +++ b/pkgs/test_descriptor/test/pattern_test.dart @@ -11,7 +11,7 @@ import 'package:test_descriptor/test_descriptor.dart' as d; import 'utils.dart'; void main() { - group("validate()", () { + group('validate()', () { test("succeeds if there's a file matching the pattern and the child", () async { await d.file('foo', 'blap').create(); @@ -26,8 +26,8 @@ void main() { }); test( - "succeeds if multiple files match the pattern but only one matches " - "the child entry", () async { + 'succeeds if multiple files match the pattern but only one matches ' + 'the child entry', () async { await d.file('foo', 'blap').create(); await d.file('fee', 'blak').create(); await d.file('faa', 'blut').create(); @@ -58,15 +58,15 @@ void main() { }); test( - "fails if there are multiple files matching the pattern and the child " - "entry", () async { + 'fails if there are multiple files matching the pattern and the child ' + 'entry', () async { await d.file('foo', 'bar').create(); await d.file('fee', 'bar').create(); await d.file('faa', 'bar').create(); expect( d.filePattern(RegExp(r'f..'), 'bar').validate(), throwsA(toString(startsWith( - "Multiple valid entries found in sandbox matching /f../:")))); + 'Multiple valid entries found in sandbox matching /f../:')))); }); }); } diff --git a/pkgs/test_descriptor/test/sandbox_test.dart b/pkgs/test_descriptor/test/sandbox_test.dart index c34c5c63b..f20a8ffe8 100644 --- a/pkgs/test_descriptor/test/sandbox_test.dart +++ b/pkgs/test_descriptor/test/sandbox_test.dart @@ -12,11 +12,11 @@ import 'package:test/test.dart'; import 'package:test_descriptor/test_descriptor.dart' as d; void main() { - test("accessing the getter creates the directory", () { + test('accessing the getter creates the directory', () { expect(Directory(d.sandbox).existsSync(), isTrue); }); - test("the directory is deleted after the test", () { + test('the directory is deleted after the test', () { String sandbox; addTearDown(() { expect(Directory(sandbox).existsSync(), isFalse); @@ -25,7 +25,7 @@ void main() { sandbox = d.sandbox; }); - test("path() returns a path in the sandbox", () { - expect(d.path("foo"), equals(p.join(d.sandbox, "foo"))); + test('path() returns a path in the sandbox', () { + expect(d.path('foo'), equals(p.join(d.sandbox, 'foo'))); }); } diff --git a/pkgs/test_descriptor/test/utils.dart b/pkgs/test_descriptor/test/utils.dart index d6359f12b..3ea1e2996 100644 --- a/pkgs/test_descriptor/test/utils.dart +++ b/pkgs/test_descriptor/test/utils.dart @@ -20,5 +20,5 @@ Matcher toString(matcher) { return predicate((object) { expect(object.toString(), matcher); return true; - }, "toString() matches $matcher"); + }, 'toString() matches $matcher'); } From 65d7dbc1d39841286ce3ae9cd63226099da46bd3 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 13 Mar 2020 12:14:32 -0700 Subject: [PATCH 20/72] remove author from pubspec --- pkgs/test_descriptor/pubspec.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/test_descriptor/pubspec.yaml b/pkgs/test_descriptor/pubspec.yaml index 31bef959c..c21b71b77 100644 --- a/pkgs/test_descriptor/pubspec.yaml +++ b/pkgs/test_descriptor/pubspec.yaml @@ -1,7 +1,6 @@ name: test_descriptor version: 1.2.1-dev description: An API for defining and verifying directory structures. -author: Dart Team homepage: https://github.com/dart-lang/test_descriptor environment: From eaf1432ca7d383252f9548b8dbfa88c69f7d69f1 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 6 Jul 2020 20:48:31 -0700 Subject: [PATCH 21/72] Bump min Dart SDK to 2.7 (dart-lang/test_descriptor#24) --- pkgs/test_descriptor/.travis.yml | 4 ++-- pkgs/test_descriptor/CHANGELOG.md | 3 ++- pkgs/test_descriptor/pubspec.yaml | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkgs/test_descriptor/.travis.yml b/pkgs/test_descriptor/.travis.yml index 3fa092b30..8914450cd 100644 --- a/pkgs/test_descriptor/.travis.yml +++ b/pkgs/test_descriptor/.travis.yml @@ -2,7 +2,7 @@ language: dart dart: - dev - - 2.1.0 + - 2.7.0 dart_task: - test @@ -14,7 +14,7 @@ matrix: - dart: dev dart_task: dartanalyzer: --fatal-infos --fatal-warnings . - - dart: 2.1.0 + - dart: 2.7.0 dart_task: dartanalyzer: --fatal-warnings . diff --git a/pkgs/test_descriptor/CHANGELOG.md b/pkgs/test_descriptor/CHANGELOG.md index 8fbc4b798..6d4156d49 100644 --- a/pkgs/test_descriptor/CHANGELOG.md +++ b/pkgs/test_descriptor/CHANGELOG.md @@ -1,5 +1,6 @@ -## 1.2.1 +## 1.2.1-dev +* Update minimum Dart SDK to `2.7.0`. * Fix outdated URLs in `README.md`. ## 1.2.0 diff --git a/pkgs/test_descriptor/pubspec.yaml b/pkgs/test_descriptor/pubspec.yaml index c21b71b77..08a3192ca 100644 --- a/pkgs/test_descriptor/pubspec.yaml +++ b/pkgs/test_descriptor/pubspec.yaml @@ -4,7 +4,7 @@ description: An API for defining and verifying directory structures. homepage: https://github.com/dart-lang/test_descriptor environment: - sdk: '>=2.1.0 <3.0.0' + sdk: '>=2.7.0 <3.0.0' dependencies: archive: '^2.0.0' From 53f4eedadc51a201976319421b6ac6708ab63179 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Tue, 1 Sep 2020 15:17:24 -0700 Subject: [PATCH 22/72] Remove unused dep on package:stack_trace (dart-lang/test_descriptor#26) --- pkgs/test_descriptor/pubspec.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/test_descriptor/pubspec.yaml b/pkgs/test_descriptor/pubspec.yaml index 08a3192ca..09319816a 100644 --- a/pkgs/test_descriptor/pubspec.yaml +++ b/pkgs/test_descriptor/pubspec.yaml @@ -13,7 +13,6 @@ dependencies: matcher: '^0.12.0' meta: '^1.1.7' path: '^1.0.0' - stack_trace: '^1.0.0' test: '^1.6.0' term_glyph: '^1.0.0' From 7c4677c7a8af5420386d7d977f11ad5d6fc2a8dc Mon Sep 17 00:00:00 2001 From: Michael R Fairhurst Date: Fri, 25 Sep 2020 21:39:32 -0700 Subject: [PATCH 23/72] Remove unused dart:async imports (dart-lang/test_descriptor#27) Since Dart 2.1, Future and Stream have been exported by dart:core --- pkgs/test_descriptor/lib/src/descriptor.dart | 2 -- pkgs/test_descriptor/lib/src/nothing_descriptor.dart | 1 - 2 files changed, 3 deletions(-) diff --git a/pkgs/test_descriptor/lib/src/descriptor.dart b/pkgs/test_descriptor/lib/src/descriptor.dart index 43de75d11..cd8f7cbe5 100644 --- a/pkgs/test_descriptor/lib/src/descriptor.dart +++ b/pkgs/test_descriptor/lib/src/descriptor.dart @@ -2,8 +2,6 @@ // 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:async'; - import 'sandbox.dart'; /// A declarative description of a filesystem entry. diff --git a/pkgs/test_descriptor/lib/src/nothing_descriptor.dart b/pkgs/test_descriptor/lib/src/nothing_descriptor.dart index 5dd9b8a72..e70e890ee 100644 --- a/pkgs/test_descriptor/lib/src/nothing_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/nothing_descriptor.dart @@ -2,7 +2,6 @@ // 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:async'; import 'dart:io'; import 'package:path/path.dart' as p; From 5d74c5200b358fb65900780f25f2199c85e2d05f Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Tue, 3 Nov 2020 10:20:52 -0800 Subject: [PATCH 24/72] Migrate to runZonedGuarded (dart-lang/test_descriptor#28) The `onError` argument to `runZoned` is deprecated. Switch to the supported `runZonedGuarded`. Add ignored parameters for the `StackTrace` argument to fit the more strict static type. Bump min SDK to 2.8.1 which is the first published with the `runZonedGuarded` API. --- pkgs/test_descriptor/.travis.yml | 4 ++-- pkgs/test_descriptor/lib/src/pattern_descriptor.dart | 4 ++-- pkgs/test_descriptor/pubspec.yaml | 2 +- pkgs/test_descriptor/test/directory_test.dart | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkgs/test_descriptor/.travis.yml b/pkgs/test_descriptor/.travis.yml index 8914450cd..50bda8cb7 100644 --- a/pkgs/test_descriptor/.travis.yml +++ b/pkgs/test_descriptor/.travis.yml @@ -2,7 +2,7 @@ language: dart dart: - dev - - 2.7.0 + - 2.8.1 dart_task: - test @@ -14,7 +14,7 @@ matrix: - dart: dev dart_task: dartanalyzer: --fatal-infos --fatal-warnings . - - dart: 2.7.0 + - dart: 2.8.1 dart_task: dartanalyzer: --fatal-warnings . diff --git a/pkgs/test_descriptor/lib/src/pattern_descriptor.dart b/pkgs/test_descriptor/lib/src/pattern_descriptor.dart index 9de3b9935..4c1760dea 100644 --- a/pkgs/test_descriptor/lib/src/pattern_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/pattern_descriptor.dart @@ -59,12 +59,12 @@ class PatternDescriptor extends Descriptor { var results = await Future.wait(matchingEntries.map((entry) { var basename = p.basename(entry); - return runZoned(() { + return runZonedGuarded(() { return Result.capture(Future.sync(() async { await _fn(basename).validate(parent); return basename; })); - }, onError: (_) { + }, (_, __) { // Validate may produce multiple errors, but we ignore all but the first // to avoid cluttering the user with many different errors from many // different un-matched entries. diff --git a/pkgs/test_descriptor/pubspec.yaml b/pkgs/test_descriptor/pubspec.yaml index 09319816a..290888f5c 100644 --- a/pkgs/test_descriptor/pubspec.yaml +++ b/pkgs/test_descriptor/pubspec.yaml @@ -4,7 +4,7 @@ description: An API for defining and verifying directory structures. homepage: https://github.com/dart-lang/test_descriptor environment: - sdk: '>=2.7.0 <3.0.0' + sdk: '>=2.8.1 <3.0.0' dependencies: archive: '^2.0.0' diff --git a/pkgs/test_descriptor/test/directory_test.dart b/pkgs/test_descriptor/test/directory_test.dart index 71b998ed3..e13508645 100644 --- a/pkgs/test_descriptor/test/directory_test.dart +++ b/pkgs/test_descriptor/test/directory_test.dart @@ -103,7 +103,7 @@ void main() { var errors = 0; var controller = StreamController(); - runZoned(() { + runZonedGuarded(() { d.dir('dir', [ d.dir('subdir', [ d.file('subfile1.txt', 'subcontents1'), @@ -113,7 +113,7 @@ void main() { d.file('file2.txt', 'contents2') ]).validate(); }, - onError: expectAsync1((error) { + expectAsync2((error, _) { errors++; controller.add(error.toString()); if (errors == 3) controller.close(); From 7e7be216287f81357337ec4a5d421ac1b0ea6692 Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Thu, 5 Nov 2020 12:08:20 -0800 Subject: [PATCH 25/72] Migrate to null safety (dart-lang/test_descriptor#29) Dropped support for archives as planned in https://github.com/dart-lang/test_descriptor/issues/25 - this also allows us to migrate before `package:archive`. Closes https://github.com/dart-lang/test_descriptor/issues/25 --- pkgs/test_descriptor/.travis.yml | 4 - pkgs/test_descriptor/CHANGELOG.md | 5 +- .../lib/src/archive_descriptor.dart | 186 ------------ pkgs/test_descriptor/lib/src/descriptor.dart | 4 +- .../lib/src/directory_descriptor.dart | 8 +- .../lib/src/file_descriptor.dart | 16 +- .../lib/src/nothing_descriptor.dart | 4 +- .../lib/src/pattern_descriptor.dart | 35 ++- pkgs/test_descriptor/lib/src/sandbox.dart | 10 +- pkgs/test_descriptor/lib/src/utils.dart | 8 +- pkgs/test_descriptor/lib/test_descriptor.dart | 19 +- pkgs/test_descriptor/pubspec.yaml | 21 +- pkgs/test_descriptor/test/archive_test.dart | 281 ------------------ pkgs/test_descriptor/test/directory_test.dart | 2 +- pkgs/test_descriptor/test/sandbox_test.dart | 2 +- 15 files changed, 61 insertions(+), 544 deletions(-) delete mode 100644 pkgs/test_descriptor/lib/src/archive_descriptor.dart delete mode 100644 pkgs/test_descriptor/test/archive_test.dart diff --git a/pkgs/test_descriptor/.travis.yml b/pkgs/test_descriptor/.travis.yml index 50bda8cb7..502b3eb79 100644 --- a/pkgs/test_descriptor/.travis.yml +++ b/pkgs/test_descriptor/.travis.yml @@ -2,7 +2,6 @@ language: dart dart: - dev - - 2.8.1 dart_task: - test @@ -14,9 +13,6 @@ matrix: - dart: dev dart_task: dartanalyzer: --fatal-infos --fatal-warnings . - - dart: 2.8.1 - dart_task: - dartanalyzer: --fatal-warnings . branches: only: [master] diff --git a/pkgs/test_descriptor/CHANGELOG.md b/pkgs/test_descriptor/CHANGELOG.md index 6d4156d49..2c2bc32d7 100644 --- a/pkgs/test_descriptor/CHANGELOG.md +++ b/pkgs/test_descriptor/CHANGELOG.md @@ -1,7 +1,8 @@ -## 1.2.1-dev +## 2.0.0-nullsafety -* Update minimum Dart SDK to `2.7.0`. +* Migrate to null safety. * Fix outdated URLs in `README.md`. +* BREAKING: Removed archive support. ## 1.2.0 diff --git a/pkgs/test_descriptor/lib/src/archive_descriptor.dart b/pkgs/test_descriptor/lib/src/archive_descriptor.dart deleted file mode 100644 index 7d96ce80a..000000000 --- a/pkgs/test_descriptor/lib/src/archive_descriptor.dart +++ /dev/null @@ -1,186 +0,0 @@ -// Copyright (c) 2019, 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:async'; -import 'dart:io'; - -import 'package:archive/archive.dart'; -import 'package:async/async.dart'; -import 'package:meta/meta.dart'; -import 'package:path/path.dart' as p; -import 'package:test/test.dart'; - -import 'descriptor.dart'; -import 'directory_descriptor.dart'; -import 'file_descriptor.dart'; -import 'sandbox.dart'; -import 'utils.dart'; - -/// A [Descriptor] describing files in a Tar or Zip archive. -/// -/// The format is determined by the descriptor's file extension. -@sealed -class ArchiveDescriptor extends Descriptor implements FileDescriptor { - /// Descriptors for entries in this archive. - final List contents; - - /// Returns a `package:archive` [Archive] object that contains the contents of - /// this file. - Future get archive async { - var archive = Archive(); - (await _files(contents)).forEach(archive.addFile); - return archive; - } - - @override - File get io => File(p.join(sandbox, name)); - - /// Returns [ArchiveFile]s for each file in [descriptors]. - /// - /// If [parent] is passed, it's used as the parent directory for filenames. - Future> _files(Iterable descriptors, - [String parent]) async { - return (await waitAndReportErrors(descriptors.map((descriptor) async { - var fullName = - parent == null ? descriptor.name : '$parent/${descriptor.name}'; - - if (descriptor is FileDescriptor) { - var bytes = await collectBytes(descriptor.readAsBytes()); - return [ - ArchiveFile(fullName, bytes.length, bytes) - // Setting the mode and mod time are necessary to work around - // brendan-duncan/archive#76. - ..mode = 428 - ..lastModTime = DateTime.now().millisecondsSinceEpoch ~/ 1000 - ]; - } else if (descriptor is DirectoryDescriptor) { - return await _files(descriptor.contents, fullName); - } else { - throw UnsupportedError( - 'An archive can only be created from FileDescriptors and ' - 'DirectoryDescriptors.'); - } - }))) - .expand((files) => files); - } - - ArchiveDescriptor(String name, Iterable contents) - : contents = List.unmodifiable(contents), - super(name); - - @override - Future create([String parent]) async { - var path = p.join(parent ?? sandbox, name); - var file = File(path).openWrite(); - try { - try { - await readAsBytes().listen(file.add).asFuture(); - } finally { - await file.close(); - } - } catch (_) { - await File(path).delete(); - rethrow; - } - } - - @override - Future read() async => throw UnsupportedError( - 'ArchiveDescriptor.read() is not supported. Use Archive.readAsBytes() ' - 'instead.'); - - @override - Stream> readAsBytes() => Stream.fromFuture(() async { - return _encodeFunction()(await archive); - }()); - - @override - Future validate([String parent]) async { - // Access this first so we eaerly throw an error for a path with an invalid - // extension. - var decoder = _decodeFunction(); - - var fullPath = p.join(parent ?? sandbox, name); - var pretty = prettyPath(fullPath); - if (!(await File(fullPath).exists())) { - fail('File not found: "$pretty".'); - } - - var bytes = await File(fullPath).readAsBytes(); - Archive archive; - try { - archive = decoder(bytes); - } catch (_) { - // Catch every error to work around brendan-duncan/archive#77. - fail('File "$pretty" is not a valid archive.'); - } - - // Because validators expect to validate against a real filesystem, we have - // to extract the archive to a temp directory and run validation on that. - var tempDir = await Directory.systemTemp - .createTempSync('dart_test_') - .resolveSymbolicLinks(); - - try { - await waitAndReportErrors(archive.files.map((file) async { - var path = p.join(tempDir, file.name); - await Directory(p.dirname(path)).create(recursive: true); - await File(path).writeAsBytes(file.content as List); - })); - - await waitAndReportErrors(contents.map((entry) async { - try { - await entry.validate(tempDir); - } on TestFailure catch (error) { - // Replace the temporary directory with the path to the archive to - // make the error more user-friendly. - fail(error.message.replaceAll(tempDir, pretty)); - } - })); - } finally { - await Directory(tempDir).delete(recursive: true); - } - } - - /// Returns the function to use to encode this file to binary, based on its - /// [name]. - List Function(Archive) _encodeFunction() { - if (name.endsWith('.zip')) { - return ZipEncoder().encode; - } else if (name.endsWith('.tar')) { - return TarEncoder().encode; - } else if (name.endsWith('.tar.gz') || - name.endsWith('.tar.gzip') || - name.endsWith('.tgz')) { - return (archive) => GZipEncoder().encode(TarEncoder().encode(archive)); - } else if (name.endsWith('.tar.bz2') || name.endsWith('.tar.bzip2')) { - return (archive) => BZip2Encoder().encode(TarEncoder().encode(archive)); - } else { - throw UnsupportedError('Unknown file format $name.'); - } - } - - /// Returns the function to use to decode this file from binary, based on its - /// [name]. - Archive Function(List) _decodeFunction() { - if (name.endsWith('.zip')) { - return ZipDecoder().decodeBytes; - } else if (name.endsWith('.tar')) { - return TarDecoder().decodeBytes; - } else if (name.endsWith('.tar.gz') || - name.endsWith('.tar.gzip') || - name.endsWith('.tgz')) { - return (archive) => - TarDecoder().decodeBytes(GZipDecoder().decodeBytes(archive)); - } else if (name.endsWith('.tar.bz2') || name.endsWith('.tar.bzip2')) { - return (archive) => - TarDecoder().decodeBytes(BZip2Decoder().decodeBytes(archive)); - } else { - throw UnsupportedError('Unknown file format $name.'); - } - } - - @override - String describe() => describeDirectory(name, contents); -} diff --git a/pkgs/test_descriptor/lib/src/descriptor.dart b/pkgs/test_descriptor/lib/src/descriptor.dart index cd8f7cbe5..0d6c30c35 100644 --- a/pkgs/test_descriptor/lib/src/descriptor.dart +++ b/pkgs/test_descriptor/lib/src/descriptor.dart @@ -15,11 +15,11 @@ abstract class Descriptor { /// Creates this entry within the [parent] directory, which defaults to /// [sandbox]. - Future create([String parent]); + Future create([String? parent]); /// Validates that the physical file system under [parent] (which defaults to /// [sandbox]) contains an entry that matches this descriptor. - Future validate([String parent]); + Future validate([String? parent]); /// Returns a human-friendly tree-style description of this descriptor. String describe(); diff --git a/pkgs/test_descriptor/lib/src/directory_descriptor.dart b/pkgs/test_descriptor/lib/src/directory_descriptor.dart index 1a8fe6501..092766788 100644 --- a/pkgs/test_descriptor/lib/src/directory_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/directory_descriptor.dart @@ -52,18 +52,18 @@ class DirectoryDescriptor extends Descriptor { } // Ignore broken symlinks. return null; - }).where((path) => path != null)); + }).whereType()); } @override - Future create([String parent]) async { + Future create([String? parent]) async { var fullPath = p.join(parent ?? sandbox, name); await Directory(fullPath).create(recursive: true); await Future.wait(contents.map((entry) => entry.create(fullPath))); } @override - Future validate([String parent]) async { + Future validate([String? parent]) async { var fullPath = p.join(parent ?? sandbox, name); if (!(await Directory(fullPath).exists())) { fail('Directory not found: "${prettyPath(fullPath)}".'); @@ -80,7 +80,7 @@ class DirectoryDescriptor extends Descriptor { /// The [parents] parameter should only be passed by subclasses of /// [DirectoryDescriptor] that are recursively calling [load]. It's the /// URL-format path of the directories that have been loaded so far. - Stream> load(url, [String parents]) { + Stream> load(url, [String? parents]) { String path; if (url is String) { path = url; diff --git a/pkgs/test_descriptor/lib/src/file_descriptor.dart b/pkgs/test_descriptor/lib/src/file_descriptor.dart index 3d634b670..f5d921619 100644 --- a/pkgs/test_descriptor/lib/src/file_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/file_descriptor.dart @@ -60,7 +60,7 @@ abstract class FileDescriptor extends Descriptor { FileDescriptor.protected(String name) : super(name); @override - Future create([String parent]) async { + Future create([String? parent]) async { // Create the stream before we call [File.openWrite] because it may fail // fast (e.g. if this is a matcher file). var file = File(p.join(parent ?? sandbox, name)).openWrite(); @@ -72,7 +72,7 @@ abstract class FileDescriptor extends Descriptor { } @override - Future validate([String parent]) async { + Future validate([String? parent]) async { var fullPath = p.join(parent ?? sandbox, name); var pretty = prettyPath(fullPath); if (!(await File(fullPath).exists())) { @@ -87,7 +87,7 @@ abstract class FileDescriptor extends Descriptor { /// /// The [prettyPath] is a human-friendly representation of the path to the /// descriptor. - Future _validate(String prettyPath, List binaryContents); + FutureOr _validate(String prettyPath, List binaryContents); /// Reads and decodes the contents of this descriptor as a UTF-8 string. /// @@ -113,8 +113,8 @@ class _BinaryFileDescriptor extends FileDescriptor { Stream> readAsBytes() => Stream.fromIterable([_contents]); @override - Future _validate(String prettPath, List actualContents) async { - if (const IterableEquality().equals(_contents, actualContents)) return null; + Future _validate(String prettPath, List actualContents) async { + if (const IterableEquality().equals(_contents, actualContents)) return; // TODO(nweiz): show a hex dump here if the data is small enough. fail('File "$prettPath" didn\'t contain the expected binary data.'); } @@ -134,9 +134,9 @@ class _StringFileDescriptor extends FileDescriptor { Stream.fromIterable([utf8.encode(_contents)]); @override - Future _validate(String prettyPath, List actualContents) { + void _validate(String prettyPath, List actualContents) { var actualContentsText = utf8.decode(actualContents); - if (_contents == actualContentsText) return null; + if (_contents == actualContentsText) return; fail(_textMismatchMessage(prettyPath, _contents, actualContentsText)); } @@ -194,7 +194,7 @@ class _MatcherFileDescriptor extends FileDescriptor { throw UnsupportedError("Matcher files can't be created or read."); @override - Future _validate(String prettyPath, List actualContents) async { + Future _validate(String prettyPath, List actualContents) async { try { expect( _isBinary ? actualContents : utf8.decode(actualContents), _matcher); diff --git a/pkgs/test_descriptor/lib/src/nothing_descriptor.dart b/pkgs/test_descriptor/lib/src/nothing_descriptor.dart index e70e890ee..22e7bc8c1 100644 --- a/pkgs/test_descriptor/lib/src/nothing_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/nothing_descriptor.dart @@ -18,10 +18,10 @@ class NothingDescriptor extends Descriptor { NothingDescriptor(String name) : super(name); @override - Future create([String parent]) async {} + Future create([String? parent]) async {} @override - Future validate([String parent]) async { + Future validate([String? parent]) async { var fullPath = p.join(parent ?? sandbox, name); var pretty = prettyPath(fullPath); if (File(fullPath).existsSync()) { diff --git a/pkgs/test_descriptor/lib/src/pattern_descriptor.dart b/pkgs/test_descriptor/lib/src/pattern_descriptor.dart index 4c1760dea..ed1b556a9 100644 --- a/pkgs/test_descriptor/lib/src/pattern_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/pattern_descriptor.dart @@ -41,7 +41,7 @@ class PatternDescriptor extends Descriptor { /// in the constructor and validates the result. If exactly one succeeds, /// `this` is considered valid. @override - Future validate([String parent]) async { + Future validate([String? parent]) async { var inSandbox = parent == null; parent ??= sandbox; var matchingEntries = await Directory(parent) @@ -57,19 +57,22 @@ class PatternDescriptor extends Descriptor { fail('No entries found in $location matching $_patternDescription.'); } - var results = await Future.wait(matchingEntries.map((entry) { - var basename = p.basename(entry); - return runZonedGuarded(() { - return Result.capture(Future.sync(() async { - await _fn(basename).validate(parent); - return basename; - })); - }, (_, __) { - // Validate may produce multiple errors, but we ignore all but the first - // to avoid cluttering the user with many different errors from many - // different un-matched entries. - }); - }).toList()); + var results = await Future.wait(matchingEntries + .map((entry) { + var basename = p.basename(entry); + return runZonedGuarded(() { + return Result.capture(Future.sync(() async { + await _fn(basename).validate(parent); + return basename; + })); + }, (_, __) { + // Validate may produce multiple errors, but we ignore all but the first + // to avoid cluttering the user with many different errors from many + // different un-matched entries. + }); + }) + .whereType>>() + .toList()); var successes = results.where((result) => result.isValue).toList(); if (successes.isEmpty) { @@ -77,7 +80,7 @@ class PatternDescriptor extends Descriptor { } else if (successes.length > 1) { fail('Multiple valid entries found in $location matching ' '$_patternDescription:\n' - '${bullet(successes.map((result) => result.asValue.value))}'); + '${bullet(successes.map((result) => result.asValue!.value))}'); } } @@ -96,7 +99,7 @@ class PatternDescriptor extends Descriptor { } @override - Future create([String parent]) { + Future create([String? parent]) { throw UnsupportedError("Pattern descriptors don't support create()."); } } diff --git a/pkgs/test_descriptor/lib/src/sandbox.dart b/pkgs/test_descriptor/lib/src/sandbox.dart index a09145ee4..1f5847f02 100644 --- a/pkgs/test_descriptor/lib/src/sandbox.dart +++ b/pkgs/test_descriptor/lib/src/sandbox.dart @@ -13,23 +13,23 @@ import 'package:test/test.dart'; /// created the first time [sandbox] is accessed for each test case, and /// automatically deleted after the test finishes running. String get sandbox { - if (_sandbox != null) return _sandbox; + if (_sandbox != null) return _sandbox!; // Resolve symlinks so we don't end up with inconsistent paths on Mac OS where // /tmp is symlinked. - _sandbox = Directory.systemTemp + var sandbox = _sandbox = Directory.systemTemp .createTempSync('dart_test_') .resolveSymbolicLinksSync(); addTearDown(() async { - var sandbox = _sandbox; + var sandbox = _sandbox!; _sandbox = null; await Directory(sandbox).delete(recursive: true); }); - return _sandbox; + return sandbox; } -String _sandbox; +String? _sandbox; /// Whether [sandbox] has been created. bool get sandboxExists => _sandbox != null; diff --git a/pkgs/test_descriptor/lib/src/utils.dart b/pkgs/test_descriptor/lib/src/utils.dart index 85d339f6c..d9d80173e 100644 --- a/pkgs/test_descriptor/lib/src/utils.dart +++ b/pkgs/test_descriptor/lib/src/utils.dart @@ -54,10 +54,10 @@ String describeDirectory(String name, List contents) { /// only a single line; otherwise, [first], [last], or [prefix] is used, in that /// order of precedence. String prefixLines(String text, String prefix, - {String first, String last, String single}) { + {String? first, String? last, String? single}) { + single ??= first ?? last ?? prefix; first ??= prefix; last ??= prefix; - single ??= first ?? last ?? prefix; var lines = text.split('\n'); if (lines.length == 1) return '$single$text'; @@ -94,10 +94,10 @@ Future> waitAndReportErrors(Iterable> futures) { return Future.wait(futures.map((future) { // Avoid async/await so that we synchronously add error handlers for the // futures to keep them from top-leveling. - return future.catchError((error, StackTrace stackTrace) { + return future.catchError((Object error, StackTrace stackTrace) { if (!errored) { errored = true; - throw error; + throw error; // ignore: only_throw_errors } else { registerException(error, stackTrace); } diff --git a/pkgs/test_descriptor/lib/test_descriptor.dart b/pkgs/test_descriptor/lib/test_descriptor.dart index 343a2747d..cf5e07fdb 100644 --- a/pkgs/test_descriptor/lib/test_descriptor.dart +++ b/pkgs/test_descriptor/lib/test_descriptor.dart @@ -5,7 +5,6 @@ import 'package:path/path.dart' as p; import 'package:test/test.dart'; -import 'src/archive_descriptor.dart'; import 'src/descriptor.dart'; import 'src/directory_descriptor.dart'; import 'src/file_descriptor.dart'; @@ -13,7 +12,6 @@ import 'src/nothing_descriptor.dart'; import 'src/pattern_descriptor.dart'; import 'src/sandbox.dart'; -export 'src/archive_descriptor.dart'; export 'src/descriptor.dart'; export 'src/directory_descriptor.dart'; export 'src/file_descriptor.dart'; @@ -42,7 +40,7 @@ FileDescriptor file(String name, [contents]) => FileDescriptor(name, contents); /// children of the physical diretory, but it *doesn't* require that no other /// children exist. To ensure that a particular child doesn't exist, use /// [nothing]. -DirectoryDescriptor dir(String name, [Iterable contents]) => +DirectoryDescriptor dir(String name, [Iterable? contents]) => DirectoryDescriptor(name, contents ?? []); /// Creates a new [NothingDescriptor] descriptor that asserts that no entry @@ -72,21 +70,8 @@ PatternDescriptor filePattern(Pattern name, [contents]) => /// A convenience method for creating a [PatternDescriptor] descriptor that /// constructs a [DirectoryDescriptor] descriptor. -PatternDescriptor dirPattern(Pattern name, [Iterable contents]) => +PatternDescriptor dirPattern(Pattern name, [Iterable? contents]) => pattern(name, (realName) => dir(realName, contents)); -/// Creates a new [ArchiveDescriptor] with [name] and [contents]. -/// -/// [Descriptor.create] creates an archive with the given files and directories -/// within it, and [Descriptor.validate] validates that the archive contains the -/// given contents. It *doesn't* require that no other children exist. To ensure -/// that a particular child doesn't exist, use [nothing]. -/// -/// The type of the archive is determined by [name]'s file extension. It -/// supports `.zip`, `.tar`, `.tar.gz`/`.tar.gzip`/`.tgz`, and -/// `.tar.bz2`/`.tar.bzip2` files. -ArchiveDescriptor archive(String name, [Iterable contents]) => - ArchiveDescriptor(name, contents ?? []); - /// Returns [path] within the [sandbox] directory. String path(String path) => p.join(sandbox, path); diff --git a/pkgs/test_descriptor/pubspec.yaml b/pkgs/test_descriptor/pubspec.yaml index 290888f5c..8ebd7852b 100644 --- a/pkgs/test_descriptor/pubspec.yaml +++ b/pkgs/test_descriptor/pubspec.yaml @@ -1,20 +1,19 @@ name: test_descriptor -version: 1.2.1-dev +version: 2.0.0-nullsafety description: An API for defining and verifying directory structures. homepage: https://github.com/dart-lang/test_descriptor environment: - sdk: '>=2.8.1 <3.0.0' + sdk: '>=2.12.0-0 <3.0.0' dependencies: - archive: '^2.0.0' - async: '>=1.13.0 <3.0.0' - collection: '^1.5.0' - matcher: '^0.12.0' - meta: '^1.1.7' - path: '^1.0.0' - test: '^1.6.0' - term_glyph: '^1.0.0' + async: ^2.5.0-nullsafety + collection: ^1.15.0-nullsafety + matcher: ^0.12.10-nullsafety + meta: ^1.3.0-nullsafety + path: ^1.8.0-nullsafety + term_glyph: ^ 1.2.0-nullsafety + test: ^1.16.0-nullsafety dev_dependencies: - pedantic: ^1.0.0 + pedantic: ^1.10.0-nullsafety diff --git a/pkgs/test_descriptor/test/archive_test.dart b/pkgs/test_descriptor/test/archive_test.dart deleted file mode 100644 index 751afdcf7..000000000 --- a/pkgs/test_descriptor/test/archive_test.dart +++ /dev/null @@ -1,281 +0,0 @@ -// Copyright (c) 2019, 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. - -@TestOn('vm') - -import 'dart:convert'; -import 'dart:io'; - -import 'package:archive/archive.dart'; -import 'package:async/async.dart'; -import 'package:path/path.dart' as p; -import 'package:test/test.dart'; -import 'package:test_descriptor/test_descriptor.dart' as d; - -import 'utils.dart'; - -void main() { - group('create()', () { - test('creates an empty archive', () async { - await d.archive('test.tar').create(); - - var archive = - TarDecoder().decodeBytes(File(d.path('test.tar')).readAsBytesSync()); - expect(archive.files, isEmpty); - }); - - test('creates an archive with files', () async { - await d.archive('test.tar', [ - d.file('file1.txt', 'contents 1'), - d.file('file2.txt', 'contents 2') - ]).create(); - - var files = TarDecoder() - .decodeBytes(File(d.path('test.tar')).readAsBytesSync()) - .files; - expect(files.length, equals(2)); - _expectFile(files[0], 'file1.txt', 'contents 1'); - _expectFile(files[1], 'file2.txt', 'contents 2'); - }); - - test('creates an archive with files in a directory', () async { - await d.archive('test.tar', [ - d.dir('dir', [ - d.file('file1.txt', 'contents 1'), - d.file('file2.txt', 'contents 2') - ]) - ]).create(); - - var files = TarDecoder() - .decodeBytes(File(d.path('test.tar')).readAsBytesSync()) - .files; - expect(files.length, equals(2)); - _expectFile(files[0], 'dir/file1.txt', 'contents 1'); - _expectFile(files[1], 'dir/file2.txt', 'contents 2'); - }); - - test('creates an archive with files in a nested directory', () async { - await d.archive('test.tar', [ - d.dir('dir', [ - d.dir('subdir', [ - d.file('file1.txt', 'contents 1'), - d.file('file2.txt', 'contents 2') - ]) - ]) - ]).create(); - - var files = TarDecoder() - .decodeBytes(File(d.path('test.tar')).readAsBytesSync()) - .files; - expect(files.length, equals(2)); - _expectFile(files[0], 'dir/subdir/file1.txt', 'contents 1'); - _expectFile(files[1], 'dir/subdir/file2.txt', 'contents 2'); - }); - - group('creates a file in', () { - test('zip format', () async { - await d.archive('test.zip', [d.file('file.txt', 'contents')]).create(); - - var archive = ZipDecoder() - .decodeBytes(File(d.path('test.zip')).readAsBytesSync()); - _expectFile(archive.files.single, 'file.txt', 'contents'); - }); - - group('gzip tar format', () { - for (var extension in ['.tar.gz', '.tar.gzip', '.tgz']) { - test('with $extension', () async { - await d.archive( - 'test$extension', [d.file('file.txt', 'contents')]).create(); - - var archive = TarDecoder().decodeBytes(GZipDecoder() - .decodeBytes(File(d.path('test$extension')).readAsBytesSync())); - _expectFile(archive.files.single, 'file.txt', 'contents'); - }); - } - }); - - group('bzip2 tar format', () { - for (var extension in ['.tar.bz2', '.tar.bzip2']) { - test('with $extension', () async { - await d.archive( - 'test$extension', [d.file('file.txt', 'contents')]).create(); - - var archive = TarDecoder().decodeBytes(BZip2Decoder() - .decodeBytes(File(d.path('test$extension')).readAsBytesSync())); - _expectFile(archive.files.single, 'file.txt', 'contents'); - }); - } - }); - }); - - group('gracefully rejects', () { - test('an uncreatable descriptor', () async { - await expectLater( - d.archive('test.tar', [d.filePattern(RegExp(r'^foo-'))]).create(), - throwsUnsupportedError); - await d.nothing('test.tar').validate(); - }); - - test('a non-file non-directory descriptor', () async { - await expectLater( - d.archive('test.tar', [d.nothing('file.txt')]).create(), - throwsUnsupportedError); - await d.nothing('test.tar').validate(); - }); - - test('an unknown file extension', () async { - await expectLater( - d.archive('test.asdf', [d.nothing('file.txt')]).create(), - throwsUnsupportedError); - }); - }); - }); - - group('validate()', () { - group('with an empty archive', () { - test('succeeds if an empty archive exists', () async { - File(d.path('test.tar')) - .writeAsBytesSync(TarEncoder().encode(Archive())); - await d.archive('test.tar').validate(); - }); - - test('succeeds if a non-empty archive exists', () async { - File(d.path('test.tar')).writeAsBytesSync( - TarEncoder().encode(Archive()..addFile(_file('file.txt')))); - await d.archive('test.tar').validate(); - }); - - test('fails if no archive exists', () { - expect(d.archive('test.tar').validate(), - throwsA(toString(startsWith('File not found: "test.tar".')))); - }); - - test('fails if an invalid archive exists', () { - d.file('test.tar', 'not a valid tar file').create(); - expect( - d.archive('test.tar').validate(), - throwsA(toString( - startsWith('File "test.tar" is not a valid archive.')))); - }); - }); - - test('succeeds if an archive contains a matching file', () async { - File(d.path('test.tar')).writeAsBytesSync(TarEncoder() - .encode(Archive()..addFile(_file('file.txt', 'contents')))); - await d.archive('test.tar', [d.file('file.txt', 'contents')]).validate(); - }); - - test("fails if an archive doesn't contain a file", () async { - File(d.path('test.tar')).writeAsBytesSync(TarEncoder().encode(Archive())); - expect( - d.archive('test.tar', [d.file('file.txt', 'contents')]).validate(), - throwsA( - toString(startsWith('File not found: "test.tar/file.txt".')))); - }); - - test('fails if an archive contains a non-matching file', () async { - File(d.path('test.tar')).writeAsBytesSync(TarEncoder() - .encode(Archive()..addFile(_file('file.txt', 'wrong contents')))); - expect( - d.archive('test.tar', [d.file('file.txt', 'contents')]).validate(), - throwsA(toString( - startsWith('File "test.tar/file.txt" should contain:')))); - }); - - test('succeeds if an archive contains a file matching a pattern', () async { - File(d.path('test.tar')).writeAsBytesSync(TarEncoder() - .encode(Archive()..addFile(_file('file.txt', 'contents')))); - await d.archive('test.tar', - [d.filePattern(RegExp(r'f..e\.txt'), 'contents')]).validate(); - }); - - group('validates a file in', () { - test('zip format', () async { - File(d.path('test.zip')).writeAsBytesSync(ZipEncoder() - .encode(Archive()..addFile(_file('file.txt', 'contents')))); - - await d - .archive('test.zip', [d.file('file.txt', 'contents')]).validate(); - }); - - group('gzip tar format', () { - for (var extension in ['.tar.gz', '.tar.gzip', '.tgz']) { - test('with $extension', () async { - File(d.path('test$extension')).writeAsBytesSync(GZipEncoder() - .encode(TarEncoder().encode( - Archive()..addFile(_file('file.txt', 'contents'))))); - - await d.archive( - 'test$extension', [d.file('file.txt', 'contents')]).validate(); - }); - } - }); - - group('bzip2 tar format', () { - for (var extension in ['.tar.bz2', '.tar.bzip2']) { - test('with $extension', () async { - File(d.path('test$extension')).writeAsBytesSync(BZip2Encoder() - .encode(TarEncoder().encode( - Archive()..addFile(_file('file.txt', 'contents'))))); - - await d.archive( - 'test$extension', [d.file('file.txt', 'contents')]).validate(); - }); - } - }); - }); - - test('gracefully rejects an unknown file format', () { - expect(d.archive('test.asdf').validate(), throwsUnsupportedError); - }); - }); - - test('read() is unsupported', () { - expect(d.archive('test.tar').read(), throwsUnsupportedError); - }); - - test('readAsBytes() returns the contents of the archive', () async { - var descriptor = d.archive('test.tar', - [d.file('file1.txt', 'contents 1'), d.file('file2.txt', 'contents 2')]); - - var files = TarDecoder() - .decodeBytes(await collectBytes(descriptor.readAsBytes())) - .files; - expect(files.length, equals(2)); - _expectFile(files[0], 'file1.txt', 'contents 1'); - _expectFile(files[1], 'file2.txt', 'contents 2'); - }); - - test('archive returns the in-memory contents', () async { - var archive = await d.archive('test.tar', [ - d.file('file1.txt', 'contents 1'), - d.file('file2.txt', 'contents 2') - ]).archive; - - var files = archive.files; - expect(files.length, equals(2)); - _expectFile(files[0], 'file1.txt', 'contents 1'); - _expectFile(files[1], 'file2.txt', 'contents 2'); - }); - - test('io refers to the file within the sandbox', () { - expect(d.file('test.tar').io.path, equals(p.join(d.sandbox, 'test.tar'))); - }); -} - -/// Asserts that [file] has the given [name] and [contents]. -void _expectFile(ArchiveFile file, String name, String contents) { - expect(file.name, equals(name)); - expect(utf8.decode(file.content as List), equals(contents)); -} - -/// Creates an [ArchiveFile] with the given [name] and [contents]. -ArchiveFile _file(String name, [String contents]) { - var bytes = utf8.encode(contents ?? ''); - return ArchiveFile(name, bytes.length, bytes) - // Setting the mode and mod time are necessary to work around - // brendan-duncan/archive#76. - ..mode = 428 - ..lastModTime = DateTime.now().millisecondsSinceEpoch ~/ 1000; -} diff --git a/pkgs/test_descriptor/test/directory_test.dart b/pkgs/test_descriptor/test/directory_test.dart index e13508645..c669be832 100644 --- a/pkgs/test_descriptor/test/directory_test.dart +++ b/pkgs/test_descriptor/test/directory_test.dart @@ -211,7 +211,7 @@ void main() { }); group('describe()', () { - bool oldAscii; + late bool oldAscii; setUpAll(() { oldAscii = term_glyph.ascii; term_glyph.ascii = true; diff --git a/pkgs/test_descriptor/test/sandbox_test.dart b/pkgs/test_descriptor/test/sandbox_test.dart index f20a8ffe8..991bd7f41 100644 --- a/pkgs/test_descriptor/test/sandbox_test.dart +++ b/pkgs/test_descriptor/test/sandbox_test.dart @@ -17,7 +17,7 @@ void main() { }); test('the directory is deleted after the test', () { - String sandbox; + late String sandbox; addTearDown(() { expect(Directory(sandbox).existsSync(), isFalse); }); From 07879dd7a7c1d29f4219402a86894fd22cc317d3 Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Thu, 5 Nov 2020 12:42:08 -0800 Subject: [PATCH 26/72] clean up some apis (dart-lang/test_descriptor#30) - drop support for Uri objects in DirectoryDescriptor.load - Use Object? instead of dynamic for `FileDescriptor` contents parameter - Remove `parents` param in DirectoryDescriptor.load --- pkgs/test_descriptor/CHANGELOG.md | 4 ++++ .../lib/src/directory_descriptor.dart | 23 +++++-------------- .../lib/src/file_descriptor.dart | 2 +- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/pkgs/test_descriptor/CHANGELOG.md b/pkgs/test_descriptor/CHANGELOG.md index 2c2bc32d7..10a98c4b2 100644 --- a/pkgs/test_descriptor/CHANGELOG.md +++ b/pkgs/test_descriptor/CHANGELOG.md @@ -3,6 +3,10 @@ * Migrate to null safety. * Fix outdated URLs in `README.md`. * 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 diff --git a/pkgs/test_descriptor/lib/src/directory_descriptor.dart b/pkgs/test_descriptor/lib/src/directory_descriptor.dart index 092766788..a7e1d5865 100644 --- a/pkgs/test_descriptor/lib/src/directory_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/directory_descriptor.dart @@ -74,25 +74,14 @@ class DirectoryDescriptor extends Descriptor { } /// Treats this descriptor as a virtual filesystem and loads the binary - /// contents of the [FileDescriptor] at the given relative [url], which may be - /// a [Uri] or a [String]. - /// - /// The [parents] parameter should only be passed by subclasses of - /// [DirectoryDescriptor] that are recursively calling [load]. It's the - /// URL-format path of the directories that have been loaded so far. - Stream> load(url, [String? parents]) { - String path; - if (url is String) { - path = url; - } else if (url is Uri) { - path = url.toString(); - } else { - throw ArgumentError.value(url, 'url', 'must be a Uri or a String.'); - } + /// contents of the [FileDescriptor] at the given relative [path]. + Stream> load(String path) => _load(path); + /// Implementation of [load], tracks parents through recursive calls. + Stream> _load(String path, [String? parents]) { if (!p.url.isWithin('.', path)) { throw ArgumentError.value( - url, 'url', 'must be relative and beneath the base URL.'); + path, 'path', 'must be relative and beneath the base URL.'); } return StreamCompleter.fromFuture(Future.sync(() { @@ -117,7 +106,7 @@ class DirectoryDescriptor extends Descriptor { return (matchingEntries.first as FileDescriptor).readAsBytes(); } else { return (matchingEntries.first as DirectoryDescriptor) - .load(p.url.joinAll(remainingPath), parentsAndSelf); + ._load(p.url.joinAll(remainingPath), parentsAndSelf); } } })); diff --git a/pkgs/test_descriptor/lib/src/file_descriptor.dart b/pkgs/test_descriptor/lib/src/file_descriptor.dart index f5d921619..b9eae6e12 100644 --- a/pkgs/test_descriptor/lib/src/file_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/file_descriptor.dart @@ -35,7 +35,7 @@ abstract class FileDescriptor extends Descriptor { /// /// To match a [Matcher] against a file's binary contents, use [new /// FileDescriptor.binaryMatcher] instead. - factory FileDescriptor(String name, contents) { + factory FileDescriptor(String name, Object? contents) { if (contents is String) return _StringFileDescriptor(name, contents); if (contents is List) { return _BinaryFileDescriptor(name, contents.cast()); From a09855d159348519efb26525f20d2eec01f5c34a Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Thu, 5 Nov 2020 14:01:21 -0800 Subject: [PATCH 27/72] Remove unused dependency on package:meta (dart-lang/test_descriptor#31) --- pkgs/test_descriptor/CHANGELOG.md | 2 ++ pkgs/test_descriptor/pubspec.yaml | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/test_descriptor/CHANGELOG.md b/pkgs/test_descriptor/CHANGELOG.md index 10a98c4b2..43d374aa1 100644 --- a/pkgs/test_descriptor/CHANGELOG.md +++ b/pkgs/test_descriptor/CHANGELOG.md @@ -1,3 +1,5 @@ +## 2.0.0-nullsafety.1-dev + ## 2.0.0-nullsafety * Migrate to null safety. diff --git a/pkgs/test_descriptor/pubspec.yaml b/pkgs/test_descriptor/pubspec.yaml index 8ebd7852b..95bd7e161 100644 --- a/pkgs/test_descriptor/pubspec.yaml +++ b/pkgs/test_descriptor/pubspec.yaml @@ -1,5 +1,5 @@ name: test_descriptor -version: 2.0.0-nullsafety +version: 2.0.0-nullsafety.1-dev description: An API for defining and verifying directory structures. homepage: https://github.com/dart-lang/test_descriptor @@ -10,7 +10,6 @@ dependencies: async: ^2.5.0-nullsafety collection: ^1.15.0-nullsafety matcher: ^0.12.10-nullsafety - meta: ^1.3.0-nullsafety path: ^1.8.0-nullsafety term_glyph: ^ 1.2.0-nullsafety test: ^1.16.0-nullsafety From cb319bf7da33709e02bc9442d9437b548a034bc2 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Sat, 21 Nov 2020 19:15:28 -0800 Subject: [PATCH 28/72] Remove unused dart:async imports. (dart-lang/test_descriptor#32) As of Dart 2.1, Future/Stream have been exported from dart:core. --- pkgs/test_descriptor/lib/src/directory_descriptor.dart | 1 - pkgs/test_descriptor/lib/src/utils.dart | 1 - pkgs/test_descriptor/test/utils.dart | 2 -- 3 files changed, 4 deletions(-) diff --git a/pkgs/test_descriptor/lib/src/directory_descriptor.dart b/pkgs/test_descriptor/lib/src/directory_descriptor.dart index a7e1d5865..e4f7b80ce 100644 --- a/pkgs/test_descriptor/lib/src/directory_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/directory_descriptor.dart @@ -2,7 +2,6 @@ // 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:async'; import 'dart:io'; import 'package:async/async.dart'; diff --git a/pkgs/test_descriptor/lib/src/utils.dart b/pkgs/test_descriptor/lib/src/utils.dart index d9d80173e..26fd3ab64 100644 --- a/pkgs/test_descriptor/lib/src/utils.dart +++ b/pkgs/test_descriptor/lib/src/utils.dart @@ -2,7 +2,6 @@ // 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:async'; import 'dart:convert'; import 'package:path/path.dart' as p; diff --git a/pkgs/test_descriptor/test/utils.dart b/pkgs/test_descriptor/test/utils.dart index 3ea1e2996..5eb84f7d5 100644 --- a/pkgs/test_descriptor/test/utils.dart +++ b/pkgs/test_descriptor/test/utils.dart @@ -2,8 +2,6 @@ // 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:async'; - import 'package:test/test.dart'; /// Converts a [Stream>] to a flat byte future. From 6ea0b782c92c7de79344b8ee03593615d3e069e9 Mon Sep 17 00:00:00 2001 From: Alexander Thomas Date: Wed, 20 Jan 2021 16:34:10 +0100 Subject: [PATCH 29/72] Migrate to GitHub Actions (dart-lang/test_descriptor#33) * Delete .travis.yml --- .../.github/workflows/test-package.yml | 61 +++++++++++++++++++ pkgs/test_descriptor/.travis.yml | 22 ------- 2 files changed, 61 insertions(+), 22 deletions(-) create mode 100644 pkgs/test_descriptor/.github/workflows/test-package.yml delete mode 100644 pkgs/test_descriptor/.travis.yml diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml new file mode 100644 index 000000000..21a3c50b6 --- /dev/null +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -0,0 +1,61 @@ +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 + +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@v2 + - uses: dart-lang/setup-dart@v0.3 + 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: [dev] + steps: + - uses: actions/checkout@v2 + - uses: dart-lang/setup-dart@v0.3 + 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' diff --git a/pkgs/test_descriptor/.travis.yml b/pkgs/test_descriptor/.travis.yml deleted file mode 100644 index 502b3eb79..000000000 --- a/pkgs/test_descriptor/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: dart - -dart: - - dev - -dart_task: - - test - -matrix: - include: - - dart: dev - dart_task: dartfmt - - dart: dev - dart_task: - dartanalyzer: --fatal-infos --fatal-warnings . - -branches: - only: [master] - -cache: - directories: - - $HOME/.pub-cache From 6f4fcb0bcc03a67a422c1bd786b7367ee2b37727 Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Tue, 9 Feb 2021 12:14:52 -0800 Subject: [PATCH 30/72] stable null safety release (dart-lang/test_descriptor#34) --- pkgs/test_descriptor/CHANGELOG.md | 5 ++++- pkgs/test_descriptor/pubspec.yaml | 17 +++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/pkgs/test_descriptor/CHANGELOG.md b/pkgs/test_descriptor/CHANGELOG.md index 43d374aa1..594530d47 100644 --- a/pkgs/test_descriptor/CHANGELOG.md +++ b/pkgs/test_descriptor/CHANGELOG.md @@ -1,4 +1,7 @@ -## 2.0.0-nullsafety.1-dev +## 2.0.0 + +* Null safety stable release. +* See breaking changes in the `2.0.0-nullsafety` version. ## 2.0.0-nullsafety diff --git a/pkgs/test_descriptor/pubspec.yaml b/pkgs/test_descriptor/pubspec.yaml index 95bd7e161..8f8432362 100644 --- a/pkgs/test_descriptor/pubspec.yaml +++ b/pkgs/test_descriptor/pubspec.yaml @@ -1,5 +1,5 @@ name: test_descriptor -version: 2.0.0-nullsafety.1-dev +version: 2.0.0 description: An API for defining and verifying directory structures. homepage: https://github.com/dart-lang/test_descriptor @@ -7,12 +7,13 @@ environment: sdk: '>=2.12.0-0 <3.0.0' dependencies: - async: ^2.5.0-nullsafety - collection: ^1.15.0-nullsafety - matcher: ^0.12.10-nullsafety - path: ^1.8.0-nullsafety - term_glyph: ^ 1.2.0-nullsafety - test: ^1.16.0-nullsafety + async: ^2.5.0 + collection: ^1.15.0 + matcher: ^0.12.10 + meta: ^1.3.0 + path: ^1.8.0 + term_glyph: ^1.2.0 + test: ^1.16.0 dev_dependencies: - pedantic: ^1.10.0-nullsafety + pedantic: ^1.10.0 From 64f5c5169ced4955ff8c6a7a7d53110cd5115e61 Mon Sep 17 00:00:00 2001 From: Franklin Yow <58489007+franklinyow@users.noreply.github.com> Date: Wed, 31 Mar 2021 14:58:19 -0700 Subject: [PATCH 31/72] Update LICENSE (dart-lang/test_descriptor#35) Changes to comply to internal review --- pkgs/test_descriptor/LICENSE | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/test_descriptor/LICENSE b/pkgs/test_descriptor/LICENSE index 82e9b524a..237243134 100644 --- a/pkgs/test_descriptor/LICENSE +++ b/pkgs/test_descriptor/LICENSE @@ -1,4 +1,5 @@ -Copyright 2016, the Dart project authors. All rights reserved. +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: @@ -9,7 +10,7 @@ met: 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 Inc. nor the names of its + * 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. From 9f8f62bef6e282ab0932d2d3c1c9651cd8af0586 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Sat, 5 Jun 2021 12:54:00 -0700 Subject: [PATCH 32/72] Add dependabot --- pkgs/test_descriptor/.github/dependabot.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 pkgs/test_descriptor/.github/dependabot.yml diff --git a/pkgs/test_descriptor/.github/dependabot.yml b/pkgs/test_descriptor/.github/dependabot.yml new file mode 100644 index 000000000..430a85e7d --- /dev/null +++ b/pkgs/test_descriptor/.github/dependabot.yml @@ -0,0 +1,11 @@ +# Set update schedule for GitHub Actions +# See https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/keeping-your-actions-up-to-date-with-dependabot + +version: 2 +updates: + +- package-ecosystem: "github-actions" + directory: "/" + schedule: + # Check for updates to GitHub Actions every weekday + interval: "daily" From 81a712bc2e2515fa89dbcf54c41ff27bb3ec2e67 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 5 Jun 2021 13:01:25 -0700 Subject: [PATCH 33/72] Bump dart-lang/setup-dart from 0.3 to 1 (dart-lang/test_descriptor#36) * Bump dart-lang/setup-dart from 0.3 to 1 Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 0.3 to 1. - [Release notes](https://github.com/dart-lang/setup-dart/releases) - [Changelog](https://github.com/dart-lang/setup-dart/blob/main/CHANGELOG.md) - [Commits](https://github.com/dart-lang/setup-dart/compare/v0.3...v1) --- updated-dependencies: - dependency-name: dart-lang/setup-dart dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * Update test-package.yml Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Kevin Moore --- pkgs/test_descriptor/.github/workflows/test-package.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml index 21a3c50b6..cecfdde6f 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -23,7 +23,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v0.3 + - uses: dart-lang/setup-dart@v1 with: sdk: ${{ matrix.sdk }} - id: install @@ -47,10 +47,10 @@ jobs: matrix: # Add macos-latest and/or windows-latest if relevant for this package. os: [ubuntu-latest] - sdk: [dev] + sdk: [2.12.0, dev] steps: - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v0.3 + - uses: dart-lang/setup-dart@v1 with: sdk: ${{ matrix.sdk }} - id: install From f22b8ebf8339ba9c809dfedad8ee0a434845ca4b Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 4 Oct 2021 13:56:02 -0700 Subject: [PATCH 34/72] Migrate to pkg:lints, enable two disable lints (dart-lang/test_descriptor#38) Cleanup changelog --- pkgs/test_descriptor/CHANGELOG.md | 8 ++------ pkgs/test_descriptor/analysis_options.yaml | 14 ++++++-------- pkgs/test_descriptor/pubspec.yaml | 6 +++--- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/pkgs/test_descriptor/CHANGELOG.md b/pkgs/test_descriptor/CHANGELOG.md index 594530d47..017903817 100644 --- a/pkgs/test_descriptor/CHANGELOG.md +++ b/pkgs/test_descriptor/CHANGELOG.md @@ -1,12 +1,8 @@ +## 2.0.1-dev + ## 2.0.0 * Null safety stable release. -* See breaking changes in the `2.0.0-nullsafety` version. - -## 2.0.0-nullsafety - -* Migrate to null safety. -* Fix outdated URLs in `README.md`. * BREAKING: Removed archive support. * BREAKING: `DirectoryDescriptor.load` only supports a `String` path instead of also accepting relative `Uri` objects. diff --git a/pkgs/test_descriptor/analysis_options.yaml b/pkgs/test_descriptor/analysis_options.yaml index 1384ade90..56bbaad30 100644 --- a/pkgs/test_descriptor/analysis_options.yaml +++ b/pkgs/test_descriptor/analysis_options.yaml @@ -1,15 +1,13 @@ -include: package:pedantic/analysis_options.yaml +include: package:lints/recommended.yaml + analyzer: strong-mode: implicit-casts: false - errors: - unused_element: error - unused_import: error - unused_local_variable: error - dead_code: error + linter: rules: - #- annotate_overrides + - annotate_overrides + - avoid_dynamic_calls - avoid_function_literals_in_foreach_calls - avoid_init_to_null - avoid_null_checks_in_equality_operators @@ -49,7 +47,7 @@ linter: - prefer_generic_function_type_aliases - prefer_initializing_formals - prefer_interpolation_to_compose_strings - #- prefer_single_quotes + - prefer_single_quotes - prefer_typing_uninitialized_variables - slash_for_doc_comments - test_types_in_equals diff --git a/pkgs/test_descriptor/pubspec.yaml b/pkgs/test_descriptor/pubspec.yaml index 8f8432362..cffa641ff 100644 --- a/pkgs/test_descriptor/pubspec.yaml +++ b/pkgs/test_descriptor/pubspec.yaml @@ -1,10 +1,10 @@ name: test_descriptor -version: 2.0.0 +version: 2.0.1-dev description: An API for defining and verifying directory structures. homepage: https://github.com/dart-lang/test_descriptor environment: - sdk: '>=2.12.0-0 <3.0.0' + sdk: '>=2.12.0 <3.0.0' dependencies: async: ^2.5.0 @@ -16,4 +16,4 @@ dependencies: test: ^1.16.0 dev_dependencies: - pedantic: ^1.10.0 + lints: ^1.0.0 From d34b480ee12f1ebdc6bd9f4f2ef77588450d4e51 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Mar 2022 11:13:45 -0800 Subject: [PATCH 35/72] Bump actions/checkout from 2 to 3 (dart-lang/test_descriptor#39) Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/test_descriptor/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml index cecfdde6f..6c7108d86 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -22,7 +22,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: dart-lang/setup-dart@v1 with: sdk: ${{ matrix.sdk }} @@ -49,7 +49,7 @@ jobs: os: [ubuntu-latest] sdk: [2.12.0, dev] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: dart-lang/setup-dart@v1 with: sdk: ${{ matrix.sdk }} From 1b703a622e31ebf0edfac3075aad79507952b089 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Tue, 3 May 2022 15:16:32 -0700 Subject: [PATCH 36/72] populate the repository field (dart-lang/test_descriptor#40) --- pkgs/test_descriptor/CHANGELOG.md | 3 +++ pkgs/test_descriptor/pubspec.yaml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/test_descriptor/CHANGELOG.md b/pkgs/test_descriptor/CHANGELOG.md index 017903817..9604b3bca 100644 --- a/pkgs/test_descriptor/CHANGELOG.md +++ b/pkgs/test_descriptor/CHANGELOG.md @@ -1,5 +1,8 @@ ## 2.0.1-dev +* Populate the pubspec `repository` field. +* Migrate to `package:lints`. + ## 2.0.0 * Null safety stable release. diff --git a/pkgs/test_descriptor/pubspec.yaml b/pkgs/test_descriptor/pubspec.yaml index cffa641ff..9fa3dc325 100644 --- a/pkgs/test_descriptor/pubspec.yaml +++ b/pkgs/test_descriptor/pubspec.yaml @@ -1,7 +1,7 @@ name: test_descriptor version: 2.0.1-dev description: An API for defining and verifying directory structures. -homepage: https://github.com/dart-lang/test_descriptor +repository: https://github.com/dart-lang/test_descriptor environment: sdk: '>=2.12.0 <3.0.0' From c4a9f9c336ffc3dee8f6d3f7b9050f64995b8190 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Tue, 24 May 2022 10:59:55 -0700 Subject: [PATCH 37/72] Move TestOn annotation to library level (dart-lang/test_descriptor#41) These annotations are only read at the library level. The next version of the test package configures the `Target` for this annotation so the analyzer will raise diagnostics for these incorrect usages. --- pkgs/test_descriptor/test/file_test.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/test_descriptor/test/file_test.dart b/pkgs/test_descriptor/test/file_test.dart index 8b111f965..13b7597d6 100644 --- a/pkgs/test_descriptor/test/file_test.dart +++ b/pkgs/test_descriptor/test/file_test.dart @@ -2,8 +2,9 @@ // 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:convert'; @TestOn('vm') + +import 'dart:convert'; import 'dart:io'; import 'package:path/path.dart' as p; From 068bd47643d421e017e48da6620890833b0ac9b8 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Mon, 25 Jul 2022 13:25:51 -0700 Subject: [PATCH 38/72] Remove deprecated experimental invariant_booleans lint rule (dart-lang/test_descriptor#42) --- pkgs/test_descriptor/analysis_options.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/test_descriptor/analysis_options.yaml b/pkgs/test_descriptor/analysis_options.yaml index 56bbaad30..200a3d43c 100644 --- a/pkgs/test_descriptor/analysis_options.yaml +++ b/pkgs/test_descriptor/analysis_options.yaml @@ -26,7 +26,6 @@ linter: - empty_statements - hash_and_equals - implementation_imports - - invariant_booleans - iterable_contains_unrelated_type - library_names - library_prefixes From 25339efd224784ce79c58b487fa55ae9bbeaf8f8 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Fri, 29 Jul 2022 16:03:53 -0700 Subject: [PATCH 39/72] Add permission key to CI (dart-lang/test_descriptor#43) --- pkgs/test_descriptor/.github/workflows/test-package.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml index 6c7108d86..79d875784 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -11,6 +11,7 @@ on: env: PUB_ENVIRONMENT: bot.github +permissions: read-all jobs: # Check code formatting and static analysis on a single OS (linux) From 7f94d3ba1cf9f3ceaa1ba1e02c0c6c905eccf90c Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Fri, 7 Oct 2022 15:51:47 -0700 Subject: [PATCH 40/72] update the CI configuration; prep for publishing (dart-lang/test_descriptor#44) --- pkgs/test_descriptor/.github/dependabot.yml | 15 ++++++--------- .../.github/workflows/test-package.yml | 9 +++++---- pkgs/test_descriptor/CHANGELOG.md | 3 ++- pkgs/test_descriptor/README.md | 6 ++++++ pkgs/test_descriptor/pubspec.yaml | 2 +- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/pkgs/test_descriptor/.github/dependabot.yml b/pkgs/test_descriptor/.github/dependabot.yml index 430a85e7d..214481934 100644 --- a/pkgs/test_descriptor/.github/dependabot.yml +++ b/pkgs/test_descriptor/.github/dependabot.yml @@ -1,11 +1,8 @@ -# Set update schedule for GitHub Actions -# See https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/keeping-your-actions-up-to-date-with-dependabot - +# Dependabot configuration file. version: 2 -updates: -- package-ecosystem: "github-actions" - directory: "/" - schedule: - # Check for updates to GitHub Actions every weekday - interval: "daily" +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml index 79d875784..38089b6b7 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -11,6 +11,7 @@ on: env: PUB_ENVIRONMENT: bot.github + permissions: read-all jobs: @@ -23,8 +24,8 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@v3 - - uses: dart-lang/setup-dart@v1 + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} - id: install @@ -50,8 +51,8 @@ jobs: os: [ubuntu-latest] sdk: [2.12.0, dev] steps: - - uses: actions/checkout@v3 - - uses: dart-lang/setup-dart@v1 + - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} - id: install diff --git a/pkgs/test_descriptor/CHANGELOG.md b/pkgs/test_descriptor/CHANGELOG.md index 9604b3bca..abe849ae6 100644 --- a/pkgs/test_descriptor/CHANGELOG.md +++ b/pkgs/test_descriptor/CHANGELOG.md @@ -1,7 +1,8 @@ -## 2.0.1-dev +## 2.0.1 * Populate the pubspec `repository` field. * Migrate to `package:lints`. +* Update the package's markdown badges. ## 2.0.0 diff --git a/pkgs/test_descriptor/README.md b/pkgs/test_descriptor/README.md index d20100488..94422ea21 100644 --- a/pkgs/test_descriptor/README.md +++ b/pkgs/test_descriptor/README.md @@ -1,6 +1,12 @@ +[![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 diff --git a/pkgs/test_descriptor/pubspec.yaml b/pkgs/test_descriptor/pubspec.yaml index 9fa3dc325..0f3836c67 100644 --- a/pkgs/test_descriptor/pubspec.yaml +++ b/pkgs/test_descriptor/pubspec.yaml @@ -1,5 +1,5 @@ name: test_descriptor -version: 2.0.1-dev +version: 2.0.1 description: An API for defining and verifying directory structures. repository: https://github.com/dart-lang/test_descriptor From fc7b4ec6b40b5e328945d59ee43f7a5461fbeb90 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 7 Nov 2022 08:13:29 -0800 Subject: [PATCH 41/72] update lints (dart-lang/test_descriptor#45) --- .../.github/workflows/test-package.yml | 2 +- pkgs/test_descriptor/CHANGELOG.md | 2 + pkgs/test_descriptor/README.md | 23 +- pkgs/test_descriptor/analysis_options.yaml | 75 +++--- pkgs/test_descriptor/example/example.dart | 25 ++ .../lib/src/directory_descriptor.dart | 90 ++++--- .../lib/src/file_descriptor.dart | 43 +-- .../lib/src/nothing_descriptor.dart | 6 +- .../lib/src/pattern_descriptor.dart | 60 ++--- pkgs/test_descriptor/lib/src/sandbox.dart | 4 +- pkgs/test_descriptor/lib/src/utils.dart | 74 ++++-- pkgs/test_descriptor/lib/test_descriptor.dart | 13 +- pkgs/test_descriptor/pubspec.yaml | 10 +- pkgs/test_descriptor/test/directory_test.dart | 246 +++++++++++------- pkgs/test_descriptor/test/file_test.dart | 107 +++++--- pkgs/test_descriptor/test/nothing_test.dart | 36 ++- pkgs/test_descriptor/test/pattern_test.dart | 38 ++- pkgs/test_descriptor/test/utils.dart | 24 +- 18 files changed, 531 insertions(+), 347 deletions(-) create mode 100644 pkgs/test_descriptor/example/example.dart diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml index 38089b6b7..0de63d5de 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -49,7 +49,7 @@ jobs: matrix: # Add macos-latest and/or windows-latest if relevant for this package. os: [ubuntu-latest] - sdk: [2.12.0, dev] + sdk: [2.17.0, dev] steps: - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d diff --git a/pkgs/test_descriptor/CHANGELOG.md b/pkgs/test_descriptor/CHANGELOG.md index abe849ae6..aad67bf35 100644 --- a/pkgs/test_descriptor/CHANGELOG.md +++ b/pkgs/test_descriptor/CHANGELOG.md @@ -1,3 +1,5 @@ +## 2.0.2-dev + ## 2.0.1 * Populate the pubspec `repository` field. diff --git a/pkgs/test_descriptor/README.md b/pkgs/test_descriptor/README.md index 94422ea21..d50e77667 100644 --- a/pkgs/test_descriptor/README.md +++ b/pkgs/test_descriptor/README.md @@ -21,25 +21,22 @@ define a filesystem structure that can be created using ```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") - ]) + test('Directory.rename', () async { + await d.dir('parent', [ + d.file('sibling', 'sibling-contents'), + d.dir('old-name', [d.file('child', 'child-contents')]) ]).create(); - await new Directory("${d.sandbox}/parent/old-name") - .rename("${d.sandbox}/parent/new-name"); + 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") - ]) + await d.dir('parent', [ + d.file('sibling', 'sibling-contents'), + d.dir('new-name', [d.file('child', 'child-contents')]) ]).validate(); }); } diff --git a/pkgs/test_descriptor/analysis_options.yaml b/pkgs/test_descriptor/analysis_options.yaml index 200a3d43c..7806fc093 100644 --- a/pkgs/test_descriptor/analysis_options.yaml +++ b/pkgs/test_descriptor/analysis_options.yaml @@ -1,62 +1,57 @@ +# https://dart.dev/guides/language/analysis-options include: package:lints/recommended.yaml analyzer: - strong-mode: - implicit-casts: false + language: + strict-casts: true + strict-inference: true + strict-raw-types: true linter: rules: - - annotate_overrides + - always_declare_return_types + - avoid_bool_literals_in_conditional_expressions + - avoid_catching_errors + - avoid_classes_with_only_static_members - avoid_dynamic_calls - - avoid_function_literals_in_foreach_calls - - avoid_init_to_null - - avoid_null_checks_in_equality_operators - - avoid_relative_lib_imports + - avoid_private_typedef_functions + - avoid_redundant_argument_values - avoid_returning_null + - avoid_returning_null_for_future + - avoid_returning_this - avoid_unused_constructor_parameters - - await_only_futures - - camel_case_types + - avoid_void_async - cancel_subscriptions - comment_references - - constant_identifier_names - - control_flow_in_finally - directives_ordering - - empty_catches - - empty_constructor_bodies - - empty_statements - - hash_and_equals - - implementation_imports - - iterable_contains_unrelated_type - - library_names - - library_prefixes - - list_remove_unrelated_type + - join_return_with_assignment + - lines_longer_than_80_chars + - literal_only_boolean_expressions + - missing_whitespace_between_adjacent_strings - no_adjacent_strings_in_list - - non_constant_identifier_names + - no_runtimeType_toString - omit_local_variable_types - only_throw_errors - - overridden_fields - package_api_docs - - package_names - - package_prefixed_library_names - - prefer_adjacent_string_concatenation - - prefer_collection_literals - - prefer_conditional_assignment + - prefer_asserts_in_initializer_lists - prefer_const_constructors - - prefer_final_fields - - prefer_generic_function_type_aliases - - prefer_initializing_formals - - prefer_interpolation_to_compose_strings + - prefer_const_declarations + - prefer_expression_function_bodies + - prefer_final_locals + - prefer_relative_imports - prefer_single_quotes - - prefer_typing_uninitialized_variables - - slash_for_doc_comments + - sort_pub_dependencies - test_types_in_equals - throw_in_finally - - type_init_formals - - unnecessary_brace_in_string_interps - - unnecessary_const - - unnecessary_getters_setters + - type_annotate_public_apis + - unawaited_futures + - unnecessary_await_in_return - unnecessary_lambdas - - unnecessary_new - - unnecessary_null_aware_assignments + - unnecessary_parenthesis + - unnecessary_raw_strings - unnecessary_statements - - unnecessary_this + - use_if_null_to_convert_nulls_to_bools + - use_raw_strings + - use_string_buffers + - use_super_parameters + - require_trailing_commas diff --git a/pkgs/test_descriptor/example/example.dart b/pkgs/test_descriptor/example/example.dart new file mode 100644 index 000000000..ef5917ed1 --- /dev/null +++ b/pkgs/test_descriptor/example/example.dart @@ -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(); + }); +} diff --git a/pkgs/test_descriptor/lib/src/directory_descriptor.dart b/pkgs/test_descriptor/lib/src/directory_descriptor.dart index e4f7b80ce..c4f269452 100644 --- a/pkgs/test_descriptor/lib/src/directory_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/directory_descriptor.dart @@ -29,14 +29,13 @@ class DirectoryDescriptor extends Descriptor { /// [sandbox]. Directory get io => Directory(p.join(sandbox, name)); - DirectoryDescriptor(String name, Iterable contents) - : contents = contents.toList(), - super(name); + DirectoryDescriptor(super.name, Iterable contents) + : contents = contents.toList(); /// Creates a directory descriptor named [name] that describes the physical /// directory at [path]. - factory DirectoryDescriptor.fromFilesystem(String name, String path) { - return DirectoryDescriptor( + factory DirectoryDescriptor.fromFilesystem(String name, String path) => + DirectoryDescriptor( name, Directory(path).listSync().map((entity) { // Ignore hidden files. @@ -44,32 +43,37 @@ class DirectoryDescriptor extends Descriptor { if (entity is Directory) { return DirectoryDescriptor.fromFilesystem( - p.basename(entity.path), entity.path); + p.basename(entity.path), + entity.path, + ); } else if (entity is File) { return FileDescriptor( - p.basename(entity.path), entity.readAsBytesSync()); + p.basename(entity.path), + entity.readAsBytesSync(), + ); } // Ignore broken symlinks. return null; - }).whereType()); - } + }).whereType(), + ); @override Future create([String? parent]) async { - var fullPath = p.join(parent ?? sandbox, name); + final fullPath = p.join(parent ?? sandbox, name); await Directory(fullPath).create(recursive: true); await Future.wait(contents.map((entry) => entry.create(fullPath))); } @override Future validate([String? parent]) async { - var fullPath = p.join(parent ?? sandbox, name); + final fullPath = p.join(parent ?? sandbox, name); if (!(await Directory(fullPath).exists())) { fail('Directory not found: "${prettyPath(fullPath)}".'); } await waitAndReportErrors( - contents.map((entry) => entry.validate(fullPath))); + contents.map((entry) => entry.validate(fullPath)), + ); } /// Treats this descriptor as a virtual filesystem and loads the binary @@ -80,35 +84,47 @@ class DirectoryDescriptor extends Descriptor { Stream> _load(String path, [String? parents]) { if (!p.url.isWithin('.', path)) { throw ArgumentError.value( - path, 'path', 'must be relative and beneath the base URL.'); + path, + 'path', + 'must be relative and beneath the base URL.', + ); } - return StreamCompleter.fromFuture(Future.sync(() { - var split = p.url.split(p.url.normalize(path)); - var file = split.length == 1; - var matchingEntries = contents.where((entry) { - return entry.name == split.first && - (file ? entry is FileDescriptor : entry is DirectoryDescriptor); - }).toList(); - - var type = file ? 'file' : 'directory'; - var parentsAndSelf = parents == null ? name : p.url.join(parents, name); - if (matchingEntries.isEmpty) { - fail('Couldn\'t find a $type descriptor named "${split.first}" within ' - '"$parentsAndSelf".'); - } else if (matchingEntries.length > 1) { - fail('Found multiple $type descriptors named "${split.first}" within ' - '"$parentsAndSelf".'); - } else { - var remainingPath = split.sublist(1); - if (remainingPath.isEmpty) { - return (matchingEntries.first as FileDescriptor).readAsBytes(); + return StreamCompleter.fromFuture( + Future.sync(() { + final split = p.url.split(p.url.normalize(path)); + final file = split.length == 1; + final matchingEntries = contents + .where( + (entry) => + entry.name == split.first && + (file + ? entry is FileDescriptor + : entry is DirectoryDescriptor), + ) + .toList(); + + final type = file ? 'file' : 'directory'; + final parentsAndSelf = + parents == null ? name : p.url.join(parents, name); + if (matchingEntries.isEmpty) { + fail( + 'Couldn\'t find a $type descriptor named "${split.first}" within ' + '"$parentsAndSelf".'); + } else if (matchingEntries.length > 1) { + fail('Found multiple $type descriptors named "${split.first}" within ' + '"$parentsAndSelf".'); } else { - return (matchingEntries.first as DirectoryDescriptor) - ._load(p.url.joinAll(remainingPath), parentsAndSelf); + final remainingPath = split.sublist(1); + if (remainingPath.isEmpty) { + return (matchingEntries.first as FileDescriptor).readAsBytes(); + } else { + return (matchingEntries.first as DirectoryDescriptor) + ._load(p.url.joinAll(remainingPath), parentsAndSelf); + } } - } - })); + }), + ); } @override diff --git a/pkgs/test_descriptor/lib/src/file_descriptor.dart b/pkgs/test_descriptor/lib/src/file_descriptor.dart index b9eae6e12..2daedd52f 100644 --- a/pkgs/test_descriptor/lib/src/file_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/file_descriptor.dart @@ -33,8 +33,8 @@ abstract class FileDescriptor extends Descriptor { /// If [contents] isn't passed, [create] creates an empty file and [validate] /// verifies that the file is empty. /// - /// To match a [Matcher] against a file's binary contents, use [new - /// FileDescriptor.binaryMatcher] instead. + /// To match a [Matcher] against a file's binary contents, use + /// [FileDescriptor.binaryMatcher] instead. factory FileDescriptor(String name, Object? contents) { if (contents is String) return _StringFileDescriptor(name, contents); if (contents is List) { @@ -57,15 +57,15 @@ abstract class FileDescriptor extends Descriptor { _MatcherFileDescriptor(name, matcher, isBinary: true); /// A protected constructor that's only intended for subclasses. - FileDescriptor.protected(String name) : super(name); + FileDescriptor.protected(super.name); @override Future create([String? parent]) async { // Create the stream before we call [File.openWrite] because it may fail // fast (e.g. if this is a matcher file). - var file = File(p.join(parent ?? sandbox, name)).openWrite(); + final file = File(p.join(parent ?? sandbox, name)).openWrite(); try { - await readAsBytes().listen(file.add).asFuture(); + await readAsBytes().forEach(file.add); } finally { await file.close(); } @@ -73,8 +73,8 @@ abstract class FileDescriptor extends Descriptor { @override Future validate([String? parent]) async { - var fullPath = p.join(parent ?? sandbox, name); - var pretty = prettyPath(fullPath); + final fullPath = p.join(parent ?? sandbox, name); + final pretty = prettyPath(fullPath); if (!(await File(fullPath).exists())) { fail('File not found: "$pretty".'); } @@ -107,14 +107,14 @@ class _BinaryFileDescriptor extends FileDescriptor { /// The contents of this descriptor's file. final List _contents; - _BinaryFileDescriptor(String name, this._contents) : super.protected(name); + _BinaryFileDescriptor(super.name, this._contents) : super.protected(); @override Stream> readAsBytes() => Stream.fromIterable([_contents]); @override Future _validate(String prettPath, List actualContents) async { - if (const IterableEquality().equals(_contents, actualContents)) return; + if (const IterableEquality().equals(_contents, actualContents)) return; // TODO(nweiz): show a hex dump here if the data is small enough. fail('File "$prettPath" didn\'t contain the expected binary data.'); } @@ -124,7 +124,7 @@ class _StringFileDescriptor extends FileDescriptor { /// The contents of this descriptor's file. final String _contents; - _StringFileDescriptor(String name, this._contents) : super.protected(name); + _StringFileDescriptor(super.name, this._contents) : super.protected(); @override Future read() async => _contents; @@ -135,20 +135,23 @@ class _StringFileDescriptor extends FileDescriptor { @override void _validate(String prettyPath, List actualContents) { - var actualContentsText = utf8.decode(actualContents); + final actualContentsText = utf8.decode(actualContents); if (_contents == actualContentsText) return; fail(_textMismatchMessage(prettyPath, _contents, actualContentsText)); } String _textMismatchMessage( - String prettyPath, String expected, String actual) { + String prettyPath, + String expected, + String actual, + ) { final expectedLines = expected.split('\n'); final actualLines = actual.split('\n'); - var results = []; + final results = []; // Compare them line by line to see which ones match. - var length = math.max(expectedLines.length, actualLines.length); + final length = math.max(expectedLines.length, actualLines.length); for (var i = 0; i < length; i++) { if (i >= actualLines.length) { // Missing output. @@ -157,8 +160,8 @@ class _StringFileDescriptor extends FileDescriptor { // Unexpected extra output. results.add('X ${actualLines[i]}'); } else { - var expectedLine = expectedLines[i]; - var actualLine = actualLines[i]; + final expectedLine = expectedLines[i]; + final actualLine = actualLines[i]; if (expectedLine != actualLine) { // Mismatched lines. @@ -185,9 +188,9 @@ class _MatcherFileDescriptor extends FileDescriptor { /// contents. final bool _isBinary; - _MatcherFileDescriptor(String name, this._matcher, {bool isBinary = false}) + _MatcherFileDescriptor(super.name, this._matcher, {bool isBinary = false}) : _isBinary = isBinary, - super.protected(name); + super.protected(); @override Stream> readAsBytes() => @@ -197,7 +200,9 @@ class _MatcherFileDescriptor extends FileDescriptor { Future _validate(String prettyPath, List actualContents) async { try { expect( - _isBinary ? actualContents : utf8.decode(actualContents), _matcher); + _isBinary ? actualContents : utf8.decode(actualContents), + _matcher, + ); } on TestFailure catch (error) { fail('Invalid contents for file "$prettyPath":\n${error.message}'); } diff --git a/pkgs/test_descriptor/lib/src/nothing_descriptor.dart b/pkgs/test_descriptor/lib/src/nothing_descriptor.dart index 22e7bc8c1..da9e2a29d 100644 --- a/pkgs/test_descriptor/lib/src/nothing_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/nothing_descriptor.dart @@ -15,15 +15,15 @@ import 'utils.dart'; /// /// Calling [create] does nothing. class NothingDescriptor extends Descriptor { - NothingDescriptor(String name) : super(name); + NothingDescriptor(super.name); @override Future create([String? parent]) async {} @override Future validate([String? parent]) async { - var fullPath = p.join(parent ?? sandbox, name); - var pretty = prettyPath(fullPath); + final fullPath = p.join(parent ?? sandbox, name); + final pretty = prettyPath(fullPath); if (File(fullPath).existsSync()) { fail('Expected nothing to exist at "$pretty", but found a file.'); } else if (Directory(fullPath).existsSync()) { diff --git a/pkgs/test_descriptor/lib/src/pattern_descriptor.dart b/pkgs/test_descriptor/lib/src/pattern_descriptor.dart index ed1b556a9..d55afc06e 100644 --- a/pkgs/test_descriptor/lib/src/pattern_descriptor.dart +++ b/pkgs/test_descriptor/lib/src/pattern_descriptor.dart @@ -13,11 +13,6 @@ import 'descriptor.dart'; import 'sandbox.dart'; import 'utils.dart'; -/// A function that takes a name for a [Descriptor] and returns a [Descriptor]. -/// This is used for [PatternDescriptor]s, where the name isn't known -/// ahead-of-time. -typedef _EntryCreator = Descriptor Function(String name); - /// A descriptor that matches filesystem entity names by [Pattern] rather than /// by exact [String]. /// @@ -29,7 +24,7 @@ class PatternDescriptor extends Descriptor { /// The function used to generate the [Descriptor] for filesystem entities /// matching [pattern]. - final _EntryCreator _fn; + final Descriptor Function(String) _fn; PatternDescriptor(this.pattern, Descriptor Function(String basename) child) : _fn = child, @@ -42,39 +37,44 @@ class PatternDescriptor extends Descriptor { /// `this` is considered valid. @override Future validate([String? parent]) async { - var inSandbox = parent == null; + final inSandbox = parent == null; parent ??= sandbox; - var matchingEntries = await Directory(parent) + final matchingEntries = await Directory(parent) .list() - .map((entry) => - entry is File ? entry.resolveSymbolicLinksSync() : entry.path) + .map( + (entry) => + entry is File ? entry.resolveSymbolicLinksSync() : entry.path, + ) .where((entry) => matchesAll(pattern, p.basename(entry))) .toList(); matchingEntries.sort(); - var location = inSandbox ? 'sandbox' : '"${prettyPath(parent)}"'; + final location = inSandbox ? 'sandbox' : '"${prettyPath(parent)}"'; if (matchingEntries.isEmpty) { fail('No entries found in $location matching $_patternDescription.'); } - var results = await Future.wait(matchingEntries - .map((entry) { - var basename = p.basename(entry); - return runZonedGuarded(() { - return Result.capture(Future.sync(() async { - await _fn(basename).validate(parent); - return basename; - })); - }, (_, __) { - // Validate may produce multiple errors, but we ignore all but the first - // to avoid cluttering the user with many different errors from many - // different un-matched entries. - }); - }) - .whereType>>() - .toList()); + final results = await Future.wait( + matchingEntries + .map((entry) { + final basename = p.basename(entry); + return runZonedGuarded( + () => Result.capture( + Future.sync(() async { + await _fn(basename).validate(parent); + return basename; + }), + ), (_, __) { + // Validate may produce multiple errors, but we ignore all but the + // first to avoid cluttering the user with many different errors + // from many different un-matched entries. + }); + }) + .whereType>>() + .toList(), + ); - var successes = results.where((result) => result.isValue).toList(); + final successes = results.where((result) => result.isValue).toList(); if (successes.isEmpty) { await waitAndReportErrors(results.map((result) => result.asFuture)); } else if (successes.length > 1) { @@ -91,8 +91,8 @@ class PatternDescriptor extends Descriptor { if (pattern is String) return '"$pattern"'; if (pattern is! RegExp) return '$pattern'; - var regExp = pattern as RegExp; - var flags = StringBuffer(); + final regExp = pattern as RegExp; + final flags = StringBuffer(); if (!regExp.isCaseSensitive) flags.write('i'); if (regExp.isMultiLine) flags.write('m'); return '/${regExp.pattern}/$flags'; diff --git a/pkgs/test_descriptor/lib/src/sandbox.dart b/pkgs/test_descriptor/lib/src/sandbox.dart index 1f5847f02..128b6a94a 100644 --- a/pkgs/test_descriptor/lib/src/sandbox.dart +++ b/pkgs/test_descriptor/lib/src/sandbox.dart @@ -16,12 +16,12 @@ String get sandbox { if (_sandbox != null) return _sandbox!; // Resolve symlinks so we don't end up with inconsistent paths on Mac OS where // /tmp is symlinked. - var sandbox = _sandbox = Directory.systemTemp + final sandbox = _sandbox = Directory.systemTemp .createTempSync('dart_test_') .resolveSymbolicLinksSync(); addTearDown(() async { - var sandbox = _sandbox!; + final sandbox = _sandbox!; _sandbox = null; await Directory(sandbox).delete(recursive: true); }); diff --git a/pkgs/test_descriptor/lib/src/utils.dart b/pkgs/test_descriptor/lib/src/utils.dart index 26fd3ab64..f3542bdc9 100644 --- a/pkgs/test_descriptor/lib/src/utils.dart +++ b/pkgs/test_descriptor/lib/src/utils.dart @@ -12,11 +12,16 @@ import 'descriptor.dart'; import 'sandbox.dart'; /// A UTF-8 codec that allows malformed byte sequences. -final utf8 = const Utf8Codec(allowMalformed: true); +const utf8 = Utf8Codec(allowMalformed: true); /// Prepends a vertical bar to [text]. -String addBar(String text) => prefixLines(text, '${glyph.verticalLine} ', - first: '${glyph.downEnd} ', last: '${glyph.upEnd} ', single: '| '); +String addBar(String text) => prefixLines( + text, + '${glyph.verticalLine} ', + first: '${glyph.downEnd} ', + last: '${glyph.upEnd} ', + single: '| ', + ); /// Indents [text], and adds a bullet at the beginning. String addBullet(String text) => @@ -30,18 +35,24 @@ String bullet(Iterable strings) => strings.map(addBullet).join('\n'); String describeDirectory(String name, List contents) { if (contents.isEmpty) return name; - var buffer = StringBuffer(); + final buffer = StringBuffer(); buffer.writeln(name); for (var entry in contents.take(contents.length - 1)) { - var entryString = prefixLines(entry.describe(), '${glyph.verticalLine} ', - first: '${glyph.teeRight}${glyph.horizontalLine}' - '${glyph.horizontalLine} '); + final entryString = prefixLines( + entry.describe(), + '${glyph.verticalLine} ', + first: '${glyph.teeRight}${glyph.horizontalLine}' + '${glyph.horizontalLine} ', + ); buffer.writeln(entryString); } - var lastEntryString = prefixLines(contents.last.describe(), ' ', - first: '${glyph.bottomLeftCorner}${glyph.horizontalLine}' - '${glyph.horizontalLine} '); + final lastEntryString = prefixLines( + contents.last.describe(), + ' ', + first: '${glyph.bottomLeftCorner}${glyph.horizontalLine}' + '${glyph.horizontalLine} ', + ); buffer.write(lastEntryString); return buffer.toString(); } @@ -52,16 +63,21 @@ String describeDirectory(String name, List contents) { /// prefixed with those instead. If [single] is passed, it's used if there's /// only a single line; otherwise, [first], [last], or [prefix] is used, in that /// order of precedence. -String prefixLines(String text, String prefix, - {String? first, String? last, String? single}) { +String prefixLines( + String text, + String prefix, { + String? first, + String? last, + String? single, +}) { single ??= first ?? last ?? prefix; first ??= prefix; last ??= prefix; - var lines = text.split('\n'); + final lines = text.split('\n'); if (lines.length == 1) return '$single$text'; - var buffer = StringBuffer('$first${lines.first}\n'); + final buffer = StringBuffer('$first${lines.first}\n'); for (var line in lines.skip(1).take(lines.length - 2)) { buffer.writeln('$prefix$line'); } @@ -90,16 +106,22 @@ bool matchesAll(Pattern pattern, String string) => /// first using [registerException] rather than silently ignoring them. Future> waitAndReportErrors(Iterable> futures) { var errored = false; - return Future.wait(futures.map((future) { - // Avoid async/await so that we synchronously add error handlers for the - // futures to keep them from top-leveling. - return future.catchError((Object error, StackTrace stackTrace) { - if (!errored) { - errored = true; - throw error; // ignore: only_throw_errors - } else { - registerException(error, stackTrace); - } - }); - })); + return Future.wait( + futures.map( + (future) => + // Avoid async/await so that we synchronously add error handlers for the + // futures to keep them from top-leveling. + future.catchError( + // ignore: body_might_complete_normally_catch_error + (Object error, StackTrace stackTrace) { + if (!errored) { + errored = true; + throw error; // ignore: only_throw_errors + } else { + registerException(error, stackTrace); + } + }, + ), + ), + ); } diff --git a/pkgs/test_descriptor/lib/test_descriptor.dart b/pkgs/test_descriptor/lib/test_descriptor.dart index cf5e07fdb..b302910f5 100644 --- a/pkgs/test_descriptor/lib/test_descriptor.dart +++ b/pkgs/test_descriptor/lib/test_descriptor.dart @@ -30,9 +30,10 @@ export 'src/sandbox.dart' show sandbox; /// If [contents] isn't passed, [Descriptor.create] creates an empty file and /// [Descriptor.validate] verifies that the file is empty. /// -/// To match a [Matcher] against a file's binary contents, use [new -/// FileDescriptor.binaryMatcher] instead. -FileDescriptor file(String name, [contents]) => FileDescriptor(name, contents); +/// To match a [Matcher] against a file's binary contents, use +/// [FileDescriptor.binaryMatcher] instead. +FileDescriptor file(String name, [Object? contents]) => + FileDescriptor(name, contents); /// Creates a new [DirectoryDescriptor] descriptor with [name] and [contents]. /// @@ -60,12 +61,14 @@ NothingDescriptor nothing(String name) => NothingDescriptor(name); /// /// [Descriptor.create] is not supported for this descriptor. PatternDescriptor pattern( - Pattern name, Descriptor Function(String basename) child) => + Pattern name, + Descriptor Function(String basename) child, +) => PatternDescriptor(name, child); /// A convenience method for creating a [PatternDescriptor] descriptor that /// constructs a [FileDescriptor] descriptor. -PatternDescriptor filePattern(Pattern name, [contents]) => +PatternDescriptor filePattern(Pattern name, [Object? contents]) => pattern(name, (realName) => file(realName, contents)); /// A convenience method for creating a [PatternDescriptor] descriptor that diff --git a/pkgs/test_descriptor/pubspec.yaml b/pkgs/test_descriptor/pubspec.yaml index 0f3836c67..1e01da022 100644 --- a/pkgs/test_descriptor/pubspec.yaml +++ b/pkgs/test_descriptor/pubspec.yaml @@ -1,19 +1,17 @@ name: test_descriptor -version: 2.0.1 -description: An API for defining and verifying directory structures. +version: 2.0.2-dev +description: An API for defining and verifying files and directory structures. repository: https://github.com/dart-lang/test_descriptor environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.17.0 <3.0.0' dependencies: async: ^2.5.0 collection: ^1.15.0 - matcher: ^0.12.10 - meta: ^1.3.0 path: ^1.8.0 term_glyph: ^1.2.0 test: ^1.16.0 dev_dependencies: - lints: ^1.0.0 + lints: ^2.0.0 diff --git a/pkgs/test_descriptor/test/directory_test.dart b/pkgs/test_descriptor/test/directory_test.dart index c669be832..b0b2a224a 100644 --- a/pkgs/test_descriptor/test/directory_test.dart +++ b/pkgs/test_descriptor/test/directory_test.dart @@ -11,7 +11,6 @@ import 'dart:io'; import 'package:path/path.dart' as p; import 'package:term_glyph/term_glyph.dart' as term_glyph; import 'package:test/test.dart'; - import 'package:test_descriptor/test_descriptor.dart' as d; import 'utils.dart'; @@ -28,34 +27,40 @@ void main() { d.file('file2.txt', 'contents2') ]).create(); - expect(File(p.join(d.sandbox, 'dir', 'file1.txt')).readAsString(), - completion(equals('contents1'))); - expect(File(p.join(d.sandbox, 'dir', 'file2.txt')).readAsString(), - completion(equals('contents2'))); expect( - File(p.join(d.sandbox, 'dir', 'subdir', 'subfile1.txt')) - .readAsString(), - completion(equals('subcontents1'))); + File(p.join(d.sandbox, 'dir', 'file1.txt')).readAsString(), + completion(equals('contents1')), + ); + expect( + File(p.join(d.sandbox, 'dir', 'file2.txt')).readAsString(), + completion(equals('contents2')), + ); + expect( + File(p.join(d.sandbox, 'dir', 'subdir', 'subfile1.txt')).readAsString(), + completion(equals('subcontents1')), + ); expect( - File(p.join(d.sandbox, 'dir', 'subdir', 'subfile2.txt')) - .readAsString(), - completion(equals('subcontents2'))); + File(p.join(d.sandbox, 'dir', 'subdir', 'subfile2.txt')).readAsString(), + completion(equals('subcontents2')), + ); }); test('works if the directory already exists', () async { await d.dir('dir').create(); await d.dir('dir', [d.file('name.txt', 'contents')]).create(); - expect(File(p.join(d.sandbox, 'dir', 'name.txt')).readAsString(), - completion(equals('contents'))); + expect( + File(p.join(d.sandbox, 'dir', 'name.txt')).readAsString(), + completion(equals('contents')), + ); }); }); group('validate()', () { test('completes successfully if the filesystem matches the descriptor', () async { - var dirPath = p.join(d.sandbox, 'dir'); - var subdirPath = p.join(dirPath, 'subdir'); + final dirPath = p.join(d.sandbox, 'dir'); + final subdirPath = p.join(dirPath, 'subdir'); await Directory(subdirPath).create(recursive: true); await File(p.join(dirPath, 'file1.txt')).writeAsString('contents1'); await File(p.join(dirPath, 'file2.txt')).writeAsString('contents2'); @@ -75,85 +80,107 @@ void main() { }); test("fails if the directory doesn't exist", () async { - var dirPath = p.join(d.sandbox, 'dir'); + final dirPath = p.join(d.sandbox, 'dir'); await Directory(dirPath).create(); await File(p.join(dirPath, 'file1.txt')).writeAsString('contents1'); await File(p.join(dirPath, 'file2.txt')).writeAsString('contents2'); expect( - d.dir('dir', [ - d.dir('subdir', [ - d.file('subfile1.txt', 'subcontents1'), - d.file('subfile2.txt', 'subcontents2') - ]), - d.file('file1.txt', 'contents1'), - d.file('file2.txt', 'contents2') - ]).validate(), - throwsA(toString( - equals('Directory not found: "${p.join('dir', 'subdir')}".')))); + d.dir('dir', [ + d.dir('subdir', [ + d.file('subfile1.txt', 'subcontents1'), + d.file('subfile2.txt', 'subcontents2') + ]), + d.file('file1.txt', 'contents1'), + d.file('file2.txt', 'contents2') + ]).validate(), + throwsA( + toString( + equals('Directory not found: "${p.join('dir', 'subdir')}".'), + ), + ), + ); }); test('emits an error for each child that fails to validate', () async { - var dirPath = p.join(d.sandbox, 'dir'); - var subdirPath = p.join(dirPath, 'subdir'); + final dirPath = p.join(d.sandbox, 'dir'); + final subdirPath = p.join(dirPath, 'subdir'); await Directory(subdirPath).create(recursive: true); await File(p.join(dirPath, 'file1.txt')).writeAsString('contents1'); await File(p.join(subdirPath, 'subfile2.txt')) .writeAsString('subwrongtents2'); var errors = 0; - var controller = StreamController(); - runZonedGuarded(() { - d.dir('dir', [ - d.dir('subdir', [ - d.file('subfile1.txt', 'subcontents1'), - d.file('subfile2.txt', 'subcontents2') - ]), - d.file('file1.txt', 'contents1'), - d.file('file2.txt', 'contents2') - ]).validate(); - }, - expectAsync2((error, _) { + final controller = StreamController(); + runZonedGuarded( + () { + d.dir('dir', [ + d.dir('subdir', [ + d.file('subfile1.txt', 'subcontents1'), + d.file('subfile2.txt', 'subcontents2') + ]), + d.file('file1.txt', 'contents1'), + d.file('file2.txt', 'contents2') + ]).validate(); + }, + expectAsync2( + (error, _) { errors++; controller.add(error.toString()); if (errors == 3) controller.close(); - }, count: 3)); + }, + count: 3, + ), + ); expect( - controller.stream.toList(), - completion(allOf([ + controller.stream.toList(), + completion( + allOf([ contains( - 'File not found: "${p.join('dir', 'subdir', 'subfile1.txt')}".'), + 'File not found: "${p.join('dir', 'subdir', 'subfile1.txt')}".', + ), contains('File not found: "${p.join('dir', 'file2.txt')}".'), contains( - startsWith('File "${p.join('dir', 'subdir', 'subfile2.txt')}" ' - 'should contain:')), - ]))); + startsWith('File "${p.join('dir', 'subdir', 'subfile2.txt')}" ' + 'should contain:'), + ), + ]), + ), + ); }); }); group('load()', () { test('loads a file', () { - var dir = d.dir('dir', - [d.file('name.txt', 'contents'), d.file('other.txt', 'wrong')]); - expect(utf8.decodeStream(dir.load('name.txt')), - completion(equals('contents'))); + final dir = d.dir( + 'dir', + [d.file('name.txt', 'contents'), d.file('other.txt', 'wrong')], + ); + expect( + utf8.decodeStream(dir.load('name.txt')), + completion(equals('contents')), + ); }); test('loads a deeply-nested file', () { - var dir = d.dir('dir', [ - d.dir('subdir', - [d.file('name.txt', 'subcontents'), d.file('other.txt', 'wrong')]), + final dir = d.dir('dir', [ + d.dir( + 'subdir', + [d.file('name.txt', 'subcontents'), d.file('other.txt', 'wrong')], + ), d.dir('otherdir', [d.file('other.txt', 'wrong')]), d.file('name.txt', 'contents') ]); - expect(utf8.decodeStream(dir.load('subdir/name.txt')), - completion(equals('subcontents'))); + expect( + utf8.decodeStream(dir.load('subdir/name.txt')), + completion(equals('subcontents')), + ); }); test('fails to load a nested directory', () { - var dir = d.dir('dir', [ + final dir = d.dir('dir', [ d.dir('subdir', [ d.dir('subsubdir', [d.file('name.txt', 'subcontents')]) ]), @@ -161,52 +188,71 @@ void main() { ]); expect( - dir.load('subdir/subsubdir').toList(), - throwsA(toString(equals('Couldn\'t find a file descriptor named ' - '"subsubdir" within "dir/subdir".')))); + dir.load('subdir/subsubdir').toList(), + throwsA( + toString( + equals('Couldn\'t find a file descriptor named ' + '"subsubdir" within "dir/subdir".'), + ), + ), + ); }); test('fails to load an absolute path', () { - var dir = d.dir('dir', [d.file('name.txt', 'contents')]); + final dir = d.dir('dir', [d.file('name.txt', 'contents')]); expect(() => dir.load('/name.txt'), throwsArgumentError); }); test("fails to load '..'", () { - var dir = d.dir('dir', [d.file('name.txt', 'contents')]); + final dir = d.dir('dir', [d.file('name.txt', 'contents')]); expect(() => dir.load('..'), throwsArgumentError); }); test("fails to load a file that doesn't exist", () { - var dir = d.dir('dir', [ + final dir = d.dir('dir', [ d.dir('subdir', [d.file('name.txt', 'contents')]) ]); expect( - dir.load('subdir/not-name.txt').toList(), - throwsA(toString(equals('Couldn\'t find a file descriptor named ' - '"not-name.txt" within "dir/subdir".')))); + dir.load('subdir/not-name.txt').toList(), + throwsA( + toString( + equals('Couldn\'t find a file descriptor named ' + '"not-name.txt" within "dir/subdir".'), + ), + ), + ); }); test('fails to load a file that exists multiple times', () { - var dir = d.dir('dir', [ - d.dir('subdir', - [d.file('name.txt', 'contents'), d.file('name.txt', 'contents')]) + final dir = d.dir('dir', [ + d.dir( + 'subdir', + [d.file('name.txt', 'contents'), d.file('name.txt', 'contents')], + ) ]); expect( - dir.load('subdir/name.txt').toList(), - throwsA(toString(equals('Found multiple file descriptors named ' - '"name.txt" within "dir/subdir".')))); + dir.load('subdir/name.txt').toList(), + throwsA( + toString( + equals('Found multiple file descriptors named ' + '"name.txt" within "dir/subdir".'), + ), + ), + ); }); test('loads a file next to a subdirectory with the same name', () { - var dir = d.dir('dir', [ + final dir = d.dir('dir', [ d.file('name', 'contents'), d.dir('name', [d.file('subfile', 'contents')]) ]); expect( - utf8.decodeStream(dir.load('name')), completion(equals('contents'))); + utf8.decodeStream(dir.load('name')), + completion(equals('contents')), + ); }); }); @@ -222,18 +268,21 @@ void main() { }); test('lists the contents of the directory', () { - var dir = d.dir('dir', - [d.file('file1.txt', 'contents1'), d.file('file2.txt', 'contents2')]); + final dir = d.dir( + 'dir', + [d.file('file1.txt', 'contents1'), d.file('file2.txt', 'contents2')], + ); expect( - dir.describe(), - equals('dir\n' - '+-- file1.txt\n' - "'-- file2.txt")); + dir.describe(), + equals('dir\n' + '+-- file1.txt\n' + "'-- file2.txt"), + ); }); test('lists the contents of nested directories', () { - var dir = d.dir('dir', [ + final dir = d.dir('dir', [ d.file('file1.txt', 'contents1'), d.dir('subdir', [ d.file('subfile1.txt', 'subcontents1'), @@ -244,15 +293,16 @@ void main() { ]); expect( - dir.describe(), - equals('dir\n' - '+-- file1.txt\n' - '+-- subdir\n' - '| +-- subfile1.txt\n' - '| +-- subfile2.txt\n' - "| '-- subsubdir\n" - "| '-- subsubfile.txt\n" - "'-- file2.txt")); + dir.describe(), + equals('dir\n' + '+-- file1.txt\n' + '+-- subdir\n' + '| +-- subfile1.txt\n' + '| +-- subfile2.txt\n' + "| '-- subsubdir\n" + "| '-- subsubfile.txt\n" + "'-- file2.txt"), + ); }); test('with no contents returns the directory name', () { @@ -262,7 +312,7 @@ void main() { group('fromFilesystem()', () { test('creates a descriptor based on the physical filesystem', () async { - var dir = d.dir('dir', [ + final dir = d.dir('dir', [ d.dir('subdir', [ d.file('subfile1.txt', 'subcontents1'), d.file('subfile2.txt', 'subcontents2') @@ -272,7 +322,7 @@ void main() { ]); await dir.create(); - var descriptor = + final descriptor = d.DirectoryDescriptor.fromFilesystem('dir', p.join(d.sandbox, 'dir')); await descriptor.create(p.join(d.sandbox, 'dir2')); await dir.validate(p.join(d.sandbox, 'dir2')); @@ -288,13 +338,17 @@ void main() { d.file('.DS_Store', 'contents2') ]).create(); - var descriptor = d.DirectoryDescriptor.fromFilesystem( - 'dir2', p.join(d.sandbox, 'dir')); + final descriptor = d.DirectoryDescriptor.fromFilesystem( + 'dir2', + p.join(d.sandbox, 'dir'), + ); await descriptor.create(); await d.dir('dir2', [ - d.dir('subdir', - [d.file('subfile1.txt', 'subcontents1'), d.nothing('.hidden')]), + d.dir( + 'subdir', + [d.file('subfile1.txt', 'subcontents1'), d.nothing('.hidden')], + ), d.file('file1.txt', 'contents1'), d.nothing('.DS_Store') ]).validate(); diff --git a/pkgs/test_descriptor/test/file_test.dart b/pkgs/test_descriptor/test/file_test.dart index 13b7597d6..26a452858 100644 --- a/pkgs/test_descriptor/test/file_test.dart +++ b/pkgs/test_descriptor/test/file_test.dart @@ -18,28 +18,36 @@ void main() { test('creates a text file', () async { await d.file('name.txt', 'contents').create(); - expect(File(p.join(d.sandbox, 'name.txt')).readAsString(), - completion(equals('contents'))); + expect( + File(p.join(d.sandbox, 'name.txt')).readAsString(), + completion(equals('contents')), + ); }); test('creates a binary file', () async { await d.file('name.txt', [0, 1, 2, 3]).create(); - expect(File(p.join(d.sandbox, 'name.txt')).readAsBytes(), - completion(equals([0, 1, 2, 3]))); + expect( + File(p.join(d.sandbox, 'name.txt')).readAsBytes(), + completion(equals([0, 1, 2, 3])), + ); }); test('fails to create a matcher file', () async { expect( - d.file('name.txt', contains('foo')).create(), throwsUnsupportedError); + d.file('name.txt', contains('foo')).create(), + throwsUnsupportedError, + ); }); test('overwrites an existing file', () async { await d.file('name.txt', 'contents1').create(); await d.file('name.txt', 'contents2').create(); - expect(File(p.join(d.sandbox, 'name.txt')).readAsString(), - completion(equals('contents2'))); + expect( + File(p.join(d.sandbox, 'name.txt')).readAsString(), + completion(equals('contents2')), + ); }); }); @@ -72,62 +80,85 @@ void main() { test("fails if the text contents don't match", () async { await File(p.join(d.sandbox, 'name.txt')).writeAsString('wrong'); - expect(d.file('name.txt', 'contents').validate(), - throwsA(toString(startsWith('File "name.txt" should contain:')))); + expect( + d.file('name.txt', 'contents').validate(), + throwsA(toString(startsWith('File "name.txt" should contain:'))), + ); }); test("fails if the binary contents don't match", () async { await File(p.join(d.sandbox, 'name.txt')).writeAsBytes([5, 4, 3, 2]); expect( - d.file('name.txt', [0, 1, 2, 3]).validate(), - throwsA(toString(equals( - 'File "name.txt" didn\'t contain the expected binary data.')))); + d.file('name.txt', [0, 1, 2, 3]).validate(), + throwsA( + toString( + equals( + 'File "name.txt" didn\'t contain the expected binary data.', + ), + ), + ), + ); }); test("fails if the text contents don't match the matcher", () async { await File(p.join(d.sandbox, 'name.txt')).writeAsString('wrong'); expect( - d.file('name.txt', contains('ent')).validate(), - throwsA( - toString(startsWith('Invalid contents for file "name.txt":')))); + d.file('name.txt', contains('ent')).validate(), + throwsA( + toString(startsWith('Invalid contents for file "name.txt":')), + ), + ); }); test("fails if the binary contents don't match the matcher", () async { await File(p.join(d.sandbox, 'name.txt')).writeAsBytes([5, 4, 3, 2]); expect( - d.FileDescriptor.binaryMatcher('name.txt', contains(1)).validate(), - throwsA( - toString(startsWith('Invalid contents for file "name.txt":')))); + d.FileDescriptor.binaryMatcher('name.txt', contains(1)).validate(), + throwsA( + toString(startsWith('Invalid contents for file "name.txt":')), + ), + ); }); test("fails if invalid UTF-8 doesn't match a text matcher", () async { await File(p.join(d.sandbox, 'name.txt')).writeAsBytes([0xC3, 0x28]); expect( - d.file('name.txt', isEmpty).validate(), - throwsA(toString(allOf([ - startsWith('Invalid contents for file "name.txt":'), - contains('�') - ])))); + d.file('name.txt', isEmpty).validate(), + throwsA( + toString( + allOf([ + startsWith('Invalid contents for file "name.txt":'), + contains('�') + ]), + ), + ), + ); }); test("fails if there's no file", () { - expect(d.file('name.txt', 'contents').validate(), - throwsA(toString(equals('File not found: "name.txt".')))); + expect( + d.file('name.txt', 'contents').validate(), + throwsA(toString(equals('File not found: "name.txt".'))), + ); }); }); group('reading', () { test('read() returns the contents of a text file as a string', () { - expect(d.file('name.txt', 'contents').read(), - completion(equals('contents'))); + expect( + d.file('name.txt', 'contents').read(), + completion(equals('contents')), + ); }); test('read() returns the contents of a binary file as a string', () { - expect(d.file('name.txt', [0x68, 0x65, 0x6c, 0x6c, 0x6f]).read(), - completion(equals('hello'))); + expect( + d.file('name.txt', [0x68, 0x65, 0x6c, 0x6c, 0x6f]).read(), + completion(equals('hello')), + ); }); test('read() fails for a matcher file', () { @@ -136,19 +167,25 @@ void main() { test('readAsBytes() returns the contents of a text file as a byte stream', () { - expect(utf8.decodeStream(d.file('name.txt', 'contents').readAsBytes()), - completion(equals('contents'))); + expect( + utf8.decodeStream(d.file('name.txt', 'contents').readAsBytes()), + completion(equals('contents')), + ); }); test('readAsBytes() returns the contents of a binary file as a byte stream', () { - expect(byteStreamToList(d.file('name.txt', [0, 1, 2, 3]).readAsBytes()), - completion(equals([0, 1, 2, 3]))); + expect( + byteStreamToList(d.file('name.txt', [0, 1, 2, 3]).readAsBytes()), + completion(equals([0, 1, 2, 3])), + ); }); test('readAsBytes() fails for a matcher file', () { - expect(d.file('name.txt', contains('hi')).readAsBytes, - throwsUnsupportedError); + expect( + d.file('name.txt', contains('hi')).readAsBytes, + throwsUnsupportedError, + ); }); }); diff --git a/pkgs/test_descriptor/test/nothing_test.dart b/pkgs/test_descriptor/test/nothing_test.dart index a192087a8..23d91ff4c 100644 --- a/pkgs/test_descriptor/test/nothing_test.dart +++ b/pkgs/test_descriptor/test/nothing_test.dart @@ -28,25 +28,43 @@ void main() { test("fails if there's a file", () async { await d.file('name.txt', 'contents').create(); expect( - d.nothing('name.txt').validate(), - throwsA(toString(equals( - 'Expected nothing to exist at "name.txt", but found a file.')))); + d.nothing('name.txt').validate(), + throwsA( + toString( + equals( + 'Expected nothing to exist at "name.txt", but found a file.', + ), + ), + ), + ); }); test("fails if there's a directory", () async { await d.dir('dir').create(); expect( - d.nothing('dir').validate(), - throwsA(toString(equals( - 'Expected nothing to exist at "dir", but found a directory.')))); + d.nothing('dir').validate(), + throwsA( + toString( + equals( + 'Expected nothing to exist at "dir", but found a directory.', + ), + ), + ), + ); }); test("fails if there's a broken link", () async { await Link(p.join(d.sandbox, 'link')).create('nonexistent'); expect( - d.nothing('link').validate(), - throwsA(toString(equals( - 'Expected nothing to exist at "link", but found a link.')))); + d.nothing('link').validate(), + throwsA( + toString( + equals( + 'Expected nothing to exist at "link", but found a link.', + ), + ), + ), + ); }); }); } diff --git a/pkgs/test_descriptor/test/pattern_test.dart b/pkgs/test_descriptor/test/pattern_test.dart index eb7b81528..3963fc0e1 100644 --- a/pkgs/test_descriptor/test/pattern_test.dart +++ b/pkgs/test_descriptor/test/pattern_test.dart @@ -15,14 +15,14 @@ void main() { test("succeeds if there's a file matching the pattern and the child", () async { await d.file('foo', 'blap').create(); - await d.filePattern(RegExp(r'f..'), 'blap').validate(); + await d.filePattern(RegExp('f..'), 'blap').validate(); }); test("succeeds if there's a directory matching the pattern and the child", () async { await d.dir('foo', [d.file('bar', 'baz')]).create(); - await d.dirPattern(RegExp(r'f..'), [d.file('bar', 'baz')]).validate(); + await d.dirPattern(RegExp('f..'), [d.file('bar', 'baz')]).validate(); }); test( @@ -32,29 +32,35 @@ void main() { await d.file('fee', 'blak').create(); await d.file('faa', 'blut').create(); - await d.filePattern(RegExp(r'f..'), 'blap').validate(); + await d.filePattern(RegExp('f..'), 'blap').validate(); }); test("fails if there's no file matching the pattern", () { expect( - d.filePattern(RegExp(r'f..'), 'bar').validate(), - throwsA( - toString(equals('No entries found in sandbox matching /f../.')))); + d.filePattern(RegExp('f..'), 'bar').validate(), + throwsA( + toString(equals('No entries found in sandbox matching /f../.')), + ), + ); }); test("fails if there's a file matching the pattern but not the entry", () async { await d.file('foo', 'bap').create(); - expect(d.filePattern(RegExp(r'f..'), 'bar').validate(), - throwsA(toString(startsWith('File "foo" should contain:')))); + expect( + d.filePattern(RegExp('f..'), 'bar').validate(), + throwsA(toString(startsWith('File "foo" should contain:'))), + ); }); test("fails if there's a dir matching the pattern but not the entry", () async { await d.dir('foo', [d.file('bar', 'bap')]).create(); - expect(d.dirPattern(RegExp(r'f..'), [d.file('bar', 'baz')]).validate(), - throwsA(toString(startsWith('File "foo/bar" should contain:')))); + expect( + d.dirPattern(RegExp('f..'), [d.file('bar', 'baz')]).validate(), + throwsA(toString(startsWith('File "foo/bar" should contain:'))), + ); }); test( @@ -64,9 +70,15 @@ void main() { await d.file('fee', 'bar').create(); await d.file('faa', 'bar').create(); expect( - d.filePattern(RegExp(r'f..'), 'bar').validate(), - throwsA(toString(startsWith( - 'Multiple valid entries found in sandbox matching /f../:')))); + d.filePattern(RegExp('f..'), 'bar').validate(), + throwsA( + toString( + startsWith( + 'Multiple valid entries found in sandbox matching /f../:', + ), + ), + ), + ); }); }); } diff --git a/pkgs/test_descriptor/test/utils.dart b/pkgs/test_descriptor/test/utils.dart index 5eb84f7d5..8b07e8cd5 100644 --- a/pkgs/test_descriptor/test/utils.dart +++ b/pkgs/test_descriptor/test/utils.dart @@ -5,18 +5,18 @@ import 'package:test/test.dart'; /// Converts a [Stream>] to a flat byte future. -Future> byteStreamToList(Stream> stream) { - return stream.fold([], (buffer, chunk) { - buffer.addAll(chunk); - return buffer; - }); -} +Future> byteStreamToList(Stream> stream) => + stream.fold([], (buffer, chunk) { + buffer.addAll(chunk); + return buffer; + }); /// Returns a matcher that verifies that the result of calling `toString()` /// matches [matcher]. -Matcher toString(matcher) { - return predicate((object) { - expect(object.toString(), matcher); - return true; - }, 'toString() matches $matcher'); -} +Matcher toString(Object? matcher) => predicate( + (object) { + expect(object.toString(), matcher); + return true; + }, + 'toString() matches $matcher', + ); From c2f2a40f9d4f837af0b1eea495e13ef499baa5fd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Jan 2023 10:12:22 -0800 Subject: [PATCH 42/72] Bump actions/checkout from 3.1.0 to 3.2.0 (dart-lang/test_descriptor#46) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.1.0 to 3.2.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8...755da8c3cf115ac066823e79a1e1788f8940201b) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/test_descriptor/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml index 0de63d5de..6ac3f6ac4 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -24,7 +24,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} @@ -51,7 +51,7 @@ jobs: os: [ubuntu-latest] sdk: [2.17.0, dev] steps: - - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 + - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} From 268564a0c4a329d8a8b4ab82789bc940df632e1f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Feb 2023 08:06:34 -0800 Subject: [PATCH 43/72] Bump actions/checkout from 3.2.0 to 3.3.0 (dart-lang/test_descriptor#47) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.2.0 to 3.3.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/755da8c3cf115ac066823e79a1e1788f8940201b...ac593985615ec2ede58e132d2e21d2b1cbd6127c) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/test_descriptor/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml index 6ac3f6ac4..e8d811d7f 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -24,7 +24,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b + - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} @@ -51,7 +51,7 @@ jobs: os: [ubuntu-latest] sdk: [2.17.0, dev] steps: - - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b + - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d with: sdk: ${{ matrix.sdk }} From f95831e1b0c1646a534fbe6ac7acae4344c1f47c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Feb 2023 08:14:54 -0800 Subject: [PATCH 44/72] Bump dart-lang/setup-dart from 1.3 to 1.4 (dart-lang/test_descriptor#48) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.3 to 1.4. - [Release notes](https://github.com/dart-lang/setup-dart/releases) - [Changelog](https://github.com/dart-lang/setup-dart/blob/main/CHANGELOG.md) - [Commits](https://github.com/dart-lang/setup-dart/compare/6a218f2413a3e78e9087f638a238f6b40893203d...a57a6c04cf7d4840e88432aad6281d1e125f0d46) --- updated-dependencies: - dependency-name: dart-lang/setup-dart dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/test_descriptor/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml index e8d811d7f..82640bfb2 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -25,7 +25,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d + - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} - id: install @@ -52,7 +52,7 @@ jobs: sdk: [2.17.0, dev] steps: - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c - - uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d + - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} - id: install From 8a46712269eb0e2c3ffa4af31408bb494fcd9369 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Apr 2023 15:33:09 -0700 Subject: [PATCH 45/72] Bump actions/checkout from 3.3.0 to 3.5.0 (dart-lang/test_descriptor#50) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.3.0 to 3.5.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/ac593985615ec2ede58e132d2e21d2b1cbd6127c...8f4b7f84864484a7bf31766abe9204da3cbe65b3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/test_descriptor/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml index 82640bfb2..ff7db0fed 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -24,7 +24,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} @@ -51,7 +51,7 @@ jobs: os: [ubuntu-latest] sdk: [2.17.0, dev] steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 with: sdk: ${{ matrix.sdk }} From 6e1e998366c565681f59ef94bf76a331dc0ecdf7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Apr 2023 15:37:22 -0700 Subject: [PATCH 46/72] Bump dart-lang/setup-dart from 1.4.0 to 1.5.0 (dart-lang/test_descriptor#49) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.4.0 to 1.5.0. - [Release notes](https://github.com/dart-lang/setup-dart/releases) - [Changelog](https://github.com/dart-lang/setup-dart/blob/main/CHANGELOG.md) - [Commits](https://github.com/dart-lang/setup-dart/compare/a57a6c04cf7d4840e88432aad6281d1e125f0d46...d6a63dab3335f427404425de0fbfed4686d93c4f) --- updated-dependencies: - dependency-name: dart-lang/setup-dart dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/test_descriptor/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml index ff7db0fed..a0a59db07 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -25,7 +25,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 + - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} - id: install @@ -52,7 +52,7 @@ jobs: sdk: [2.17.0, dev] steps: - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 - - uses: dart-lang/setup-dart@a57a6c04cf7d4840e88432aad6281d1e125f0d46 + - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} - id: install From 5d041fe55e8198bcd7b1ae7ef497dd87b4a8bdc9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 May 2023 12:24:23 -0700 Subject: [PATCH 47/72] Bump actions/checkout from 3.5.0 to 3.5.2 (dart-lang/test_descriptor#51) Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.0 to 3.5.2. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/8f4b7f84864484a7bf31766abe9204da3cbe65b3...8e5e7e5ab8b370d6c329ec480221332ada57f0ab) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pkgs/test_descriptor/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml index a0a59db07..46d999254 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -24,7 +24,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} @@ -51,7 +51,7 @@ jobs: os: [ubuntu-latest] sdk: [2.17.0, dev] steps: - - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} From 64b9f9ab6e5855454fa6e077c122ca3df69436e8 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Mon, 22 May 2023 16:23:38 -0700 Subject: [PATCH 48/72] blast_repo fixes (dart-lang/test_descriptor#52) dependabot --- pkgs/test_descriptor/.github/dependabot.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/test_descriptor/.github/dependabot.yml b/pkgs/test_descriptor/.github/dependabot.yml index 214481934..439e796b4 100644 --- a/pkgs/test_descriptor/.github/dependabot.yml +++ b/pkgs/test_descriptor/.github/dependabot.yml @@ -2,7 +2,9 @@ version: 2 updates: - - package-ecosystem: "github-actions" - directory: "/" + - package-ecosystem: github-actions + directory: / schedule: - interval: "monthly" + interval: monthly + labels: + - autosubmit From 69447aefb574274f3351a1b79acbd38e81117982 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Mon, 3 Jul 2023 20:02:53 -0700 Subject: [PATCH 49/72] update formatting for recent lints (dart-lang/test_descriptor#54) --- pkgs/test_descriptor/example/example.dart | 4 +- pkgs/test_descriptor/test/directory_test.dart | 42 +++++++++---------- pkgs/test_descriptor/test/file_test.dart | 2 +- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/pkgs/test_descriptor/example/example.dart b/pkgs/test_descriptor/example/example.dart index ef5917ed1..457383257 100644 --- a/pkgs/test_descriptor/example/example.dart +++ b/pkgs/test_descriptor/example/example.dart @@ -11,7 +11,7 @@ void main() { test('Directory.rename', () async { await d.dir('parent', [ d.file('sibling', 'sibling-contents'), - d.dir('old-name', [d.file('child', 'child-contents')]) + d.dir('old-name', [d.file('child', 'child-contents')]), ]).create(); await Directory('${d.sandbox}/parent/old-name') @@ -19,7 +19,7 @@ void main() { await d.dir('parent', [ d.file('sibling', 'sibling-contents'), - d.dir('new-name', [d.file('child', 'child-contents')]) + d.dir('new-name', [d.file('child', 'child-contents')]), ]).validate(); }); } diff --git a/pkgs/test_descriptor/test/directory_test.dart b/pkgs/test_descriptor/test/directory_test.dart index b0b2a224a..321612833 100644 --- a/pkgs/test_descriptor/test/directory_test.dart +++ b/pkgs/test_descriptor/test/directory_test.dart @@ -21,10 +21,10 @@ void main() { await d.dir('dir', [ d.dir('subdir', [ d.file('subfile1.txt', 'subcontents1'), - d.file('subfile2.txt', 'subcontents2') + d.file('subfile2.txt', 'subcontents2'), ]), d.file('file1.txt', 'contents1'), - d.file('file2.txt', 'contents2') + d.file('file2.txt', 'contents2'), ]).create(); expect( @@ -72,10 +72,10 @@ void main() { await d.dir('dir', [ d.dir('subdir', [ d.file('subfile1.txt', 'subcontents1'), - d.file('subfile2.txt', 'subcontents2') + d.file('subfile2.txt', 'subcontents2'), ]), d.file('file1.txt', 'contents1'), - d.file('file2.txt', 'contents2') + d.file('file2.txt', 'contents2'), ]).validate(); }); @@ -89,10 +89,10 @@ void main() { d.dir('dir', [ d.dir('subdir', [ d.file('subfile1.txt', 'subcontents1'), - d.file('subfile2.txt', 'subcontents2') + d.file('subfile2.txt', 'subcontents2'), ]), d.file('file1.txt', 'contents1'), - d.file('file2.txt', 'contents2') + d.file('file2.txt', 'contents2'), ]).validate(), throwsA( toString( @@ -117,10 +117,10 @@ void main() { d.dir('dir', [ d.dir('subdir', [ d.file('subfile1.txt', 'subcontents1'), - d.file('subfile2.txt', 'subcontents2') + d.file('subfile2.txt', 'subcontents2'), ]), d.file('file1.txt', 'contents1'), - d.file('file2.txt', 'contents2') + d.file('file2.txt', 'contents2'), ]).validate(); }, expectAsync2( @@ -170,7 +170,7 @@ void main() { [d.file('name.txt', 'subcontents'), d.file('other.txt', 'wrong')], ), d.dir('otherdir', [d.file('other.txt', 'wrong')]), - d.file('name.txt', 'contents') + d.file('name.txt', 'contents'), ]); expect( @@ -182,9 +182,9 @@ void main() { test('fails to load a nested directory', () { final dir = d.dir('dir', [ d.dir('subdir', [ - d.dir('subsubdir', [d.file('name.txt', 'subcontents')]) + d.dir('subsubdir', [d.file('name.txt', 'subcontents')]), ]), - d.file('name.txt', 'contents') + d.file('name.txt', 'contents'), ]); expect( @@ -210,7 +210,7 @@ void main() { test("fails to load a file that doesn't exist", () { final dir = d.dir('dir', [ - d.dir('subdir', [d.file('name.txt', 'contents')]) + d.dir('subdir', [d.file('name.txt', 'contents')]), ]); expect( @@ -229,7 +229,7 @@ void main() { d.dir( 'subdir', [d.file('name.txt', 'contents'), d.file('name.txt', 'contents')], - ) + ), ]); expect( @@ -246,7 +246,7 @@ void main() { test('loads a file next to a subdirectory with the same name', () { final dir = d.dir('dir', [ d.file('name', 'contents'), - d.dir('name', [d.file('subfile', 'contents')]) + d.dir('name', [d.file('subfile', 'contents')]), ]); expect( @@ -287,9 +287,9 @@ void main() { d.dir('subdir', [ d.file('subfile1.txt', 'subcontents1'), d.file('subfile2.txt', 'subcontents2'), - d.dir('subsubdir', [d.file('subsubfile.txt', 'subsubcontents')]) + d.dir('subsubdir', [d.file('subsubfile.txt', 'subsubcontents')]), ]), - d.file('file2.txt', 'contents2') + d.file('file2.txt', 'contents2'), ]); expect( @@ -315,10 +315,10 @@ void main() { final dir = d.dir('dir', [ d.dir('subdir', [ d.file('subfile1.txt', 'subcontents1'), - d.file('subfile2.txt', 'subcontents2') + d.file('subfile2.txt', 'subcontents2'), ]), d.file('file1.txt', 'contents1'), - d.file('file2.txt', 'contents2') + d.file('file2.txt', 'contents2'), ]); await dir.create(); @@ -332,10 +332,10 @@ void main() { await d.dir('dir', [ d.dir('subdir', [ d.file('subfile1.txt', 'subcontents1'), - d.file('.hidden', 'subcontents2') + d.file('.hidden', 'subcontents2'), ]), d.file('file1.txt', 'contents1'), - d.file('.DS_Store', 'contents2') + d.file('.DS_Store', 'contents2'), ]).create(); final descriptor = d.DirectoryDescriptor.fromFilesystem( @@ -350,7 +350,7 @@ void main() { [d.file('subfile1.txt', 'subcontents1'), d.nothing('.hidden')], ), d.file('file1.txt', 'contents1'), - d.nothing('.DS_Store') + d.nothing('.DS_Store'), ]).validate(); }); }); diff --git a/pkgs/test_descriptor/test/file_test.dart b/pkgs/test_descriptor/test/file_test.dart index 26a452858..4f0137c0f 100644 --- a/pkgs/test_descriptor/test/file_test.dart +++ b/pkgs/test_descriptor/test/file_test.dart @@ -131,7 +131,7 @@ void main() { toString( allOf([ startsWith('Invalid contents for file "name.txt":'), - contains('�') + contains('�'), ]), ), ), From 23876d6d8663670c6551604e002e291d34584886 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 18 Jul 2023 18:03:45 +0000 Subject: [PATCH 50/72] Bump actions/checkout from 3.5.2 to 3.5.3 (dart-lang/test_descriptor#53) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.2 to 3.5.3.
Release notes

Sourced from actions/checkout's releases.

v3.5.3

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v3...v3.5.3

Changelog

Sourced from actions/checkout's changelog.

Changelog

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

v3.3.0

v3.2.0

v3.1.0

v3.0.2

v3.0.1

v3.0.0

v2.3.1

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=3.5.2&new-version=3.5.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/test_descriptor/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml index 46d999254..a52204779 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -24,7 +24,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} @@ -51,7 +51,7 @@ jobs: os: [ubuntu-latest] sdk: [2.17.0, dev] steps: - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} From 4964036b6d3fffd17274ff5f882883603ae7b8ba Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Sep 2023 15:08:06 +0000 Subject: [PATCH 51/72] Bump actions/checkout from 3.5.3 to 3.6.0 (dart-lang/test_descriptor#55) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.3 to 3.6.0.
Release notes

Sourced from actions/checkout's releases.

v3.6.0

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v3.5.3...v3.6.0

Changelog

Sourced from actions/checkout's changelog.

Changelog

v3.6.0

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

v3.3.0

v3.2.0

v3.1.0

v3.0.2

v3.0.1

v3.0.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=3.5.3&new-version=3.6.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/test_descriptor/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml index a52204779..4c1fa5351 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -24,7 +24,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} @@ -51,7 +51,7 @@ jobs: os: [ubuntu-latest] sdk: [2.17.0, dev] steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f with: sdk: ${{ matrix.sdk }} From ed138a979055af55ceb11d5d1b10a081424514be Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 15:09:55 +0000 Subject: [PATCH 52/72] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (dart-lang/test_descriptor#56) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.5.0 to 1.5.1.
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.
Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

  • Automatically create OIDC token for pub.dev.
  • Add a reusable workflow for publishing.

v1.3.0

v1.2.0

  • Fixed a path issue impacting git dependencies on Windows.

v1.1.0

  • Added a flavor option setup.sh to allow downloading unpublished builds.

v1.0.0

  • Promoted to 1.0 stable.

v0.5

  • Fixed a Windows pub global activate path issue.

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.5.0&new-version=1.5.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/test_descriptor/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml index 4c1fa5351..19468873b 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -25,7 +25,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: ${{ matrix.sdk }} - id: install @@ -52,7 +52,7 @@ jobs: sdk: [2.17.0, dev] steps: - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 - - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: ${{ matrix.sdk }} - id: install From 90e0e41d9a74477375deb1bdcffd56b999df9b3c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Oct 2023 18:39:51 +0000 Subject: [PATCH 53/72] Bump actions/checkout from 3.6.0 to 4.1.0 (dart-lang/test_descriptor#57) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 3.6.0 to 4.1.0.
Release notes

Sourced from actions/checkout's releases.

v4.1.0

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.0.0...v4.1.0

v4.0.0

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v3...v4.0.0

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.1.0

v4.0.0

v3.6.0

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

v3.3.0

v3.2.0

v3.1.0

v3.0.2

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=3.6.0&new-version=4.1.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/test_descriptor/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml index 19468873b..9e1802428 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -24,7 +24,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: ${{ matrix.sdk }} @@ -51,7 +51,7 @@ jobs: os: [ubuntu-latest] sdk: [2.17.0, dev] steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 with: sdk: ${{ matrix.sdk }} From dad3878657142bf10d7fe652c4f5fb4d082b3f11 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 15:45:47 +0000 Subject: [PATCH 54/72] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (dart-lang/test_descriptor#58) Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.5.1 to 1.6.0.
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).
Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

  • Automatically create OIDC token for pub.dev.
  • Add a reusable workflow for publishing.

v1.3.0

v1.2.0

  • Fixed a path issue impacting git dependencies on Windows.

v1.1.0

  • Added a flavor option setup.sh to allow downloading unpublished builds.

v1.0.0

  • Promoted to 1.0 stable.

v0.5

  • Fixed a Windows pub global activate path issue.

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.5.1&new-version=1.6.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/test_descriptor/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml index 9e1802428..f19bc50c5 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -25,7 +25,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 + - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: ${{ matrix.sdk }} - id: install @@ -52,7 +52,7 @@ jobs: sdk: [2.17.0, dev] steps: - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - uses: dart-lang/setup-dart@8a4b97ea2017cc079571daec46542f76189836b1 + - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: ${{ matrix.sdk }} - id: install From 80e218d28c3f6173dfaa33dc7690b8ca422f4a59 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 15:57:49 +0000 Subject: [PATCH 55/72] Bump actions/checkout from 4.1.0 to 4.1.1 (dart-lang/test_descriptor#59) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.0 to 4.1.1.
Release notes

Sourced from actions/checkout's releases.

v4.1.1

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.1.0...v4.1.1

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.0&new-version=4.1.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/test_descriptor/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml index f19bc50c5..836d05cc4 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -24,7 +24,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: ${{ matrix.sdk }} @@ -51,7 +51,7 @@ jobs: os: [ubuntu-latest] sdk: [2.17.0, dev] steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d with: sdk: ${{ matrix.sdk }} From 4f32b9bd61dff83adc04d619ec7294d9fbf27626 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Wed, 29 Nov 2023 10:22:38 -0800 Subject: [PATCH 56/72] Bump and fix latest lints, require Dart 3.1 (dart-lang/test_descriptor#60) --- .../.github/workflows/test-package.yml | 2 +- pkgs/test_descriptor/CHANGELOG.md | 4 ++- pkgs/test_descriptor/analysis_options.yaml | 25 +------------------ pkgs/test_descriptor/pubspec.yaml | 6 ++--- pkgs/test_descriptor/test/directory_test.dart | 1 + pkgs/test_descriptor/test/file_test.dart | 1 + pkgs/test_descriptor/test/nothing_test.dart | 2 +- pkgs/test_descriptor/test/pattern_test.dart | 2 +- pkgs/test_descriptor/test/sandbox_test.dart | 2 +- 9 files changed, 13 insertions(+), 32 deletions(-) diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml index 836d05cc4..76366984c 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -49,7 +49,7 @@ jobs: matrix: # Add macos-latest and/or windows-latest if relevant for this package. os: [ubuntu-latest] - sdk: [2.17.0, dev] + sdk: [3.1, dev] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d diff --git a/pkgs/test_descriptor/CHANGELOG.md b/pkgs/test_descriptor/CHANGELOG.md index aad67bf35..9f9ada8ab 100644 --- a/pkgs/test_descriptor/CHANGELOG.md +++ b/pkgs/test_descriptor/CHANGELOG.md @@ -1,4 +1,6 @@ -## 2.0.2-dev +## 2.0.2-wip + +* Require Dart 3.1 or later. ## 2.0.1 diff --git a/pkgs/test_descriptor/analysis_options.yaml b/pkgs/test_descriptor/analysis_options.yaml index 7806fc093..795fd9516 100644 --- a/pkgs/test_descriptor/analysis_options.yaml +++ b/pkgs/test_descriptor/analysis_options.yaml @@ -1,5 +1,5 @@ # https://dart.dev/guides/language/analysis-options -include: package:lints/recommended.yaml +include: package:dart_flutter_team_lints/analysis_options.yaml analyzer: language: @@ -9,49 +9,26 @@ analyzer: linter: rules: - - always_declare_return_types - avoid_bool_literals_in_conditional_expressions - - avoid_catching_errors - avoid_classes_with_only_static_members - - avoid_dynamic_calls - avoid_private_typedef_functions - avoid_redundant_argument_values - - avoid_returning_null - - avoid_returning_null_for_future - avoid_returning_this - avoid_unused_constructor_parameters - avoid_void_async - cancel_subscriptions - - comment_references - - directives_ordering - join_return_with_assignment - - lines_longer_than_80_chars - literal_only_boolean_expressions - missing_whitespace_between_adjacent_strings - no_adjacent_strings_in_list - no_runtimeType_toString - - omit_local_variable_types - - only_throw_errors - package_api_docs - - prefer_asserts_in_initializer_lists - - prefer_const_constructors - prefer_const_declarations - prefer_expression_function_bodies - prefer_final_locals - - prefer_relative_imports - - prefer_single_quotes - - sort_pub_dependencies - - test_types_in_equals - - throw_in_finally - - type_annotate_public_apis - - unawaited_futures - unnecessary_await_in_return - - unnecessary_lambdas - - unnecessary_parenthesis - unnecessary_raw_strings - - unnecessary_statements - use_if_null_to_convert_nulls_to_bools - use_raw_strings - use_string_buffers - - use_super_parameters - require_trailing_commas diff --git a/pkgs/test_descriptor/pubspec.yaml b/pkgs/test_descriptor/pubspec.yaml index 1e01da022..0ef134e4e 100644 --- a/pkgs/test_descriptor/pubspec.yaml +++ b/pkgs/test_descriptor/pubspec.yaml @@ -1,10 +1,10 @@ name: test_descriptor -version: 2.0.2-dev +version: 2.0.2-wip description: An API for defining and verifying files and directory structures. repository: https://github.com/dart-lang/test_descriptor environment: - sdk: '>=2.17.0 <3.0.0' + sdk: ^3.1.0 dependencies: async: ^2.5.0 @@ -14,4 +14,4 @@ dependencies: test: ^1.16.0 dev_dependencies: - lints: ^2.0.0 + dart_flutter_team_lints: ^2.0.0 diff --git a/pkgs/test_descriptor/test/directory_test.dart b/pkgs/test_descriptor/test/directory_test.dart index 321612833..bac615353 100644 --- a/pkgs/test_descriptor/test/directory_test.dart +++ b/pkgs/test_descriptor/test/directory_test.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') +library; import 'dart:async'; import 'dart:convert'; diff --git a/pkgs/test_descriptor/test/file_test.dart b/pkgs/test_descriptor/test/file_test.dart index 4f0137c0f..26e4b74b9 100644 --- a/pkgs/test_descriptor/test/file_test.dart +++ b/pkgs/test_descriptor/test/file_test.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') +library; import 'dart:convert'; import 'dart:io'; diff --git a/pkgs/test_descriptor/test/nothing_test.dart b/pkgs/test_descriptor/test/nothing_test.dart index 23d91ff4c..2663034aa 100644 --- a/pkgs/test_descriptor/test/nothing_test.dart +++ b/pkgs/test_descriptor/test/nothing_test.dart @@ -3,12 +3,12 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') +library; import 'dart:io'; import 'package:path/path.dart' as p; import 'package:test/test.dart'; - import 'package:test_descriptor/test_descriptor.dart' as d; import 'utils.dart'; diff --git a/pkgs/test_descriptor/test/pattern_test.dart b/pkgs/test_descriptor/test/pattern_test.dart index 3963fc0e1..988a66c64 100644 --- a/pkgs/test_descriptor/test/pattern_test.dart +++ b/pkgs/test_descriptor/test/pattern_test.dart @@ -3,9 +3,9 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') +library; import 'package:test/test.dart'; - import 'package:test_descriptor/test_descriptor.dart' as d; import 'utils.dart'; diff --git a/pkgs/test_descriptor/test/sandbox_test.dart b/pkgs/test_descriptor/test/sandbox_test.dart index 991bd7f41..b0eb32cb4 100644 --- a/pkgs/test_descriptor/test/sandbox_test.dart +++ b/pkgs/test_descriptor/test/sandbox_test.dart @@ -3,12 +3,12 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') +library; import 'dart:io'; import 'package:path/path.dart' as p; import 'package:test/test.dart'; - import 'package:test_descriptor/test_descriptor.dart' as d; void main() { From db63bd7ffea690c9c6773c0410ea92efd2623ccf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Feb 2024 15:28:07 +0000 Subject: [PATCH 57/72] Bump dart-lang/setup-dart from 1.6.0 to 1.6.2 (dart-lang/test_descriptor#61) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.6.0 to 1.6.2.
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.6.2

v1.6.1

  • Updated the google storage url for main channel releases.
Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.2

v1.6.1

  • Updated the google storage url for main channel releases.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

  • Automatically create OIDC token for pub.dev.
  • Add a reusable workflow for publishing.

v1.3.0

v1.2.0

  • Fixed a path issue impacting git dependencies on Windows.

v1.1.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.6.0&new-version=1.6.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/test_descriptor/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml index 76366984c..848520bf0 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -25,7 +25,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d + - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: ${{ matrix.sdk }} - id: install @@ -52,7 +52,7 @@ jobs: sdk: [3.1, dev] steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 - - uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d + - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: ${{ matrix.sdk }} - id: install From c8528c207725c357e2dddaf3e064bc4fe25021c7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 15:32:26 +0000 Subject: [PATCH 58/72] Bump actions/checkout from 4.1.1 to 4.1.2 (dart-lang/test_descriptor#62) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.1 to 4.1.2.
Release notes

Sourced from actions/checkout's releases.

v4.1.2

We are investigating the following issue with this release and have rolled-back the v4 tag to point to v4.1.1

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.1.1...v4.1.2

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.1.2

v4.1.1

v4.1.0

v4.0.0

v3.6.0

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

v3.3.0

v3.2.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.1&new-version=4.1.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/test_descriptor/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml index 848520bf0..543075c7d 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -24,7 +24,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: ${{ matrix.sdk }} @@ -51,7 +51,7 @@ jobs: os: [ubuntu-latest] sdk: [3.1, dev] steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: ${{ matrix.sdk }} From 18b52879666017b12b7018fc908eab1399d3c407 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 15:32:52 +0000 Subject: [PATCH 59/72] Bump actions/checkout from 4.1.2 to 4.1.4 (dart-lang/test_descriptor#63) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.2 to 4.1.4.
Release notes

Sourced from actions/checkout's releases.

v4.1.4

What's Changed

Full Changelog: https://github.com/actions/checkout/compare/v4.1.3...v4.1.4

v4.1.3

What's Changed

Full Changelog: https://github.com/actions/checkout/compare/v4.1.2...v4.1.3

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.1.4

v4.1.3

v4.1.2

v4.1.1

v4.1.0

v4.0.0

v3.6.0

v3.5.3

v3.5.2

v3.5.1

v3.5.0

v3.4.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.2&new-version=4.1.4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/test_descriptor/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml index 543075c7d..e7c99745c 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -24,7 +24,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: ${{ matrix.sdk }} @@ -51,7 +51,7 @@ jobs: os: [ubuntu-latest] sdk: [3.1, dev] steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: sdk: ${{ matrix.sdk }} From 3f87f74afc917e06b8c0180047020da27f5d273f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 15:35:07 +0000 Subject: [PATCH 60/72] Bump dart-lang/setup-dart from 1.6.2 to 1.6.4 (dart-lang/test_descriptor#64) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart) from 1.6.2 to 1.6.4.
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.6.4

  • Rebuild JS code to include changes from v1.6.3

v1.6.3

Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.4

  • Rebuild JS code.

v1.6.3

v1.6.2

v1.6.1

  • Updated the google storage url for main channel releases.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

  • Automatically create OIDC token for pub.dev.
  • Add a reusable workflow for publishing.

v1.3.0

  • The install location of the Dart SDK is now available

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.6.2&new-version=1.6.4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
--- pkgs/test_descriptor/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml index e7c99745c..30ee7fa3d 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -25,7 +25,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b - - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 + - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} - id: install @@ -52,7 +52,7 @@ jobs: sdk: [3.1, dev] steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b - - uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 + - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} - id: install From e74c332d264566d969a03a38fae71eb3edb3812c Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Fri, 10 May 2024 13:10:58 -0700 Subject: [PATCH 61/72] blast_repo fixes (dart-lang/test_descriptor#65) dependabot --- pkgs/test_descriptor/.github/dependabot.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/test_descriptor/.github/dependabot.yml b/pkgs/test_descriptor/.github/dependabot.yml index 439e796b4..bf6b38a4d 100644 --- a/pkgs/test_descriptor/.github/dependabot.yml +++ b/pkgs/test_descriptor/.github/dependabot.yml @@ -8,3 +8,7 @@ updates: interval: monthly labels: - autosubmit + groups: + github-actions: + patterns: + - "*" From 67dc6e8d8b93a51c27fc075748ad44c800f5db42 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 20:21:35 +0000 Subject: [PATCH 62/72] Bump actions/checkout from 4.1.4 to 4.1.5 in the github-actions group (dart-lang/test_descriptor#66) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps the github-actions group with 1 update: [actions/checkout](https://github.com/actions/checkout). Updates `actions/checkout` from 4.1.4 to 4.1.5
Release notes

Sourced from actions/checkout's releases.

v4.1.5

What's Changed

Full Changelog: https://github.com/actions/checkout/compare/v4.1.4...v4.1.5

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.4&new-version=4.1.5)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions
--- pkgs/test_descriptor/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml index 30ee7fa3d..49d743a8b 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -24,7 +24,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b + - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} @@ -51,7 +51,7 @@ jobs: os: [ubuntu-latest] sdk: [3.1, dev] steps: - - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b + - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} From 62cda695392510ebafef33e65ed3503e423ff0d8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 Jun 2024 15:04:17 +0000 Subject: [PATCH 63/72] Bump actions/checkout from 4.1.5 to 4.1.6 in the github-actions group (dart-lang/test_descriptor#67) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps the github-actions group with 1 update: [actions/checkout](https://github.com/actions/checkout). Updates `actions/checkout` from 4.1.5 to 4.1.6
Release notes

Sourced from actions/checkout's releases.

v4.1.6

What's Changed

Full Changelog: https://github.com/actions/checkout/compare/v4.1.5...v4.1.6

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.1.6

v4.1.5

v4.1.4

v4.1.3

v4.1.2

v4.1.1

v4.1.0

v4.0.0

v3.6.0

v3.5.3

v3.5.2

v3.5.1

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.5&new-version=4.1.6)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions
--- pkgs/test_descriptor/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml index 49d743a8b..9dadb116c 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -24,7 +24,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} @@ -51,7 +51,7 @@ jobs: os: [ubuntu-latest] sdk: [3.1, dev] steps: - - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 with: sdk: ${{ matrix.sdk }} From bffa621f4fd97855afb8a77255dd0483b11269ec Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 20 Jun 2024 11:27:00 -0700 Subject: [PATCH 64/72] update lints (dart-lang/test_descriptor#68) --- pkgs/test_descriptor/pubspec.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/test_descriptor/pubspec.yaml b/pkgs/test_descriptor/pubspec.yaml index 0ef134e4e..b1301a018 100644 --- a/pkgs/test_descriptor/pubspec.yaml +++ b/pkgs/test_descriptor/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: collection: ^1.15.0 path: ^1.8.0 term_glyph: ^1.2.0 - test: ^1.16.0 + test: ^1.16.6 dev_dependencies: - dart_flutter_team_lints: ^2.0.0 + dart_flutter_team_lints: ^3.0.0 From a9284c199c9b49e4b4136869ca00b565ee95bdef Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 15:27:59 +0000 Subject: [PATCH 65/72] Bump the github-actions group with 2 updates (dart-lang/test_descriptor#69) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps the github-actions group with 2 updates: [actions/checkout](https://github.com/actions/checkout) and [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart). Updates `actions/checkout` from 4.1.6 to 4.1.7
Release notes

Sourced from actions/checkout's releases.

v4.1.7

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.1.6...v4.1.7

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.1.7

v4.1.6

v4.1.5

v4.1.4

v4.1.3

v4.1.2

v4.1.1

v4.1.0

v4.0.0

v3.6.0

v3.5.3

... (truncated)

Commits

Updates `dart-lang/setup-dart` from 1.6.4 to 1.6.5
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.6.5

dart-lang/test_descriptor#118: dart-lang/setup-dartdart-lang/test_descriptor#118

Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.6.5

dart-lang/test_descriptor#118: dart-lang/setup-dartdart-lang/test_descriptor#118

v1.6.4

  • Rebuild JS code.

v1.6.3

v1.6.2

v1.6.1

  • Updated the google storage url for main channel releases.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

  • Re-wrote the implementation of the action into Dart.
  • Auto-detect the platform architecture (x64, ia32, arm, arm64).
  • Improved the caching and download resilience of the sdk.
  • Added a new action output: dart-version - the installed version of the sdk.

v1.4.0

... (truncated)

Commits

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions
--- pkgs/test_descriptor/.github/workflows/test-package.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml index 9dadb116c..ebec5d2da 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -24,8 +24,8 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: ${{ matrix.sdk }} - id: install @@ -51,8 +51,8 @@ jobs: os: [ubuntu-latest] sdk: [3.1, dev] steps: - - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 - - uses: dart-lang/setup-dart@f0ead981b4d9a35b37f30d36160575d60931ec30 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: ${{ matrix.sdk }} - id: install From 3dc3cbe3be2a7a36a155fda7183550d6b13a7cd1 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 26 Aug 2024 08:57:18 -0700 Subject: [PATCH 66/72] Fix angle brackets in doc comments (dart-lang/test_descriptor#70) --- pkgs/test_descriptor/test/utils.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/test_descriptor/test/utils.dart b/pkgs/test_descriptor/test/utils.dart index 8b07e8cd5..2d696635d 100644 --- a/pkgs/test_descriptor/test/utils.dart +++ b/pkgs/test_descriptor/test/utils.dart @@ -4,7 +4,7 @@ import 'package:test/test.dart'; -/// Converts a [Stream>] to a flat byte future. +/// Converts a [Stream]`>` to a flat byte future. Future> byteStreamToList(Stream> stream) => stream.fold([], (buffer, chunk) { buffer.addAll(chunk); From d137708dfbde159253f58e8272d7f0d404b8d7ed Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 15:57:23 +0000 Subject: [PATCH 67/72] Bump actions/checkout from 4.1.7 to 4.2.0 in the github-actions group (dart-lang/test_descriptor#71) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps the github-actions group with 1 update: [actions/checkout](https://github.com/actions/checkout). Updates `actions/checkout` from 4.1.7 to 4.2.0
Release notes

Sourced from actions/checkout's releases.

v4.2.0

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.1.7...v4.2.0

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.2.0

v4.1.7

v4.1.6

v4.1.5

v4.1.4

v4.1.3

v4.1.2

v4.1.1

v4.1.0

v4.0.0

v3.6.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.1.7&new-version=4.2.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions
--- pkgs/test_descriptor/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml index ebec5d2da..8e74bb4c5 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -24,7 +24,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: ${{ matrix.sdk }} @@ -51,7 +51,7 @@ jobs: os: [ubuntu-latest] sdk: [3.1, dev] steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: ${{ matrix.sdk }} From 3184eef9acdd9739cf2f8e8519525fff9edb7bae Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 29 Oct 2024 11:07:52 -0700 Subject: [PATCH 68/72] blast_repo fixes (dart-lang/test_descriptor#72) drop-lint --- pkgs/test_descriptor/analysis_options.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/test_descriptor/analysis_options.yaml b/pkgs/test_descriptor/analysis_options.yaml index 795fd9516..e9a8c394d 100644 --- a/pkgs/test_descriptor/analysis_options.yaml +++ b/pkgs/test_descriptor/analysis_options.yaml @@ -22,7 +22,6 @@ linter: - missing_whitespace_between_adjacent_strings - no_adjacent_strings_in_list - no_runtimeType_toString - - package_api_docs - prefer_const_declarations - prefer_expression_function_bodies - prefer_final_locals From 7369e36a1bbb9143395679fc2e3cf2fd903d8248 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 15:58:10 +0000 Subject: [PATCH 69/72] Bump actions/checkout from 4.2.0 to 4.2.2 in the github-actions group (dart-lang/test_descriptor#73) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps the github-actions group with 1 update: [actions/checkout](https://github.com/actions/checkout). Updates `actions/checkout` from 4.2.0 to 4.2.2
Release notes

Sourced from actions/checkout's releases.

v4.2.2

What's Changed

Full Changelog: https://github.com/actions/checkout/compare/v4.2.1...v4.2.2

v4.2.1

What's Changed

New Contributors

Full Changelog: https://github.com/actions/checkout/compare/v4.2.0...v4.2.1

Changelog

Sourced from actions/checkout's changelog.

Changelog

v4.2.2

v4.2.1

v4.2.0

v4.1.7

v4.1.6

v4.1.5

v4.1.4

v4.1.3

v4.1.2

v4.1.1

v4.1.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=actions/checkout&package-manager=github_actions&previous-version=4.2.0&new-version=4.2.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions
--- pkgs/test_descriptor/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml index 8e74bb4c5..9a6c3b98d 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -24,7 +24,7 @@ jobs: matrix: sdk: [dev] steps: - - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: ${{ matrix.sdk }} @@ -51,7 +51,7 @@ jobs: os: [ubuntu-latest] sdk: [3.1, dev] steps: - - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 with: sdk: ${{ matrix.sdk }} From 4d4041200d77b3f3e1d8f81dc6cf9020bd167430 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Dec 2024 15:43:30 +0000 Subject: [PATCH 70/72] Bump dart-lang/setup-dart in the github-actions group (dart-lang/test_descriptor#74) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps the github-actions group with 1 update: [dart-lang/setup-dart](https://github.com/dart-lang/setup-dart). Updates `dart-lang/setup-dart` from 1.6.5 to 1.7.0
Release notes

Sourced from dart-lang/setup-dart's releases.

v1.7.0

What's Changed

  • Install a Flutter SDK in the publish workflow allowing for publication of flutter packages.
Changelog

Sourced from dart-lang/setup-dart's changelog.

v1.7.0

v1.6.5

dart-lang/test_descriptor#118: dart-lang/setup-dartdart-lang/test_descriptor#118

v1.6.4

  • Rebuild JS code.

v1.6.3

v1.6.2

v1.6.1

  • Updated the google storage url for main channel releases.

v1.6.0

  • Enable provisioning of the latest Dart SDK patch release by specifying just the major and minor version (e.g. 3.2).

v1.5.1

  • No longer test the setup-dart action on pre-2.12 SDKs.
  • Upgrade JS interop code to use extension types (the new name for inline classes).
  • The upcoming rename of the be channel to main is now supported with forward compatibility that switches when the rename happens.

v1.5.0

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=dart-lang/setup-dart&package-manager=github_actions&previous-version=1.6.5&new-version=1.7.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions
--- pkgs/test_descriptor/.github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/pkgs/test_descriptor/.github/workflows/test-package.yml index 9a6c3b98d..65bcbdec2 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/pkgs/test_descriptor/.github/workflows/test-package.yml @@ -25,7 +25,7 @@ jobs: sdk: [dev] steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 + - uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 with: sdk: ${{ matrix.sdk }} - id: install @@ -52,7 +52,7 @@ jobs: sdk: [3.1, dev] steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - - uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 + - uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 with: sdk: ${{ matrix.sdk }} - id: install From b42c80e7023723975664bb294cd78aa1d08def10 Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 12 Dec 2024 14:03:39 +0100 Subject: [PATCH 71/72] Add issue template and other fixes --- .github/ISSUE_TEMPLATE/test_descriptor.md | 5 ++++ pkgs/test_descriptor/CONTRIBUTING.md | 33 ----------------------- pkgs/test_descriptor/pubspec.yaml | 2 +- 3 files changed, 6 insertions(+), 34 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/test_descriptor.md delete mode 100644 pkgs/test_descriptor/CONTRIBUTING.md diff --git a/.github/ISSUE_TEMPLATE/test_descriptor.md b/.github/ISSUE_TEMPLATE/test_descriptor.md new file mode 100644 index 000000000..32de9a035 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/test_descriptor.md @@ -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" +--- \ No newline at end of file diff --git a/pkgs/test_descriptor/CONTRIBUTING.md b/pkgs/test_descriptor/CONTRIBUTING.md deleted file mode 100644 index 6f5e0ea67..000000000 --- a/pkgs/test_descriptor/CONTRIBUTING.md +++ /dev/null @@ -1,33 +0,0 @@ -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). diff --git a/pkgs/test_descriptor/pubspec.yaml b/pkgs/test_descriptor/pubspec.yaml index b1301a018..9b6e6634e 100644 --- a/pkgs/test_descriptor/pubspec.yaml +++ b/pkgs/test_descriptor/pubspec.yaml @@ -1,7 +1,7 @@ name: test_descriptor version: 2.0.2-wip description: An API for defining and verifying files and directory structures. -repository: https://github.com/dart-lang/test_descriptor +repository: https://github.com/dart-lang/test/tree/master/pkgs/test_descriptor environment: sdk: ^3.1.0 From 9f70ed27e61a315f35f112dcf1349508a8a15f5c Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 12 Dec 2024 14:10:57 +0100 Subject: [PATCH 72/72] Moving fixes --- .../workflows/test_descriptor.yaml | 13 +++++++++++-- README.md | 1 + pkgs/test_descriptor/.github/dependabot.yml | 14 -------------- pkgs/test_descriptor/CHANGELOG.md | 3 ++- pkgs/test_descriptor/README.md | 2 +- pkgs/test_descriptor/pubspec.yaml | 2 +- 6 files changed, 16 insertions(+), 19 deletions(-) rename pkgs/test_descriptor/.github/workflows/test-package.yml => .github/workflows/test_descriptor.yaml (86%) delete mode 100644 pkgs/test_descriptor/.github/dependabot.yml diff --git a/pkgs/test_descriptor/.github/workflows/test-package.yml b/.github/workflows/test_descriptor.yaml similarity index 86% rename from pkgs/test_descriptor/.github/workflows/test-package.yml rename to .github/workflows/test_descriptor.yaml index 65bcbdec2..928de57c2 100644 --- a/pkgs/test_descriptor/.github/workflows/test-package.yml +++ b/.github/workflows/test_descriptor.yaml @@ -1,18 +1,27 @@ -name: Dart CI +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 -permissions: read-all + +defaults: + run: + working-directory: pkgs/test_descriptor/ jobs: # Check code formatting and static analysis on a single OS (linux) diff --git a/README.md b/README.md index 25b50aab7..9ff29e9e1 100644 --- a/README.md +++ b/README.md @@ -22,3 +22,4 @@ 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) | diff --git a/pkgs/test_descriptor/.github/dependabot.yml b/pkgs/test_descriptor/.github/dependabot.yml deleted file mode 100644 index bf6b38a4d..000000000 --- a/pkgs/test_descriptor/.github/dependabot.yml +++ /dev/null @@ -1,14 +0,0 @@ -# Dependabot configuration file. -version: 2 - -updates: - - package-ecosystem: github-actions - directory: / - schedule: - interval: monthly - labels: - - autosubmit - groups: - github-actions: - patterns: - - "*" diff --git a/pkgs/test_descriptor/CHANGELOG.md b/pkgs/test_descriptor/CHANGELOG.md index 9f9ada8ab..b9d876660 100644 --- a/pkgs/test_descriptor/CHANGELOG.md +++ b/pkgs/test_descriptor/CHANGELOG.md @@ -1,6 +1,7 @@ -## 2.0.2-wip +## 2.0.2 * Require Dart 3.1 or later. +* Move to `dart-lang/test` monorepo. ## 2.0.1 diff --git a/pkgs/test_descriptor/README.md b/pkgs/test_descriptor/README.md index d50e77667..9a1d27779 100644 --- a/pkgs/test_descriptor/README.md +++ b/pkgs/test_descriptor/README.md @@ -1,4 +1,4 @@ -[![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) +[![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) diff --git a/pkgs/test_descriptor/pubspec.yaml b/pkgs/test_descriptor/pubspec.yaml index 9b6e6634e..d9a97ac91 100644 --- a/pkgs/test_descriptor/pubspec.yaml +++ b/pkgs/test_descriptor/pubspec.yaml @@ -1,5 +1,5 @@ name: test_descriptor -version: 2.0.2-wip +version: 2.0.2 description: An API for defining and verifying files and directory structures. repository: https://github.com/dart-lang/test/tree/master/pkgs/test_descriptor