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

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: Address comments. 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
« no previous file with comments | « tools/testing/dart/multitest.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("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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 if (!isTestFile(filename)) return; 175 if (!isTestFile(filename)) return;
174 176
175 // If patterns are given only list the files that match one of the 177 // If patterns are given only list the files that match one of the
176 // patterns. 178 // patterns.
177 var patterns = configuration['patterns']; 179 var patterns = configuration['patterns'];
178 if (!patterns.isEmpty() && 180 if (!patterns.isEmpty() &&
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());
184 String testName = filename.substring(start + 4, filename.length - 5);
185 Set<String> expectations = testExpectations.expectations(testName);
186 185
187 if (expectations.contains(SKIP)) return; 186 var timeout = configuration['timeout'];
187 var optionsFromFile = optionsFromFile(filename);
188 188
189 var optionsFromFile = optionsFromFile(filename); 189 Function createTestCase(String filename,
190 var isNegative = optionsFromFile['isNegative']; 190 bool isNegative,
191 var argumentLists = argumentListsFromFile(filename, optionsFromFile); 191 [bool isNegativeIfChecked = false]) {
192 var timeout = configuration['timeout']; 192 // Look up expectations in status files using a modified file path.
193 String pathSeparator = new Platform().pathSeparator();
194 String testName;
195 int start = filename.lastIndexOf('src' + pathSeparator);
196 if (start != -1) {
197 testName = filename.substring(start + 4, filename.length - 5);
198 } else {
199 // Only multitests in a temporary directory should reach here.
200 start = filename.lastIndexOf(pathSeparator);
201 int middle = filename.lastIndexOf('_');
202 testName = filename.substring(start + 1, middle) + pathSeparator +
203 filename.substring(middle + 1, filename.length - 5);
204 }
205 Set<String> expectations = testExpectations.expectations(testName);
193 206
194 for (var args in argumentLists) { 207 if (expectations.contains(SKIP)) return;
195 doTest(new TestCase(testName, 208
196 shellPath, 209 isNegative = isNegative ||
197 args, 210 (configuration['checked'] && isNegativeIfChecked);
198 timeout, 211 var argumentLists = argumentListsFromFile(filename, optionsFromFile);
199 completeHandler, 212 for (var args in argumentLists) {
200 expectations, 213 doTest(new TestCase(testName,
201 isNegative)); 214 shellPath,
215 args,
216 timeout,
217 completeHandler,
218 expectations,
219 isNegative));
220 }
221 }
222
223
224 if (optionsFromFile['isMultitest']) {
225 DoMultitest(filename, createTestCase);
226 } else {
227 createTestCase(filename, optionsFromFile['isNegative']);
202 } 228 }
203 } 229 }
204 230
205 void completeHandler(TestCase testCase) { 231 void completeHandler(TestCase testCase) {
206 } 232 }
207 233
208 234
209 List<List<String>> argumentListsFromFile(String filename, 235 List<List<String>> argumentListsFromFile(String filename,
210 Map optionsFromFile) { 236 Map optionsFromFile) {
211 List args = TestUtils.standardOptions(configuration); 237 List args = TestUtils.standardOptions(configuration);
212 238
239 bool isMultitest = optionsFromFile["isMultitest"];
213 List<String> dartOptions = optionsFromFile["dartOptions"]; 240 List<String> dartOptions = optionsFromFile["dartOptions"];
241 List<List<String>> vmOptionsList = optionsFromFile["vmOptions"];
242 Expect.isTrue(!isMultitest || dartOptions == null);
214 args.addAll(dartOptions == null ? [filename] : dartOptions); 243 args.addAll(dartOptions == null ? [filename] : dartOptions);
215 244
216 var result = new List<List<String>>(); 245 var result = new List<List<String>>();
217 List<List<String>> vmOptionsList = optionsFromFile["vmOptions"]; 246 Expect.isFalse(vmOptionsList.isEmpty(), "empty vmOptionsList");
218 if (vmOptionsList.isEmpty()) { 247 for (var vmOptions in vmOptionsList) {
219 result.add(args); 248 if (isMultitest) {
220 } else { 249 // Make copy of vmOptions, since we will modify it at each iteration.
221 for (var vmOptions in vmOptionsList) { 250 vmOptions = new List<String>.from(vmOptions);
222 vmOptions.addAll(args);
223 result.add(vmOptions);
224 } 251 }
252 vmOptions.addAll(args);
253 result.add(vmOptions);
225 } 254 }
226 255
227 return result; 256 return result;
228 } 257 }
229 258
230 Map optionsFromFile(String filename) { 259 Map optionsFromFile(String filename) {
231 RegExp testOptionsRegExp = const RegExp(@"// VMOptions=(.*)"); 260 RegExp testOptionsRegExp = const RegExp(@"// VMOptions=(.*)");
232 RegExp dartOptionsRegExp = const RegExp(@"// DartOptions=(.*)"); 261 RegExp dartOptionsRegExp = const RegExp(@"// DartOptions=(.*)");
233 262
234 // Read the entire file into a byte buffer and transform it to a 263 // Read the entire file into a byte buffer and transform it to a
(...skipping 12 matching lines...) Expand all
247 276
248 // Find the options in the file. 277 // Find the options in the file.
249 List<List> result = new List<List>(); 278 List<List> result = new List<List>();
250 List<String> dartOptions; 279 List<String> dartOptions;
251 bool isNegative = false; 280 bool isNegative = false;
252 281
253 Iterable<Match> matches = testOptionsRegExp.allMatches(contents); 282 Iterable<Match> matches = testOptionsRegExp.allMatches(contents);
254 for (var match in matches) { 283 for (var match in matches) {
255 result.add(match[1].split(' ').filter((e) => e != '')); 284 result.add(match[1].split(' ').filter((e) => e != ''));
256 } 285 }
286 if (result.isEmpty()) result.add([]);
257 287
258 matches = dartOptionsRegExp.allMatches(contents); 288 matches = dartOptionsRegExp.allMatches(contents);
259 for (var match in matches) { 289 for (var match in matches) {
260 if (dartOptions != null) { 290 if (dartOptions != null) {
261 throw new Exception( 291 throw new Exception(
262 'More than one "// DartOptions=" line in test $filename'); 292 'More than one "// DartOptions=" line in test $filename');
263 } 293 }
264 dartOptions = match[1].split(' ').filter((e) => e != ''); 294 dartOptions = match[1].split(' ').filter((e) => e != '');
265 } 295 }
266 296
267 if (contents.contains("@compile-error") || 297 if (contents.contains("@compile-error") ||
268 contents.contains("@runtime-error")) { 298 contents.contains("@runtime-error")) {
269 isNegative = true; 299 isNegative = true;
270 } else if (contents.contains("@dynamic-type-error") && 300 } else if (contents.contains("@dynamic-type-error") &&
271 configuration['checked']) { 301 configuration['checked']) {
272 isNegative = true; 302 isNegative = true;
273 } 303 }
274 304
305 bool isMultitest = contents.contains("///");
306
275 return { "vmOptions": result, 307 return { "vmOptions": result,
276 "dartOptions": dartOptions, 308 "dartOptions": dartOptions,
277 "isNegative" : isNegative }; 309 "isNegative": isNegative,
310 "isMultitest": isMultitest};
278 } 311 }
279 } 312 }
280 313
281 314
282 class TestUtils { 315 class TestUtils {
283 static String executableName(Map configuration) { 316 static String executableName(Map configuration) {
284 String postfix = 317 String postfix =
285 (new Platform().operatingSystem() == 'windows') ? '.exe' : ''; 318 (new Platform().operatingSystem() == 'windows') ? '.exe' : '';
286 switch (configuration['component']) { 319 switch (configuration['component']) {
287 case 'vm': 320 case 'vm':
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 args.add("--enable_leg"); 363 args.add("--enable_leg");
331 } 364 }
332 if (configuration["component"] == "dartc") { 365 if (configuration["component"] == "dartc") {
333 if (configuration["mode"] == "release") { 366 if (configuration["mode"] == "release") {
334 args.add("--optimize"); 367 args.add("--optimize");
335 } 368 }
336 } 369 }
337 return args; 370 return args;
338 } 371 }
339 } 372 }
OLDNEW
« no previous file with comments | « tools/testing/dart/multitest.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698