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

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

Issue 2765693002: Update all tests (Closed)
Patch Set: Created 3 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
Index: tools/testing/dart/multitest.dart
diff --git a/tools/testing/dart/multitest.dart b/tools/testing/dart/multitest.dart
index b714e718e84412fefbadc5c2110b410677346906..d0402da14d4ea34fea663bbb79becbfd63297755 100644
--- a/tools/testing/dart/multitest.dart
+++ b/tools/testing/dart/multitest.dart
@@ -12,6 +12,9 @@ import "test_suite.dart";
import "utils.dart";
// Multitests are Dart test scripts containing lines of the form
+// " [some dart code] //# [key]: [error type]"
+//
+// To support legacy multi tests we also handle lines of the form
// " [some dart code] /// [key]: [error type]"
//
// For each key in the file, a new test file is made containing all
@@ -28,10 +31,10 @@ import "utils.dart";
//
// For example: file I_am_a_multitest.dart
// aaa
-// bbb /// 02: runtime error
-// ccc /// 02: continued
-// ddd /// 07: static type warning
-// eee /// 10: ok
+// bbb //# 02: runtime error
+// ccc //# 02: continued
+// ddd //# 07: static type warning
+// eee //# 10: ok
// fff
//
// should create four tests:
@@ -41,26 +44,29 @@ import "utils.dart";
//
// I_am_a_multitest_02.dart
// aaa
-// bbb /// 02: runtime error
-// ccc /// 02: continued
+// bbb //# 02: runtime error
+// ccc //# 02: continued
// fff
//
// I_am_a_multitest_07.dart
// aaa
-// ddd /// 07: static type warning
+// ddd //# 07: static type warning
// fff
//
// and I_am_a_multitest_10.dart
// aaa
-// eee /// 10: ok
+// eee //# 10: ok
// fff
//
// Note that it is possible to indicate more than one acceptable outcome
// in the case of dynamic and static type warnings
// aaa
-// ddd /// 07: static type warning, dynamic type error
+// ddd //# 07: static type warning, dynamic type error
// fff
+/// Until legacy multitests are ported we need to support both /// and //#
+final _multitestMarker = new RegExp(r"//[/#]");
+
void ExtractTestsFromMultitest(Path filePath, Map<String, String> tests,
Map<String, Set<String>> outcomes) {
// Read the entire file into a byte buffer and transform it to a
@@ -69,8 +75,10 @@ void ExtractTestsFromMultitest(Path filePath, Map<String, String> tests,
List bytes = new File(filePath.toNativePath()).readAsBytesSync();
String contents = decodeUtf8(bytes);
int first_newline = contents.indexOf('\n');
- final String line_separator = (first_newline == 0 ||
- contents[first_newline - 1] != '\r') ? '\n' : '\r\n';
+ final String line_separator =
+ (first_newline == 0 || contents[first_newline - 1] != '\r')
+ ? '\n'
+ : '\r\n';
List<String> lines = contents.split(line_separator);
if (lines.last == '') lines.removeLast();
bytes = null;
@@ -148,7 +156,7 @@ void ExtractTestsFromMultitest(Path filePath, Map<String, String> tests,
}
}
-// Represents a mutlitest annotation in the special /// comment.
+// Represents a mutlitest annotation in the special //# comment.
class _Annotation {
String key;
String rest;
@@ -157,11 +165,11 @@ class _Annotation {
factory _Annotation.from(String line) {
// Do an early return with "null" if this is not a valid multitest
// annotation.
- if (!line.contains('///')) {
+ if (!line.contains(_multitestMarker)) {
return null;
}
var parts = line
- .split('///')[1]
+ .split(_multitestMarker)[1]
.split(':')
.map((s) => s.trim())
.where((s) => s.length > 0)
@@ -220,12 +228,8 @@ Set<String> _findAllRelativeImports(Path topLibrary) {
return foundImports;
}
-Future doMultitest(
- Path filePath,
- String outputDir,
- Path suiteDir,
- CreateTest doTest,
- bool hotReload) {
+Future doMultitest(Path filePath, String outputDir, Path suiteDir,
+ CreateTest doTest, bool hotReload) {
void writeFile(String filepath, String content) {
final File file = new File(filepath);
@@ -306,8 +310,10 @@ String suiteNameFromPath(Path suiteDir) {
Path createMultitestDirectory(String outputDir, Path suiteDir, Path sourceDir) {
Path relative = sourceDir.relativeTo(suiteDir);
- Path path = new Path(outputDir).append('generated_tests')
- .append(suiteNameFromPath(suiteDir)).join(relative);
+ Path path = new Path(outputDir)
+ .append('generated_tests')
+ .append(suiteNameFromPath(suiteDir))
+ .join(relative);
TestUtils.mkdirRecursive(TestUtils.currentWorkingDirectory, path);
return new Path(new File(path.toNativePath()).absolute.path);
}

Powered by Google App Engine
This is Rietveld 408576698