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

Side by Side Diff: tests/standalone/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 unified diff | Download patch | Annotate | Revision Log
« tests/co19/test_config.dart ('K') | « tests/corelib/test_config.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #library("standalone_test_config"); 5 #library("standalone_test_config");
6 6
7 #import("../../tools/testing/dart/test_runner.dart"); 7 #import("../../tools/testing/dart/test_runner.dart");
8 #import("../../tools/testing/dart/status_file_parser.dart"); 8 #import("../../tools/testing/dart/status_file_parser.dart");
9 9
10 class StandaloneTestSuite { 10 class StandaloneTestSuite {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 configuration["timeout"], 90 configuration["timeout"],
91 completeHandler, 91 completeHandler,
92 expectations)); 92 expectations));
93 } 93 }
94 } 94 }
95 } 95 }
96 96
97 Map testOptions(String filename) { 97 Map testOptions(String filename) {
98 RegExp testOptionsRegExp = const RegExp(@"// VMOptions=(.*)"); 98 RegExp testOptionsRegExp = const RegExp(@"// VMOptions=(.*)");
99 RegExp dartOptionsRegExp = const RegExp(@"// DartOptions=(.*)"); 99 RegExp dartOptionsRegExp = const RegExp(@"// DartOptions=(.*)");
100
101 // Read the entire file into a byte buffer and transform it to a
102 // String. This will treat the file as ascii but the only parts
103 // we are interested in will be ascii in any case.
100 File file = new File(filename); 104 File file = new File(filename);
101 FileInputStream fileStream = file.openInputStream(); 105 file.openSync();
102 StringInputStream lines = new StringInputStream(fileStream); 106 List chars = new List(file.lengthSync());
107 var offset = 0;
108 while (offset != chars.length) {
109 offset += file.readListSync(chars, offset, chars.length - offset);
110 }
111 file.closeSync();
112 String contents = new String.fromCharCodes(chars);
113 chars = null;
103 114
115 // Find the options in the file.
104 List<List> result = new List<List>(); 116 List<List> result = new List<List>();
105 List<String> dartOptions; 117 List<String> dartOptions;
106 String line; 118 bool isNegative = false;
107 while ((line = lines.readLine()) != null) { 119
108 Match match = testOptionsRegExp.firstMatch(line); 120 Iterable<Match> matches = testOptionsRegExp.allMatches(contents);
109 if (match != null) { 121 for (var match in matches) {
110 result.add(match[1].split(' ').filter((e) => e != '')); 122 result.add(match[1].split(' ').filter((e) => e != ''));
123 }
124
125 matches = dartOptionsRegExp.allMatches(contents);
126 for (var match in matches) {
127 if (dartOptions != null) {
128 throw new Exception(
129 'More than one "// DartOptions=" line in test $filename');
111 } 130 }
131 dartOptions = match[1].split(' ').filter((e) => e != '');
132 }
112 133
113 match = dartOptionsRegExp.firstMatch(line); 134 return { "vmOptions": result, "dartOptions": dartOptions };
114 if (match != null) {
115 if (dartOptions != null) {
116 throw new Exception(
117 'More than one "// DartOptions=" line in test $filename');
118 }
119 dartOptions = match[1].split(' ').filter((e) => e != '');
120 }
121 }
122 return {"vmOptions": result, "dartOptions": dartOptions};
123 } 135 }
124 136
125 void completeHandler(TestCase testCase) { 137 void completeHandler(TestCase testCase) {
126 } 138 }
127 } 139 }
OLDNEW
« tests/co19/test_config.dart ('K') | « tests/corelib/test_config.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698