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

Unified Diff: tests/corelib/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: Just read the bytes directly from the file. 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
Index: tests/corelib/test_config.dart
diff --git a/tests/corelib/test_config.dart b/tests/corelib/test_config.dart
index ace1a9798c1e8b737559098b169d420e19e6c776..5105fb4b696a7c473773158b817109fc70458f2f 100644
--- a/tests/corelib/test_config.dart
+++ b/tests/corelib/test_config.dart
@@ -97,29 +97,41 @@ class CorelibTestSuite {
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;
- String line;
- while ((line = lines.readLine()) != null) {
- Match match = testOptionsRegExp.firstMatch(line);
- if (match != null) {
- result.add(match[1].split(' ').filter((e) => e != ''));
- }
+ bool isNegative = false;
- 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 != ''));
+ }
+
+ 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 != '');
}
- return {"vmOptions": result, "dartOptions": dartOptions};
+
+ return { "vmOptions": result, "dartOptions": dartOptions };
}
void completeHandler(TestCase testCase) {

Powered by Google App Engine
This is Rietveld 408576698