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

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: 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"]) {
387 var compileCommand = getCompileCommand(vmOptions);
378 var drtFlags = ['-no-timeout']; 388 var drtFlags = ['-no-timeout'];
379 var dartFlags = ['--enable_asserts', '--enable_type_checks']; 389 var dartFlags = ['--enable_asserts', '--enable_type_checks'];
380 dartFlags.addAll(vmOptions); 390 dartFlags.addAll(vmOptions);
381 drtFlags.add('--dart-flags=${Strings.join(dartFlags, " ")}'); 391 drtFlags.add('--dart-flags=${Strings.join(dartFlags, " ")}');
382 var args = drtFlags; 392 var args = drtFlags;
383 args.add(htmlTestBase.fullPathSync()); 393 args.add(htmlTestBase.fullPathSync());
384 394
385 // Create BrowserTestCase and queue it. 395 // Create BrowserTestCase and queue it.
386 var testCase = new BrowserTestCase( 396 var testCase = new BrowserTestCase(
387 testName, 397 testName,
388 '/bin/echo', 398 compileCommand['executable'],
389 ['No compilation step for component dartium.'], 399 compileCommand['args'],
390 dumpRenderTreeFilename, 400 dumpRenderTreeFilename,
391 args, 401 args,
392 configuration, 402 configuration,
393 completeHandler, 403 completeHandler,
394 expectations, optionsFromFile['isNegative']); 404 expectations, optionsFromFile['isNegative']);
395 doTest(testCase); 405 doTest(testCase);
396 } 406 }
397 } 407 }
398 408
399 static String dartTestWrapper(String library) { 409 void enqueueChromiumTest(String filename,
400 return DartTestWrapper('', '', 'dart:dom', 410 String testName,
401 '../../../tests/isolate/src/TestFramework.dart', 411 Map optionsFromFile,
402 library); 412 Set<String> expectations,
413 bool isNegative) {
414 if (optionsFromFile['isMultitest']) return;
415 bool isWebTest = optionsFromFile['containsDomImport'];
416 bool isLibraryDefinition = optionsFromFile['isLibraryDefinition'];
417 if (!isLibraryDefinition && optionsFromFile['containsSourceOrImport']) {
418 print('Warning for $filename: Browser tests require #library ' +
419 'in any file that uses #import or #source');
420 }
421
422 String dartDir = new File('.').fullPathSync();
423 String buildDir = TestUtils.buildDir(configuration);
424 String testPath = new File(filename).fullPathSync();
425 String outputDirBase = '$dartDir/$buildDir/generated_tests/chromium';
426
427 Expect.isTrue(testPath.startsWith(dartDir));
428 String testRelativePath = testPath.substring(dartDir.length + 1);
429 String testNameBase;
430 String testRelativeDir;
431 String testRelativeDirFlattened;
432
433 int start = testRelativePath.lastIndexOf('src' + pathSeparator);
434 if (start != -1) {
435 Expect.isTrue(testRelativePath.endsWith('.dart'));
436 testNameBase =
437 testRelativePath.substring(start + 4, testRelativePath.length - 5);
438 testRelativeDir = testRelativePath.substring(0, start - 1);
Mads Ager (google) 2011/12/20 09:03:01 Two spaces after the '='. Remove one of them.
Bill Hesse 2011/12/21 15:33:43 Done.
439 testRelativeDirFlattened = testRelativeDir.replaceAll(pathSeparator, '_');
440 } else {
441 Expect.fail('Web tests not imlemented yet');
442 }
443
444 print('''
Mads Ager (google) 2011/12/20 09:03:01 Delete.
445 dartDir: $dartDir
446 buildDir: $buildDir
447 testPath: $testPath:
448 testRelativePath: $testRelativePath:
449 testNameBase: $testNameBase:
450 testRelativeDir: $testRelativeDir:
451 testRelativeDirFlattened: $testRelativeDirFlattened''');
452
453 if (!new Directory('$dartDir/$buildDir/generated_tests').existsSync()) {
454 new Directory('$dartDir/$buildDir/generated_tests').createSync();
455 }
456 if (!new Directory(outputDirBase).existsSync()) {
457 new Directory(outputDirBase).createSync();
458 }
459 Directory tempDir = new Directory(
460 '$outputDirBase/${testRelativeDirFlattened}_$testNameBase');
461 if (!tempDir.existsSync()) {
462 tempDir.createSync();
463 }
464
465 String dartWrapperFilename = '${tempDir.path}/test.dart';
466 String compiledDartWrapperFilename = '${tempDir.path}/test.js';
467 if (!isWebTest) {
468 // test.dart will import the dart test directly, if it is a library,
469 // or indirectly through test_as_library.dart, if it is not.
470 String dartLibraryFilename;
471 if (isLibraryDefinition) {
472 dartLibraryFilename = testPath;
473 } else {
474 dartLibraryFilename = 'test_as_library.dart';
475 File file = new File('${tempDir.path}/$dartLibraryFilename');
476 RandomAccessFile dartLibrary = file.openSync(writable: true);
477 dartLibrary.writeStringSync(WrapDartTestInLibrary(testPath));
478 dartLibrary.closeSync();
479 }
480
481 File file = new File(dartWrapperFilename);
482 RandomAccessFile dartWrapper = file.openSync(writable: true);
483 dartWrapper.writeStringSync(DartTestWrapper(
484 '../../../../../client/testing/unittest/dom_for_unittest.dart',
485 '../../../../../tests/isolate/src/TestFramework.dart',
486 dartLibraryFilename));
487 dartWrapper.closeSync();
488 } else {
489 return; // TODO(whesse): Implement client web tests on dartium.
490 }
491 // Create the HTML file for the test.
492 File htmlTestBase = new File('${tempDir.path}/${getHtmlName(filename)}');
493 RandomAccessFile htmlTest = htmlTestBase.openSync(writable: true);
494 htmlTest.writeStringSync(GetHtmlContents(
495 filename,
496 '../../../../../client/testing/unittest/test_controller.js',
497 scriptType,
498 compiledDartWrapperFilename));
499 htmlTest.closeSync();
500
501 for (var vmOptions in optionsFromFile["vmOptions"]) {
502 String dartcExecutable = '$dartDir/$buildDir/compiler/bin/dartc';
Mads Ager (google) 2011/12/20 09:03:01 Use the TestUtils dartc compilation helper to get
Bill Hesse 2011/12/21 15:33:43 Done.
503 List<String> dartcArgs = ['--work', tempDir.path];
504 if (configuration['mode'] == 'release') {
505 dartcArgs.add('--optimize');
506 }
507 dartcArgs.addAll(vmOptions);
508 dartcArgs.add('--ignore-unrecognized-flags');
509 dartcArgs.add('--out');
510 dartcArgs.add(compiledDartWrapperFilename);
511 dartcArgs.add(dartWrapperFilename);
512 // TODO(whesse): Add --fatal-type-errors if needed.
513 var args = ['--no-timeout'];
514 args.add(htmlTestBase.fullPathSync());
515
516 // Create BrowserTestCase and queue it.
517 var testCase = new BrowserTestCase(
518 testName,
519 dartcExecutable,
520 dartcArgs,
521 dumpRenderTreeFilename,
522 args,
523 configuration,
524 completeHandler,
525 expectations, optionsFromFile['isNegative']);
Mads Ager (google) 2011/12/20 09:03:01 Move isNegative to a separate line.
Bill Hesse 2011/12/21 15:33:43 Done.
526 doTest(testCase);
527 }
403 } 528 }
404 529
405 static String get scriptType() => 'application/dart'; 530 String get scriptType() =>
531 {'dartium': 'application/dart',
Mads Ager (google) 2011/12/20 09:03:01 Creating a map every time and performing a lookup
Bill Hesse 2011/12/21 15:33:43 Done.
532 'chromium': 'text/javascript'}[configuration['component']];
533
534 String get scriptName() => tempDir.path +
Mads Ager (google) 2011/12/20 09:03:01 Ditto.
535 {'chromium': 'test.js',
536 'dartium': 'test.dart'}[configuration['component']];
406 537
407 String getHtmlName(String filename) { 538 String getHtmlName(String filename) {
408 return filename.replaceAll(pathSeparator, '_') + 'dartium.html'; 539 return filename.replaceAll(pathSeparator, '_') + 'dartium.html';
409 } 540 }
410 541
411 static String get dumpRenderTreeFilename() { 542 String get dumpRenderTreeFilename() {
412 if (new Platform().operatingSystem() == 'macos') { 543 if (new Platform().operatingSystem() == 'macos') {
413 return 'client/tests/drt/.app/Contents/MacOS/DumpRenderTree'; 544 return 'client/tests/drt/.app/Contents/MacOS/DumpRenderTree';
414 } 545 }
415 return 'client/tests/drt/DumpRenderTree'; 546 return 'client/tests/drt/DumpRenderTree';
416 } 547 }
417 548
549 // Returns a Map with keys 'executable' and 'args'.
Bill Hesse 2011/12/19 16:18:58 This function will be removed again.
550 Map getCompileCommand(List<String> vmOptions) {
551 switch (configuration['component']) {
552 case 'dartium':
553 return {'executable': '/bin/echo',
554 'args': ['No compilation step for component dartium.']};
555 case 'chromium':
556 return {'executable': '/bin/echo',
557 'args': ['Unimplemented compilation step for component chromium.']};
558 default:
559 return {'executable': '/bin/echo',
560 'args': ['Unimplemented default case hit.']};
561 }
562 }
418 563
419 void testGeneratorStarted() { 564 void testGeneratorStarted() {
420 ++activeTestGenerators; 565 ++activeTestGenerators;
421 } 566 }
422 567
423 void testGeneratorDone() { 568 void testGeneratorDone() {
424 --activeTestGenerators; 569 --activeTestGenerators;
425 if (activeTestGenerators == 0 && listingDone) { 570 if (activeTestGenerators == 0 && listingDone) {
426 doDone(); 571 doDone();
427 } 572 }
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 case 'leg': 764 case 'leg':
620 return 'frog/bin/frog$postfix'; 765 return 'frog/bin/frog$postfix';
621 case 'frogsh': 766 case 'frogsh':
622 return 'frog/bin/frogsh$postfix'; 767 return 'frog/bin/frogsh$postfix';
623 default: 768 default:
624 throw "Unknown executable for: ${configuration['component']}"; 769 throw "Unknown executable for: ${configuration['component']}";
625 } 770 }
626 } 771 }
627 772
628 static String dartShellFileName(Map configuration) { 773 static String dartShellFileName(Map configuration) {
629 var name = buildDir(configuration) + executableName(configuration); 774 var name = '${buildDir(configuration)}/${executableName(configuration)}';
630 if (!(new File(name)).existsSync()) { 775 if (!(new File(name)).existsSync()) {
631 throw "Executable '$name' does not exist"; 776 throw "Executable '$name' does not exist";
632 } 777 }
633 return name; 778 return name;
634 } 779 }
635 780
636 static String dartcCompilationShellPath(Map configuration) { 781 static String dartcCompilationShellPath(Map configuration) {
637 var name = buildDir(configuration) + 'compiler/bin/dartc'; 782 var name = '${buildDir(configuration)}/compiler/bin/dartc';
638 if (!(new File(name)).existsSync()) { 783 if (!(new File(name)).existsSync()) {
639 throw "Executable '$name' does not exist"; 784 throw "Executable '$name' does not exist";
640 } 785 }
641 return name; 786 return name;
642 } 787 }
643 788
644 static String outputDir(Map configuration) { 789 static String outputDir(Map configuration) {
645 var outputDir = ''; 790 var outputDir = '';
646 var system = configuration['system']; 791 var system = configuration['system'];
647 if (system == 'linux') { 792 if (system == 'linux') {
648 outputDir = 'out/'; 793 outputDir = 'out/';
649 } else if (system == 'macos') { 794 } else if (system == 'macos') {
650 outputDir = 'xcodebuild/'; 795 outputDir = 'xcodebuild/';
651 } 796 }
652 return outputDir; 797 return outputDir;
653 } 798 }
654 799
655 static String buildDir(Map configuration) { 800 static String buildDir(Map configuration) {
656 var buildDir = outputDir(configuration); 801 var buildDir = outputDir(configuration);
657 buildDir += (configuration['mode'] == 'debug') ? 'Debug_' : 'Release_'; 802 buildDir += (configuration['mode'] == 'debug') ? 'Debug_' : 'Release_';
658 buildDir += configuration['arch'] + '/'; 803 buildDir += configuration['arch'];
659 return buildDir; 804 return buildDir;
660 } 805 }
661 806
662 static List<String> standardOptions(Map configuration) { 807 static List<String> standardOptions(Map configuration) {
663 List args = ["--ignore-unrecognized-flags"]; 808 List args = ["--ignore-unrecognized-flags"];
664 if (configuration["checked"]) { 809 if (configuration["checked"]) {
665 args.add('--enable_asserts'); 810 args.add('--enable_asserts');
666 args.add("--enable_type_checks"); 811 args.add("--enable_type_checks");
667 } 812 }
668 if (configuration["component"] == "leg") { 813 if (configuration["component"] == "leg") {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 * $noCrash tests are expected to be flaky but not crash 868 * $noCrash tests are expected to be flaky but not crash
724 * $pass tests are expected to pass 869 * $pass tests are expected to pass
725 * $failOk tests are expected to fail that we won't fix 870 * $failOk tests are expected to fail that we won't fix
726 * $fail tests are expected to fail that we should fix 871 * $fail tests are expected to fail that we should fix
727 * $crash tests are expected to crash that we should fix 872 * $crash tests are expected to crash that we should fix
728 * $timeout tests are allowed to timeout\ 873 * $timeout tests are allowed to timeout\
729 """; 874 """;
730 print(report); 875 print(report);
731 } 876 }
732 } 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