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

Unified Diff: tools/testing/dart/multitest.dart

Issue 1026693002: Change Multitest files to preserve line numbers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Little more cleanup. 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/testing/dart/multitest.dart
diff --git a/tools/testing/dart/multitest.dart b/tools/testing/dart/multitest.dart
index 3aed790d6fc096cfb39cfdfac36b5dc026574772..d17c62a3ab83f3ea714b8899ce2a09e27c4b8a97 100644
--- a/tools/testing/dart/multitest.dart
+++ b/tools/testing/dart/multitest.dart
@@ -84,24 +84,27 @@ void ExtractTestsFromMultitest(Path filePath,
'checked mode compile-time error']);
List<String> testTemplate = new List<String>();
- testTemplate.add(
- '// Test created from multitest named ${filePath.toNativePath()}.');
// Create the set of multitests, which will have a new test added each
// time we see a multitest line with a new key.
Map<String, List<String>> testsAsLines = new Map<String, List<String>>();
+ // Add the template, with no multitest lines, as a test with key 'none'.
Bill Hesse 2015/03/20 10:32:57 Maybe drop the testTemplate variable completely, a
Lasse Reichstein Nielsen 2015/03/20 13:06:30 Done.
+ testsAsLines['none'] = testTemplate;
+ outcomes['none'] = new Set<String>();
+
int lineCount = 0;
for (String line in lines) {
lineCount++;
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 {
+ // Add empty line to all tests.
+ for (var test in testsAsLines.values) test.add("");
+ var testLines = testsAsLines.putIfAbsent(annotation.key,
+ () => new List<String>.from(testTemplate));
+ // Replace empty line with actual line only in matching test.
+ testLines[testLines.length - 1] = line;
+ outcomes.putIfAbsent(annotation.key, () => new Set<String>());
+ if (annotation.rest != 'continued') {
Bill Hesse 2015/03/20 10:32:57 I think the code is clearer if we remove the testL
Lasse Reichstein Nielsen 2015/03/20 13:06:30 That is more readable. Done.
for (String nextOutcome in annotation.outcomesList) {
if (validMultitestOutcomes.contains(nextOutcome)) {
outcomes[annotation.key].add(nextOutcome);
@@ -113,10 +116,15 @@ void ExtractTestsFromMultitest(Path filePath,
}
}
} else {
- testTemplate.add(line);
for (var test in testsAsLines.values) test.add(line);
}
}
+ // End marker, has a final line separator so we don't need to add it after
+ // joining the lines.
+ var marker =
+ '// Test created from multitest named ${filePath.toNativePath()}.'
+ '$line_separator';
+ for (var test in testsAsLines.values) test.add(marker);
var keysToDelete = [];
// Check that every key (other than the none case) has at least one outcome
@@ -131,16 +139,12 @@ void ExtractTestsFromMultitest(Path filePath,
}
}
// If a key/multitest was marked for deletion, do the necessary cleanup.
- keysToDelete.forEach((key) => outcomes.remove(key));
- keysToDelete.forEach((key) => testsAsLines.remove(key));
-
- // Add the template, with no multitest lines, as a test with key 'none'.
- testsAsLines['none'] = testTemplate;
- outcomes['none'] = new Set<String>();
+ keysToDelete.forEach(outcomes.remove);
+ keysToDelete.forEach(testsAsLines.remove);
// Copy all the tests into the output map tests, as multiline strings.
for (String key in testsAsLines.keys) {
- tests[key] = testsAsLines[key].join(line_separator) + line_separator;
+ tests[key] = testsAsLines[key].join(line_separator);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698