Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(632)

Unified Diff: bin/unittest.dart

Issue 1041503002: Allow tests to be selected by name. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | pubspec.yaml » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bin/unittest.dart
diff --git a/bin/unittest.dart b/bin/unittest.dart
index 0189c8f1c4b9233f6d8c0ed6ee92c86d4f20c4f2..38d4770958c916716075bdb361b63ddb0893b194 100644
--- a/bin/unittest.dart
+++ b/bin/unittest.dart
@@ -26,6 +26,10 @@ void main(List<String> args) {
_parser.addFlag("help", abbr: "h", negatable: false,
help: "Shows this usage information.");
_parser.addOption("package-root", hide: true);
+ _parser.addOption("name",
+ abbr: 'n',
+ help: 'A substring of the name of the test to run.\n'
+ 'Regular expression syntax is supported.');
kevmoo 2015/03/28 22:02:26 In theory I like regex support, but since we allow
nweiz 2015/03/30 19:45:41 I personally hate it when I have to switch up my c
kevmoo 2015/03/30 19:51:49 I'm fine if plain text is opt in. But we should ab
nweiz 2015/03/30 20:08:09 Done.
_parser.addOption("platform",
abbr: 'p',
help: 'The platform(s) on which to run the tests.',
@@ -72,6 +76,22 @@ void main(List<String> args) {
throw new LoadException(path, 'Does not exist.');
}));
}).then((suites) {
+ suites = flatten(suites);
+
+ if (options["name"] != null) {
+ var expression = new RegExp(options["name"]);
+ suites = suites.map((suite) {
+ return suite.change(
+ tests: suite.tests.where((test) => expression.hasMatch(test.name)));
+ }).toList();
+
+ if (suites.every((suite) => suite.tests.isEmpty)) {
+ stderr.writeln('No tests match "${options["name"]}".');
+ exitCode = exit_codes.data;
+ return null;
+ }
+ }
+
var reporter = new CompactReporter(flatten(suites), color: color);
return reporter.run().then((success) {
exitCode = success ? 0 : 1;
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | pubspec.yaml » ('J')

Powered by Google App Engine
This is Rietveld 408576698