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

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

Issue 8995009: Implement chromium component. (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/test_runner.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"); 9 #import("multitest.dart");
10 10
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 List<String> statusFilePaths; 53 List<String> statusFilePaths;
54 Function doTest; 54 Function doTest;
55 Function doDone; 55 Function doDone;
56 ReceivePort receiveTestName; 56 ReceivePort receiveTestName;
57 TestExpectations testExpectations; 57 TestExpectations testExpectations;
58 58
59 CCTestSuite(Map this.configuration, 59 CCTestSuite(Map this.configuration,
60 String this.suiteName, 60 String this.suiteName,
61 String runnerName, 61 String runnerName,
62 List<String> this.statusFilePaths) { 62 List<String> this.statusFilePaths) {
63 runnerPath = TestUtils.buildDir(configuration) + runnerName; 63 runnerPath = TestUtils.buildDir(configuration) + '/' + runnerName;
64 } 64 }
65 65
66 void complexStatusMatching() => false; 66 void complexStatusMatching() => false;
67 67
68 void testNameHandler(String testName, ignore) { 68 void testNameHandler(String testName, ignore) {
69 if (testName == "") { 69 if (testName == "") {
70 receiveTestName.close(); 70 receiveTestName.close();
71 doDone(true); 71 doDone(true);
72 } else { 72 } else {
73 // Only run the tests that match the pattern. Use the name 73 // Only run the tests that match the pattern. Use the name
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 SummaryReport.add(expectations); 253 SummaryReport.add(expectations);
254 } 254 }
255 } 255 }
256 if (expectations.contains(SKIP)) return; 256 if (expectations.contains(SKIP)) return;
257 257
258 if (configuration['component'] == 'dartium') { 258 if (configuration['component'] == 'dartium') {
259 enqueueDartiumTest(filename, testName, optionsFromFile, 259 enqueueDartiumTest(filename, testName, optionsFromFile,
260 expectations, isNegative); 260 expectations, isNegative);
261 return; 261 return;
262 } 262 }
263 if (configuration['component'] == 'chromium') {
264 enqueueChromiumTest(filename, testName, optionsFromFile,
265 expectations, isNegative);
266 return;
267 }
268
263 // Only dartc supports fatal type errors. Enable fatal type 269 // Only dartc supports fatal type errors. Enable fatal type
264 // errors with a flag and treat tests that have fatal type 270 // errors with a flag and treat tests that have fatal type
265 // errors as negative. 271 // errors as negative.
266 var enableFatalTypeErrors = 272 var enableFatalTypeErrors =
267 (info.hasFatalTypeErrors && configuration['component'] == 'dartc'); 273 (info.hasFatalTypeErrors && configuration['component'] == 'dartc');
268 var argumentLists = argumentListsFromFile(filename, 274 var argumentLists = argumentListsFromFile(filename,
269 optionsFromFile, 275 optionsFromFile,
270 enableFatalTypeErrors); 276 enableFatalTypeErrors);
271 isNegative = isNegative || 277 isNegative = isNegative ||
272 (configuration['checked'] && info.isNegativeIfChecked) || 278 (configuration['checked'] && info.isNegativeIfChecked) ||
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 Set<String> expectations, 333 Set<String> expectations,
328 bool isNegative) { 334 bool isNegative) {
329 if (optionsFromFile['isMultitest']) return; 335 if (optionsFromFile['isMultitest']) return;
330 bool isWebTest = optionsFromFile['containsDomImport']; 336 bool isWebTest = optionsFromFile['containsDomImport'];
331 bool isLibraryDefinition = optionsFromFile['isLibraryDefinition']; 337 bool isLibraryDefinition = optionsFromFile['isLibraryDefinition'];
332 if (!isLibraryDefinition && optionsFromFile['containsSourceOrImport']) { 338 if (!isLibraryDefinition && optionsFromFile['containsSourceOrImport']) {
333 print('Warning for $filename: Browser tests require #library ' + 339 print('Warning for $filename: Browser tests require #library ' +
334 'in any file that uses #import or #source'); 340 'in any file that uses #import or #source');
335 } 341 }
336 342
337 Directory tempDir = new Directory((isWebTest ? 'client/' : '') + 343 String tempDirTemplate = '${TestUtils.buildDir(configuration)}/tmp';
338 TestUtils.buildDir(configuration) + 344 if (isWebTest) tempDirTemplate = 'client/' + tempDirTemplate;
339 'tmp'); 345 Directory tempDir = new Directory(tempDirTemplate);
340 // TODO(whesse): When implementing client web tests, 346 // TODO(whesse): When implementing client web tests,
341 // create directory in the client case, if it doesn't exist. 347 // create directory in the client case, if it doesn't exist.
342 tempDir.createTempSync(); 348 tempDir.createTempSync();
343 349
344 String dartTestFilename = new File(filename).fullPathSync(); 350 String dartTestFilename = new File(filename).fullPathSync();
345 String dartWrapperFilename = '${tempDir.path}/test.dart'; 351 String dartWrapperFilename = '${tempDir.path}/test.dart';
346 if (!isWebTest) { 352 if (!isWebTest) {
347 // test.dart will import the dart test directly, if it is a library, 353 // test.dart will import the dart test directly, if it is a library,
348 // or indirectly through test_as_library.dart, if it is not. 354 // or indirectly through test_as_library.dart, if it is not.
349 String dartLibraryFilename; 355 String dartLibraryFilename;
350 if (isLibraryDefinition) { 356 if (isLibraryDefinition) {
351 dartLibraryFilename = dartTestFilename; 357 dartLibraryFilename = dartTestFilename;
352 } else { 358 } else {
353 dartLibraryFilename = 'test_as_library.dart'; 359 dartLibraryFilename = 'test_as_library.dart';
354 File file = new File('${tempDir.path}/$dartLibraryFilename'); 360 File file = new File('${tempDir.path}/$dartLibraryFilename');
355 RandomAccessFile dartLibrary = file.openSync(writable: true); 361 RandomAccessFile dartLibrary = file.openSync(writable: true);
356 dartLibrary.writeStringSync(WrapDartTestInLibrary(dartTestFilename)); 362 dartLibrary.writeStringSync(WrapDartTestInLibrary(dartTestFilename));
357 dartLibrary.closeSync(); 363 dartLibrary.closeSync();
358 } 364 }
359 365
360 File file = new File(dartWrapperFilename); 366 File file = new File(dartWrapperFilename);
361 RandomAccessFile dartWrapper = file.openSync(writable: true); 367 RandomAccessFile dartWrapper = file.openSync(writable: true);
362 dartWrapper.writeStringSync(dartTestWrapper(dartLibraryFilename)); 368 dartWrapper.writeStringSync(DartTestWrapper(
369 'dart:dom',
370 '../../../tests/isolate/src/TestFramework.dart',
371 dartLibraryFilename));
363 dartWrapper.closeSync(); 372 dartWrapper.closeSync();
364 } else { 373 } else {
365 return; // TODO(whesse): Implement client web tests on dartium. 374 return; // TODO(whesse): Implement client web tests on dartium.
366 } 375 }
367 // Create the HTML file for the test. 376 // Create the HTML file for the test.
368 File htmlTestBase = new File('${tempDir.path}/${getHtmlName(filename)}'); 377 File htmlTestBase = new File('${tempDir.path}/${getHtmlName(filename)}');
369 RandomAccessFile htmlTest = htmlTestBase.openSync(writable: true); 378 RandomAccessFile htmlTest = htmlTestBase.openSync(writable: true);
370 htmlTest.writeStringSync(GetHtmlContents( 379 htmlTest.writeStringSync(GetHtmlContents(
371 filename, 380 filename,
372 'client/testing/unittest/test_controller.js', 381 '../../../client/testing/unittest/test_controller.js',
373 scriptType, 382 scriptType,
374 dartWrapperFilename)); 383 '../../../$dartWrapperFilename'));
375 htmlTest.closeSync(); 384 htmlTest.closeSync();
376 385
377 for (var vmOptions in optionsFromFile["vmOptions"]) { 386 for (var vmOptions in optionsFromFile["vmOptions"]) {
378 var drtFlags = ['-no-timeout']; 387 var drtFlags = ['-no-timeout'];
379 var dartFlags = ['--enable_asserts', '--enable_type_checks']; 388 var dartFlags = ['--enable_asserts', '--enable_type_checks'];
380 dartFlags.addAll(vmOptions); 389 dartFlags.addAll(vmOptions);
381 drtFlags.add('--dart-flags=${Strings.join(dartFlags, " ")}'); 390 drtFlags.add('--dart-flags=${Strings.join(dartFlags, " ")}');
382 var args = drtFlags; 391 var args = drtFlags;
383 args.add(htmlTestBase.fullPathSync()); 392 args.add(htmlTestBase.fullPathSync());
384 393
385 // Create BrowserTestCase and queue it. 394 // Create BrowserTestCase and queue it.
386 var testCase = new BrowserTestCase( 395 var testCase = new BrowserTestCase(
387 testName, 396 testName,
388 '/bin/echo', 397 null,
389 ['No compilation step for component dartium.'], 398 null,
390 dumpRenderTreeFilename, 399 dumpRenderTreeFilename,
391 args, 400 args,
392 configuration, 401 configuration,
393 completeHandler, 402 completeHandler,
394 expectations, optionsFromFile['isNegative']); 403 expectations, optionsFromFile['isNegative']);
395 doTest(testCase); 404 doTest(testCase);
396 } 405 }
397 } 406 }
398 407
399 static String dartTestWrapper(String library) { 408 void enqueueChromiumTest(String filename,
400 return DartTestWrapper('', '', 'dart:dom', 409 String testName,
401 '../../../tests/isolate/src/TestFramework.dart', 410 Map optionsFromFile,
402 library); 411 Set<String> expectations,
412 bool isNegative) {
413 if (optionsFromFile['isMultitest']) return;
414 bool isWebTest = optionsFromFile['containsDomImport'];
415 bool isLibraryDefinition = optionsFromFile['isLibraryDefinition'];
416 if (!isLibraryDefinition && optionsFromFile['containsSourceOrImport']) {
417 print('Warning for $filename: Browser tests require #library ' +
418 'in any file that uses #import or #source');
419 }
420
421 String dartDir = new File('.').fullPathSync();
422 String buildDir = TestUtils.buildDir(configuration);
423 String testPath = new File(filename).fullPathSync();
424 String outputDirBase = '$dartDir/$buildDir/generated_tests/chromium';
425
426 Expect.isTrue(testPath.startsWith(dartDir));
427 String testRelativePath = testPath.substring(dartDir.length + 1);
428 String testNameBase;
429 String testRelativeDir;
430 String testRelativeDirFlattened;
431
432 int start = testRelativePath.lastIndexOf('src' + pathSeparator);
433 if (start != -1) {
434 Expect.isTrue(testRelativePath.endsWith('.dart'));
435 testNameBase =
436 testRelativePath.substring(start + 4, testRelativePath.length - 5);
437 testRelativeDir = testRelativePath.substring(0, start - 1);
438 testRelativeDirFlattened = testRelativeDir.replaceAll(pathSeparator, '_');
439 } else {
440 Expect.fail('Web tests not imlemented yet');
441 }
442
443 if (!new Directory('$dartDir/$buildDir/generated_tests').existsSync()) {
444 new Directory('$dartDir/$buildDir/generated_tests').createSync();
445 }
446 if (!new Directory(outputDirBase).existsSync()) {
447 new Directory(outputDirBase).createSync();
448 }
449 Directory tempDir = new Directory(
450 '$outputDirBase/${testRelativeDirFlattened}_$testNameBase');
451 if (!tempDir.existsSync()) {
452 tempDir.createSync();
453 }
454
455 String dartWrapperFilename = '${tempDir.path}/test.dart';
456 String compiledDartWrapperFilename = '${tempDir.path}/test.js';
457 if (!isWebTest) {
458 // test.dart will import the dart test directly, if it is a library,
459 // or indirectly through test_as_library.dart, if it is not.
460 String dartLibraryFilename;
461 if (isLibraryDefinition) {
462 dartLibraryFilename = testPath;
463 } else {
464 dartLibraryFilename = 'test_as_library.dart';
465 File file = new File('${tempDir.path}/$dartLibraryFilename');
466 RandomAccessFile dartLibrary = file.openSync(writable: true);
467 dartLibrary.writeStringSync(WrapDartTestInLibrary(testPath));
468 dartLibrary.closeSync();
469 }
470
471 File file = new File(dartWrapperFilename);
472 RandomAccessFile dartWrapper = file.openSync(writable: true);
473 dartWrapper.writeStringSync(DartTestWrapper(
474 '$dartDir/client/testing/unittest/dom_for_unittest.dart',
475 '$dartDir/tests/isolate/src/TestFramework.dart',
476 dartLibraryFilename));
477 dartWrapper.closeSync();
478 } else {
479 return; // TODO(whesse): Implement client web tests on dartium.
480 }
481 // Create the HTML file for the test.
482 File htmlTestBase = new File('${tempDir.path}/${getHtmlName(filename)}');
483 RandomAccessFile htmlTest = htmlTestBase.openSync(writable: true);
484 htmlTest.writeStringSync(GetHtmlContents(
485 filename,
486 '$dartDir/client/testing/unittest/test_controller.js',
487 scriptType,
488 compiledDartWrapperFilename));
489 htmlTest.closeSync();
490
491 for (var vmOptions in optionsFromFile["vmOptions"]) {
492 List<String> dartcArgs = ['--work', tempDir.path];
493 if (configuration['mode'] == 'release') {
494 dartcArgs.add('--optimize');
495 }
496 dartcArgs.addAll(vmOptions);
497 dartcArgs.add('--ignore-unrecognized-flags');
498 dartcArgs.add('--out');
499 dartcArgs.add(compiledDartWrapperFilename);
500 dartcArgs.add(dartWrapperFilename);
501 // TODO(whesse): Add --fatal-type-errors if needed.
502 var args = ['--no-timeout'];
503 args.add(htmlTestBase.fullPathSync());
504
505 // Create BrowserTestCase and queue it.
506 var testCase = new BrowserTestCase(
507 testName,
508 TestUtils.dartcCompilationShellPath(configuration),
509 dartcArgs,
510 dumpRenderTreeFilename,
511 args,
512 configuration,
513 completeHandler,
514 expectations,
515 optionsFromFile['isNegative']);
516 doTest(testCase);
517 }
403 } 518 }
404 519
405 static String get scriptType() => 'application/dart'; 520 String get scriptType() {
521 switch (configuration['component']) {
522 case 'dartium':
523 return 'application/dart';
524 case 'chromium':
525 return 'text/javascript';
526 default:
527 Expect.fail('Unimplemented component scriptType');
528 return null;
529 }
530 }
531
532 String get scriptName() {
533 switch (configuration['component']) {
534 case 'dartium':
535 return tempDir.path + 'test.dart';
536 case 'chromium':
537 return tempDir.path + 'test.js';
538 default:
539 Expect.fail('Unimplemented component scriptType');
540 return null;
541 }
542 }
406 543
407 String getHtmlName(String filename) { 544 String getHtmlName(String filename) {
408 return filename.replaceAll(pathSeparator, '_') + 'dartium.html'; 545 switch (configuration['component']) {
546 case 'dartium':
547 return filename.replaceAll(pathSeparator, '_') + 'dartium.html';
548 case 'chromium':
549 return 'test.html';
550 default:
551 Expect.fail('Unimplemented component scriptType');
552 return null;
553 }
409 } 554 }
410 555
411 static String get dumpRenderTreeFilename() { 556 String get dumpRenderTreeFilename() {
412 if (new Platform().operatingSystem() == 'macos') { 557 if (new Platform().operatingSystem() == 'macos') {
413 return 'client/tests/drt/DumpRenderTree.app/Contents/' + 558 return 'client/tests/drt/DumpRenderTree.app/Contents/' +
414 'MacOS/DumpRenderTree'; 559 'MacOS/DumpRenderTree';
415 } 560 }
416 return 'client/tests/drt/DumpRenderTree'; 561 return 'client/tests/drt/DumpRenderTree';
417 } 562 }
418 563
419
420 void testGeneratorStarted() { 564 void testGeneratorStarted() {
421 ++activeTestGenerators; 565 ++activeTestGenerators;
422 } 566 }
423 567
424 void testGeneratorDone() { 568 void testGeneratorDone() {
425 --activeTestGenerators; 569 --activeTestGenerators;
426 if (activeTestGenerators == 0 && listingDone) { 570 if (activeTestGenerators == 0 && listingDone) {
427 doDone(); 571 doDone();
428 } 572 }
429 } 573 }
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 case 'leg': 764 case 'leg':
621 return 'frog/bin/frog$postfix'; 765 return 'frog/bin/frog$postfix';
622 case 'frogsh': 766 case 'frogsh':
623 return 'frog/bin/frogsh$postfix'; 767 return 'frog/bin/frogsh$postfix';
624 default: 768 default:
625 throw "Unknown executable for: ${configuration['component']}"; 769 throw "Unknown executable for: ${configuration['component']}";
626 } 770 }
627 } 771 }
628 772
629 static String dartShellFileName(Map configuration) { 773 static String dartShellFileName(Map configuration) {
630 var name = buildDir(configuration) + executableName(configuration); 774 var name = '${buildDir(configuration)}/${executableName(configuration)}';
631 if (!(new File(name)).existsSync()) { 775 if (!(new File(name)).existsSync()) {
632 throw "Executable '$name' does not exist"; 776 throw "Executable '$name' does not exist";
633 } 777 }
634 return name; 778 return name;
635 } 779 }
636 780
637 static String dartcCompilationShellPath(Map configuration) { 781 static String dartcCompilationShellPath(Map configuration) {
638 var name = buildDir(configuration) + 'compiler/bin/dartc'; 782 var name = '${buildDir(configuration)}/compiler/bin/dartc';
639 if (!(new File(name)).existsSync()) { 783 if (!(new File(name)).existsSync()) {
640 throw "Executable '$name' does not exist"; 784 throw "Executable '$name' does not exist";
641 } 785 }
642 return name; 786 return name;
643 } 787 }
644 788
645 static String outputDir(Map configuration) { 789 static String outputDir(Map configuration) {
646 var outputDir = ''; 790 var outputDir = '';
647 var system = configuration['system']; 791 var system = configuration['system'];
648 if (system == 'linux') { 792 if (system == 'linux') {
649 outputDir = 'out/'; 793 outputDir = 'out/';
650 } else if (system == 'macos') { 794 } else if (system == 'macos') {
651 outputDir = 'xcodebuild/'; 795 outputDir = 'xcodebuild/';
652 } 796 }
653 return outputDir; 797 return outputDir;
654 } 798 }
655 799
656 static String buildDir(Map configuration) { 800 static String buildDir(Map configuration) {
657 var buildDir = outputDir(configuration); 801 var buildDir = outputDir(configuration);
658 buildDir += (configuration['mode'] == 'debug') ? 'Debug_' : 'Release_'; 802 buildDir += (configuration['mode'] == 'debug') ? 'Debug_' : 'Release_';
659 buildDir += configuration['arch'] + '/'; 803 buildDir += configuration['arch'];
660 return buildDir; 804 return buildDir;
661 } 805 }
662 806
663 static List<String> standardOptions(Map configuration) { 807 static List<String> standardOptions(Map configuration) {
664 List args = ["--ignore-unrecognized-flags"]; 808 List args = ["--ignore-unrecognized-flags"];
665 if (configuration["checked"]) { 809 if (configuration["checked"]) {
666 args.add('--enable_asserts'); 810 args.add('--enable_asserts');
667 args.add("--enable_type_checks"); 811 args.add("--enable_type_checks");
668 } 812 }
669 if (configuration["component"] == "leg") { 813 if (configuration["component"] == "leg") {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 * $noCrash tests are expected to be flaky but not crash 868 * $noCrash tests are expected to be flaky but not crash
725 * $pass tests are expected to pass 869 * $pass tests are expected to pass
726 * $failOk tests are expected to fail that we won't fix 870 * $failOk tests are expected to fail that we won't fix
727 * $fail tests are expected to fail that we should fix 871 * $fail tests are expected to fail that we should fix
728 * $crash tests are expected to crash that we should fix 872 * $crash tests are expected to crash that we should fix
729 * $timeout tests are allowed to timeout\ 873 * $timeout tests are allowed to timeout\
730 """; 874 """;
731 print(report); 875 print(report);
732 } 876 }
733 } 877 }
OLDNEW
« no previous file with comments | « tools/testing/dart/test_runner.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698