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

Unified Diff: pkg/testing/lib/src/multitest.dart

Issue 2765893003: Fix warnings_checker.dart handling of multitests (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
« no previous file with comments | « pkg/dev_compiler/test/multitest.dart ('k') | tests/compiler/dart2js/warnings_checker.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/testing/lib/src/multitest.dart
diff --git a/pkg/testing/lib/src/multitest.dart b/pkg/testing/lib/src/multitest.dart
index 5d4d1232071fa8aaf9971e867ea7be9373d2b8a0..913ec2867cebb5f3a621beb955a97afa6146ba29 100644
--- a/pkg/testing/lib/src/multitest.dart
+++ b/pkg/testing/lib/src/multitest.dart
@@ -4,19 +4,13 @@
library testing.multitest;
-import 'dart:async' show
- Stream,
- StreamTransformer;
+import 'dart:async' show Stream, StreamTransformer;
-import 'dart:io' show
- Directory,
- File;
+import 'dart:io' show Directory, File;
-import 'log.dart' show
- splitLines;
+import 'log.dart' show splitLines;
-import 'test_description.dart' show
- TestDescription;
+import 'test_description.dart' show TestDescription;
bool isError(Set<String> expectations) {
if (expectations.contains("compile-time error")) return true;
@@ -32,16 +26,17 @@ bool isCheckedModeError(Set<String> expectations) {
class MultitestTransformer
implements StreamTransformer<TestDescription, TestDescription> {
- static const String multitestMarker = "///";
+ static RegExp multitestMarker = new RegExp(r"//[#/]");
+ static int _multitestMarkerLength = 3;
static const List<String> validOutcomesList = const <String>[
- "ok",
- "compile-time error",
- "runtime error",
- "static type warning",
- "dynamic type error",
- "checked mode compile-time error",
- ];
+ "ok",
+ "compile-time error",
+ "runtime error",
+ "static type warning",
+ "dynamic type error",
+ "checked mode compile-time error",
+ ];
static final Set<String> validOutcomes =
new Set<String>.from(validOutcomesList);
@@ -52,7 +47,9 @@ class MultitestTransformer
errors.add(error);
print(error);
}
- nextTest: await for (TestDescription test in stream) {
+
+ nextTest:
+ await for (TestDescription test in stream) {
String contents = await test.file.readAsString();
if (!contents.contains(multitestMarker)) {
yield test;
@@ -74,20 +71,23 @@ class MultitestTransformer
List<String> subtestOutcomesList;
if (index != -1) {
String annotationText =
- line.substring(index + multitestMarker.length).trim();
+ line.substring(index + _multitestMarkerLength).trim();
index = annotationText.indexOf(":");
if (index != -1) {
subtestName = annotationText.substring(0, index).trim();
- subtestOutcomesList = annotationText.substring(index + 1).split(",")
- .map((s) => s.trim()).toList();
+ subtestOutcomesList = annotationText
+ .substring(index + 1)
+ .split(",")
+ .map((s) => s.trim())
+ .toList();
if (subtestName == "none") {
reportError(test.formatError(
- "$lineNumber: $subtestName can't be used as test name."));
+ "$lineNumber: $subtestName can't be used as test name."));
continue nextTest;
}
if (subtestOutcomesList.isEmpty) {
- reportError(test.formatError(
- "$lineNumber: Expected <testname>:<outcomes>"));
+ reportError(test
+ .formatError("$lineNumber: Expected <testname>:<outcomes>"));
continue nextTest;
}
}
@@ -96,8 +96,8 @@ class MultitestTransformer
List<String> lines = testsAsLines.putIfAbsent(subtestName,
() => new List<String>.from(linesWithoutAnnotations));
lines.add(line);
- Set<String> subtestOutcomes = outcomes.putIfAbsent(subtestName,
- () => new Set<String>());
+ Set<String> subtestOutcomes =
+ outcomes.putIfAbsent(subtestName, () => new Set<String>());
if (subtestOutcomesList.length != 1 ||
subtestOutcomesList.single != "continued") {
for (String outcome in subtestOutcomesList) {
@@ -105,7 +105,7 @@ class MultitestTransformer
subtestOutcomes.add(outcome);
} else {
reportError(test.formatError(
- "$lineNumber: '$outcome' isn't a recognized outcome."));
+ "$lineNumber: '$outcome' isn't a recognized outcome."));
continue nextTest;
}
}
« no previous file with comments | « pkg/dev_compiler/test/multitest.dart ('k') | tests/compiler/dart2js/warnings_checker.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698