Chromium Code Reviews| Index: tools/testing/dart/multitest.dart |
| diff --git a/tools/testing/dart/multitest.dart b/tools/testing/dart/multitest.dart |
| index 37af902889957b93efd26dd4b22c655f37fb584e..23f634d188b928b15ae6d5a4b39e5691a1f1446e 100644 |
| --- a/tools/testing/dart/multitest.dart |
| +++ b/tools/testing/dart/multitest.dart |
| @@ -87,22 +87,21 @@ void ExtractTestsFromMultitest(String filename, |
| int lineCount = 0; |
| for (String line in lines) { |
| lineCount++; |
| - if (line.contains('///')) { |
| - var parts = line.split('///')[1].split(':'); |
| - var key = parts[0].trim(); |
| - var rest = parts[1].trim(); |
| - if (testsAsLines.containsKey(key)) { |
| - Expect.equals('continued', rest); |
| - testsAsLines[key].add(line); |
| + var annotation = new _Annotation.from(line); |
| + if (annotation != null) { |
| + testsAsLines.putIfAbsent(annotation.key, |
| + () => new List<String>.from(testTemplate)).add(line); |
| + outcomes.putIfAbsent(annotation.key, |
| + () => new Set<String>()); |
| + if (annotation.rest == 'continued') { |
| + continue; |
| } else { |
| - (testsAsLines[key] = new List<String>.from(testTemplate)).add(line); |
| - List<String> outcomesList = rest.split(','); |
| - for (String nextOutcome in outcomesList) { |
| + for (String nextOutcome in annotation.outcomesList) { |
| nextOutcome = nextOutcome.trim(); |
| - outcomes.putIfAbsent(key, () => new Set<String>()).add(nextOutcome); |
| + outcomes[annotation.key].add(nextOutcome); |
| if (!validMultitestOutcomes.contains(nextOutcome)) { |
| Expect.fail( |
| - "Invalid test directive '$nextOutcome' on line ${lineCount}: $rest "); |
| + "Invalid test directive '$nextOutcome' on line ${lineCount}: ${annotation.rest} "); |
|
Bill Hesse
2012/03/12 16:02:49
Line too long?
I think they have put concatenation
zundel
2012/03/12 20:06:23
Looks like we need to update the dart executable t
|
| } |
| } |
| } |
| @@ -111,6 +110,17 @@ void ExtractTestsFromMultitest(String filename, |
| for (var test in testsAsLines.getValues()) test.add(line); |
| } |
| } |
| + |
| + // Check that every key (other than the none case) has at least one outcome |
| + for (var outcomeKey in outcomes.getKeys()) { |
| + if (outcomeKey == "none") { |
| + continue; |
| + } |
| + if (outcomes[outcomeKey].isEmpty()) { |
|
Bill Hesse
2012/03/12 16:02:49
Why not: if outcomeKey != 'none' && outcomes[outco
zundel
2012/03/12 20:06:23
Done.
|
| + Expect.fail("Test ${outcomeKey} has no valid annotated outcomes. Expected one of: ${validMultitestOutcomes.toString()}"); |
|
Bill Hesse
2012/03/12 16:02:49
Long line.
|
| + } |
| + } |
| + |
| // Add the template, with no multitest lines, as a test with key 'none'. |
| testsAsLines['none'] = testTemplate; |
| outcomes['none'] = new Set<String>(); |
| @@ -122,6 +132,25 @@ void ExtractTestsFromMultitest(String filename, |
| } |
| } |
| +// Represents a mutlitest annotation in the special /// comment. |
| +class _Annotation { |
| + String key; |
| + String rest; |
| + List<String> outcomesList; |
| + _Annotation() {} |
| + factory _Annotation.from(String line) { |
| + if (!line.contains('///')) { |
| + return null; |
| + } |
| + var annotation = new _Annotation(); |
| + var parts = line.split('///')[1].split(':'); |
| + annotation.key = parts[0].trim(); |
| + annotation.rest = parts[1].trim(); |
| + annotation.outcomesList = annotation.rest.split(','); |
|
Bill Hesse
2012/03/12 16:02:49
annotation.outcomesList = annotation.rest.split(',
|
| + return annotation; |
| + } |
| +} |
| + |
| // Find all relative imports and copy them into the dir that contains |
| // the generated tests. |
| Set<String> _findAllRelativeImports(String topLibrary) { |