diff --git a/pkg/smith/lib/builder.dart b/pkg/smith/lib/builder.dart index 673b0a99965..19b7f2c6b84 100644 --- a/pkg/smith/lib/builder.dart +++ b/pkg/smith/lib/builder.dart @@ -99,7 +99,7 @@ class Builder { final Architecture arch; final Sanitizer sanitizer; final Runtime runtime; - final List testedConfigurations; + final Set testedConfigurations; Builder(this.name, this.description, this.steps, this.system, this.mode, this.arch, this.sanitizer, this.runtime, this.testedConfigurations); @@ -167,11 +167,11 @@ String _expandVariables(String string, Map values) { return string; } -List _getTestedConfigurations(List steps) { +Set _getTestedConfigurations(List steps) { return steps .where((step) => step.isTestStep) .map((step) => step.testedConfiguration) - .toList(); + .toSet(); } T _findIfNotNull(T Function(String) find, String name) { diff --git a/pkg/smith/lib/test_matrix.dart b/pkg/smith/lib/test_matrix.dart index 5c8c35d6b0e..3d10b21ff67 100644 --- a/pkg/smith/lib/test_matrix.dart +++ b/pkg/smith/lib/test_matrix.dart @@ -56,6 +56,20 @@ class TestMatrix { var builders = parseBuilders(builderConfigurations, configurations); var branches = [...?json["branches"]]; + // Check that each configuration is tested on at most one builder. + var testedOn = {}; + for (var builder in builders) { + for (var configuration in builder.testedConfigurations) { + if (testedOn.containsKey(configuration)) { + var other = testedOn[configuration]; + throw FormatException('Configuration "${configuration.name}" is ' + 'tested on both "${builder.name}" and "${other.name}"'); + } else { + testedOn[configuration] = builder; + } + } + } + return TestMatrix._(configurations, builders, branches); } diff --git a/pkg/smith/test/test_matrix_test.dart b/pkg/smith/test/test_matrix_test.dart index 0884e67d43a..9787567f562 100644 --- a/pkg/smith/test/test_matrix_test.dart +++ b/pkg/smith/test/test_matrix_test.dart @@ -120,6 +120,35 @@ void main() { ] }); }); + + test("a configuration is tested on more than one builder", () { + expectJsonError( + 'Configuration "fasta-linux" is tested on both ' + '"test-fasta-2" and "test-fasta-1"', + { + "configurations": {"fasta-linux": {}}, + "builder_configurations": [ + { + "builders": ["test-fasta-1"], + "steps": [ + { + "name": "fasta1", + "arguments": [r"-nfasta-linux"], + }, + ], + }, + { + "builders": ["test-fasta-2"], + "steps": [ + { + "name": "fasta2", + "arguments": [r"-nfasta-linux"], + }, + ], + }, + ] + }); + }); }); test("a list of branches is parsed", () {