From 184fd507282b452a2316a436e4bb52287c9c02c7 Mon Sep 17 00:00:00 2001 From: Johnni Winther Date: Tue, 24 Aug 2021 08:02:38 +0000 Subject: [PATCH] [test_runner] Support multiple arguments in update_static_error_tests.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 Commit-Queue: Johnni Winther --- .../tool/update_static_error_tests.dart | 43 ++++++++----------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/pkg/test_runner/tool/update_static_error_tests.dart b/pkg/test_runner/tool/update_static_error_tests.dart index 053dcbd0216..23be2961104 100644 --- a/pkg/test_runner/tool/update_static_error_tests.dart +++ b/pkg/test_runner/tool/update_static_error_tests.dart @@ -112,32 +112,27 @@ Future main(List 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."); - } + 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"; + } - var result = results.rest.single; + // 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; - // 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); + if (entry is pkg_file.File) { + await _processFile(entry, + dryRun: dryRun, + includeContext: includeContext, + remove: removeSources, + insert: insertSources); + } } } }