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

Unified Diff: tests/co19/test_config.dart

Issue 8486009: Optimize the processing of test options. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 9 years, 1 month 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 | tests/corelib/test_config.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/co19/test_config.dart
diff --git a/tests/co19/test_config.dart b/tests/co19/test_config.dart
index aff0555c872965637552e389bf0c641791edb178..ee57ae94409f53c9ee6ffde2dead6f1c32bbe960 100644
--- a/tests/co19/test_config.dart
+++ b/tests/co19/test_config.dart
@@ -110,41 +110,53 @@ class Co19TestSuite {
Map testOptions(String filename) {
RegExp testOptionsRegExp = const RegExp(@"// VMOptions=(.*)");
RegExp dartOptionsRegExp = const RegExp(@"// DartOptions=(.*)");
+
+ // Read the entire file into a byte buffer and transform it to a
+ // String. This will treat the file as ascii but the only parts
+ // we are interested in will be ascii in any case.
File file = new File(filename);
- FileInputStream fileStream = file.openInputStream();
- StringInputStream lines = new StringInputStream(fileStream);
+ file.openSync();
+ List chars = new List(file.lengthSync());
+ var offset = 0;
+ while (offset != chars.length) {
+ offset += file.readListSync(chars, offset, chars.length - offset);
+ }
+ file.closeSync();
+ String contents = new String.fromCharCodes(chars);
+ chars = null;
+ // Find the options in the file.
List<List> result = new List<List>();
List<String> dartOptions;
bool isNegative = false;
- String line;
- while ((line = lines.readLine()) != null) {
- Match match = testOptionsRegExp.firstMatch(line);
- if (match != null) {
- result.add(match[1].split(' ').filter((e) => e != ''));
- }
- match = dartOptionsRegExp.firstMatch(line);
- if (match != null) {
- if (dartOptions != null) {
- throw new Exception(
- 'More than one "// DartOptions=" line in test $filename');
- }
- dartOptions = match[1].split(' ').filter((e) => e != '');
- }
+ Iterable<Match> matches = testOptionsRegExp.allMatches(contents);
+ for (var match in matches) {
+ result.add(match[1].split(' ').filter((e) => e != ''));
+ }
- if (line.contains("@compile-error") || line.contains("@runtime-error")) {
- isNegative = true;
- } else if (line.contains("@dynamic-type-error") &&
- configuration['checked']) {
- isNegative = true;
+ matches = dartOptionsRegExp.allMatches(contents);
+ for (var match in matches) {
+ if (dartOptions != null) {
+ throw new Exception(
+ 'More than one "// DartOptions=" line in test $filename');
}
+ dartOptions = match[1].split(' ').filter((e) => e != '');
+ }
+
+ if (contents.contains("@compile-error") ||
+ contents.contains("@runtime-error")) {
+ isNegative = true;
+ } else if (contents.contains("@dynamic-type-error") &&
+ configuration['checked']) {
+ isNegative = true;
}
+
return { "vmOptions": result,
"dartOptions": dartOptions,
"isNegative" : isNegative };
}
- void completeHandler(TestCase testCase) {
+ void completeHandler(TestCase test) {
}
}
« no previous file with comments | « no previous file | tests/corelib/test_config.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698