[infra] Let tool/test.py fail if the configuration supplied with -n does not exist
This will result in:
tools/test.py -n foobar
The named configuration "foobar" does not exist. The following configurations are available:
* analyzer-asserts-linux
* analyzer-asserts-mac
* analyzer-asserts-win
* ...
Change-Id: I2fadc2ab3ae6f2b34dd373d84365d44ef27c7b8b
Reviewed-on: https://dart-review.googlesource.com/c/87325
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
diff --git a/tools/testing/dart/options.dart b/tools/testing/dart/options.dart
index 72ef8d4..b647348 100644
--- a/tools/testing/dart/options.dart
+++ b/tools/testing/dart/options.dart
@@ -514,12 +514,6 @@
return _createConfigurations(configuration);
}
- /// Prints [message] and exits with a non-zero exit code.
- void _fail(String message) {
- print(message);
- exit(1);
- }
-
/// Given a set of parsed option values, returns the list of command line
/// arguments that would reproduce that configuration.
List<String> _reproducingCommand(
@@ -904,7 +898,24 @@
Configuration getNamedConfiguration(String template) {
if (template == null) return null;
- TestMatrix testMatrix = TestMatrix.fromPath("tools/bots/test_matrix.json");
- return testMatrix.configurations
+ final testMatrixFile = "tools/bots/test_matrix.json";
+ TestMatrix testMatrix = TestMatrix.fromPath(testMatrixFile);
+ final configuration = testMatrix.configurations
.singleWhere((c) => c.name == template, orElse: () => null);
+ if (configuration == null) {
+ final names = testMatrix.configurations
+ .map((configuration) => configuration.name)
+ .toList();
+ names.sort();
+ _fail('The named configuration "$template" does not exist. The following '
+ 'configurations are available:\n * ${names.join('\n * ')}');
+ }
+
+ return configuration;
+}
+
+/// Prints [message] and exits with a non-zero exit code.
+void _fail(String message) {
+ print(message);
+ exit(1);
}