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

Side by Side Diff: tools/testing/dart/test_suite.dart

Issue 8715006: tools/test.dart: Add multitest support to Dart implementation of test runner. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years 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
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("test_suite"); 5 #library("test_suite");
6 6
7 #import("status_file_parser.dart"); 7 #import("status_file_parser.dart");
8 #import("test_runner.dart"); 8 #import("test_runner.dart");
9 #import("multitest.dart");
10
9 11
10 interface TestSuite { 12 interface TestSuite {
11 void forEachTest(Function onTest, [Function onDone]); 13 void forEachTest(Function onTest, [Function onDone]);
12 } 14 }
13 15
14 16
15 class CCTestListerIsolate extends Isolate { 17 class CCTestListerIsolate extends Isolate {
16 CCTestListerIsolate() : super.heavy(); 18 CCTestListerIsolate() : super.heavy();
17 19
18 void main() { 20 void main() {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 !patterns.some((re) => re.hasMatch(filename))) { 181 !patterns.some((re) => re.hasMatch(filename))) {
180 return; 182 return;
181 } 183 }
182 184
183 int start = filename.lastIndexOf('src' + new Platform().pathSeparator()); 185 int start = filename.lastIndexOf('src' + new Platform().pathSeparator());
184 String testName = filename.substring(start + 4, filename.length - 5); 186 String testName = filename.substring(start + 4, filename.length - 5);
185 Set<String> expectations = testExpectations.expectations(testName); 187 Set<String> expectations = testExpectations.expectations(testName);
186 188
187 if (expectations.contains(SKIP)) return; 189 if (expectations.contains(SKIP)) return;
188 190
191 var timeout = configuration['timeout'];
189 var optionsFromFile = optionsFromFile(filename); 192 var optionsFromFile = optionsFromFile(filename);
190 var isNegative = optionsFromFile['isNegative'];
191 var argumentLists = argumentListsFromFile(filename, optionsFromFile);
192 var timeout = configuration['timeout'];
193 193
194 for (var args in argumentLists) { 194 Function doTestBound(filename, isNegative, isNegativeIfChecked) {
Mads Ager (google) 2011/11/29 08:12:04 What does the 'Bound' part of this name mean? sche
195 doTest(new TestCase(testName, 195 isNegative = isNegative ||
196 shellPath, 196 (configuration['checked'] && isNegativeIfChecked);
197 args, 197 var argumentLists = argumentListsFromFile(filename, optionsFromFile);
198 timeout, 198 for (var args in argumentLists) {
199 completeHandler, 199 doTest(new TestCase(testName,
200 expectations, 200 shellPath,
201 isNegative)); 201 args,
202 timeout,
203 completeHandler,
204 expectations,
205 isNegative));
206 }
207 }
208
209
210 if (optionsFromFile['isMultitest']) {
211 DoMultitest(filename, doTestBound);
212 } else {
213 var isNegative = optionsFromFile['isNegative'];
214 doTestBound(filename, isNegative, false);
202 } 215 }
203 } 216 }
204 217
205 void completeHandler(TestCase testCase) { 218 void completeHandler(TestCase testCase) {
206 } 219 }
207 220
208 221
209 List<List<String>> argumentListsFromFile(String filename, 222 List<List<String>> argumentListsFromFile(String filename,
210 Map optionsFromFile) { 223 Map optionsFromFile) {
211 List args = TestUtils.standardOptions(configuration); 224 List args = TestUtils.standardOptions(configuration);
212 225
226 bool isMultitest = optionsFromFile["isMultitest"];
213 List<String> dartOptions = optionsFromFile["dartOptions"]; 227 List<String> dartOptions = optionsFromFile["dartOptions"];
228 List<List<String>> vmOptionsList = optionsFromFile["vmOptions"];
229 Expect.isTrue(!isMultitest || dartOptions == null);
214 args.addAll(dartOptions == null ? [filename] : dartOptions); 230 args.addAll(dartOptions == null ? [filename] : dartOptions);
215 231
216 var result = new List<List<String>>(); 232 var result = new List<List<String>>();
217 List<List<String>> vmOptionsList = optionsFromFile["vmOptions"];
218 if (vmOptionsList.isEmpty()) { 233 if (vmOptionsList.isEmpty()) {
Bill Hesse 2011/11/28 15:29:47 This if statement can be removed now.
219 result.add(args); 234 result.add(args);
220 } else { 235 } else {
221 for (var vmOptions in vmOptionsList) { 236 for (var vmOptions in vmOptionsList) {
237 if (isMultitest) {
238 // Make copy of vmOptions, since we will modify it at each iteration.
239 vmOptions = new List<String>.from(vmOptions);
240 }
222 vmOptions.addAll(args); 241 vmOptions.addAll(args);
223 result.add(vmOptions); 242 result.add(vmOptions);
243 print("vmOptions added, filename = $filename");
Mads Ager (google) 2011/11/29 08:12:04 Remove debug printing.
224 } 244 }
225 } 245 }
226 246
227 return result; 247 return result;
228 } 248 }
229 249
230 Map optionsFromFile(String filename) { 250 Map optionsFromFile(String filename) {
231 RegExp testOptionsRegExp = const RegExp(@"// VMOptions=(.*)"); 251 RegExp testOptionsRegExp = const RegExp(@"// VMOptions=(.*)");
232 RegExp dartOptionsRegExp = const RegExp(@"// DartOptions=(.*)"); 252 RegExp dartOptionsRegExp = const RegExp(@"// DartOptions=(.*)");
233 253
(...skipping 13 matching lines...) Expand all
247 267
248 // Find the options in the file. 268 // Find the options in the file.
249 List<List> result = new List<List>(); 269 List<List> result = new List<List>();
250 List<String> dartOptions; 270 List<String> dartOptions;
251 bool isNegative = false; 271 bool isNegative = false;
252 272
253 Iterable<Match> matches = testOptionsRegExp.allMatches(contents); 273 Iterable<Match> matches = testOptionsRegExp.allMatches(contents);
254 for (var match in matches) { 274 for (var match in matches) {
255 result.add(match[1].split(' ').filter((e) => e != '')); 275 result.add(match[1].split(' ').filter((e) => e != ''));
256 } 276 }
277 if (result.isEmpty()) result.add([]);
257 278
258 matches = dartOptionsRegExp.allMatches(contents); 279 matches = dartOptionsRegExp.allMatches(contents);
259 for (var match in matches) { 280 for (var match in matches) {
260 if (dartOptions != null) { 281 if (dartOptions != null) {
261 throw new Exception( 282 throw new Exception(
262 'More than one "// DartOptions=" line in test $filename'); 283 'More than one "// DartOptions=" line in test $filename');
263 } 284 }
264 dartOptions = match[1].split(' ').filter((e) => e != ''); 285 dartOptions = match[1].split(' ').filter((e) => e != '');
265 } 286 }
266 287
267 if (contents.contains("@compile-error") || 288 if (contents.contains("@compile-error") ||
268 contents.contains("@runtime-error")) { 289 contents.contains("@runtime-error")) {
269 isNegative = true; 290 isNegative = true;
270 } else if (contents.contains("@dynamic-type-error") && 291 } else if (contents.contains("@dynamic-type-error") &&
271 configuration['checked']) { 292 configuration['checked']) {
272 isNegative = true; 293 isNegative = true;
273 } 294 }
274 295
296 bool isMultitest = contents.contains("///");
297
275 return { "vmOptions": result, 298 return { "vmOptions": result,
276 "dartOptions": dartOptions, 299 "dartOptions": dartOptions,
277 "isNegative" : isNegative }; 300 "isNegative": isNegative,
301 "isMultitest": isMultitest};
278 } 302 }
279 } 303 }
280 304
281 305
282 class TestUtils { 306 class TestUtils {
283 static String executableName(Map configuration) { 307 static String executableName(Map configuration) {
284 String postfix = 308 String postfix =
285 (new Platform().operatingSystem() == 'windows') ? '.exe' : ''; 309 (new Platform().operatingSystem() == 'windows') ? '.exe' : '';
286 switch (configuration['component']) { 310 switch (configuration['component']) {
287 case 'vm': 311 case 'vm':
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 args.add("--enable_leg"); 354 args.add("--enable_leg");
331 } 355 }
332 if (configuration["component"] == "dartc") { 356 if (configuration["component"] == "dartc") {
333 if (configuration["mode"] == "release") { 357 if (configuration["mode"] == "release") {
334 args.add("--optimize"); 358 args.add("--optimize");
335 } 359 }
336 } 360 }
337 return args; 361 return args;
338 } 362 }
339 } 363 }
OLDNEW
« tools/testing/dart/multitest.dart ('K') | « tools/testing/dart/multitest.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698