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

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: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 shellPath, 88 shellPath,
89 options, 89 options,
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 // Since '.*' does not match a newline these RegExps can be used
99 // on the entire contents of files instead of individual lines.
98 RegExp testOptionsRegExp = const RegExp(@"// VMOptions=(.*)"); 100 RegExp testOptionsRegExp = const RegExp(@"// VMOptions=(.*)");
99 RegExp dartOptionsRegExp = const RegExp(@"// DartOptions=(.*)"); 101 RegExp dartOptionsRegExp = const RegExp(@"// DartOptions=(.*)");
102
103 // Read the entire file into a byte buffer and transform it to a
104 // String. This will treat the file as ascii but the only parts
105 // we are interested in will be ascii in any case.
100 File file = new File(filename); 106 File file = new File(filename);
101 FileInputStream fileStream = file.openInputStream(); 107 file.openSync();
102 StringInputStream lines = new StringInputStream(fileStream); 108 List chars = new List(file.lengthSync());
109 var offset = 0;
110 while (offset != chars.length) {
111 offset += file.readListSync(chars, offset, chars.length - offset);
112 }
113 file.closeSync();
114 String contents = new String.fromCharCodes(chars);
115 chars = null;
103 116
117 // Find the options in the file.
104 List<List> result = new List<List>(); 118 List<List> result = new List<List>();
105 List<String> dartOptions; 119 List<String> dartOptions;
106 String line; 120 bool isNegative = false;
107 while ((line = lines.readLine()) != null) { 121
108 Match match = testOptionsRegExp.firstMatch(line); 122 Iterable<Match> matches = testOptionsRegExp.allMatches(contents);
109 if (match != null) { 123 for (var match in matches) {
110 result.add(match[1].split(' ').filter((e) => e != '')); 124 result.add(match[1].split(' ').filter((e) => e != ''));
125 }
126
127 matches = dartOptionsRegExp.allMatches(contents);
128 for (var match in matches) {
129 if (dartOptions != null) {
130 throw new Exception(
131 'More than one "// DartOptions=" line in test $filename');
111 } 132 }
133 dartOptions = match[1].split(' ').filter((e) => e != '');
134 }
112 135
113 match = dartOptionsRegExp.firstMatch(line); 136 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 } 137 }
124 138
125 void completeHandler(TestCase testCase) { 139 void completeHandler(TestCase testCase) {
126 } 140 }
127 } 141 }
OLDNEW
« no previous file with comments | « tests/corelib/test_config.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698