Skip to content

Commit

Permalink
[test_runner] Support multiple arguments in update_static_error_tests…
Browse files Browse the repository at this point in the history
….dart

This improves usability of the tool when a multiple tests needs updating.

Change-Id: I034e3da7381ae79b2149429e5271904e0dfcae59
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210862
Reviewed-by: Jens Johansen <[email protected]>
Commit-Queue: Johnni Winther <[email protected]>
  • Loading branch information
johnniwinther authored and [email protected] committed Aug 24, 2021
1 parent 89ba203 commit 184fd50
Showing 1 changed file with 20 additions and 25 deletions.
45 changes: 20 additions & 25 deletions pkg/test_runner/tool/update_static_error_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,32 +112,27 @@ Future<void> main(List<String> args) async {
parser, "Must provide at least one flag for an operation to perform.");
}

if (results.rest.length != 1) {
_usageError(
parser, "Must provide a file path or glob for which tests to update.");
}

var result = results.rest.single;

// Allow tests to be specified without the extension for compatibility with
// the regular test runner syntax.
if (!result.endsWith(".dart")) {
result += ".dart";
}
for (var result in results.rest) {
// Allow tests to be specified without the extension for compatibility with
// the regular test runner syntax.
if (!result.endsWith(".dart")) {
result += ".dart";
}

// Allow tests to be specified either relative to the "tests" directory
// or relative to the current directory.
var root = result.startsWith("tests") ? "." : "tests";
var glob = Glob(result, recursive: true);
for (var entry in glob.listSync(root: root)) {
if (!entry.path.endsWith(".dart")) continue;

if (entry is pkg_file.File) {
await _processFile(entry,
dryRun: dryRun,
includeContext: includeContext,
remove: removeSources,
insert: insertSources);
// Allow tests to be specified either relative to the "tests" directory
// or relative to the current directory.
var root = result.startsWith("tests") ? "." : "tests";
var glob = Glob(result, recursive: true);
for (var entry in glob.listSync(root: root)) {
if (!entry.path.endsWith(".dart")) continue;

if (entry is pkg_file.File) {
await _processFile(entry,
dryRun: dryRun,
includeContext: includeContext,
remove: removeSources,
insert: insertSources);
}
}
}
}
Expand Down

0 comments on commit 184fd50

Please sign in to comment.