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

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

Issue 9838068: Rename test.dart component to specify compiler + runtime. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 months 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') | utils/tests/css/css.status » ('j') | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 /** 5 /**
6 * Classes and methods for enumerating and preparing tests. 6 * Classes and methods for enumerating and preparing tests.
7 * 7 *
8 * This library includes: 8 * This library includes:
9 * 9 *
10 * - Creating tests by listing all the Dart files in certain directories, 10 * - Creating tests by listing all the Dart files in certain directories,
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 218
219 bool listRecursively() => false; 219 bool listRecursively() => false;
220 220
221 String shellPath() => TestUtils.dartShellFileName(configuration); 221 String shellPath() => TestUtils.dartShellFileName(configuration);
222 222
223 List<String> additionalOptions(String filename) => []; 223 List<String> additionalOptions(String filename) => [];
224 224
225 void forEachTest(Function onTest, Map testCache, String globalTempDir(), 225 void forEachTest(Function onTest, Map testCache, String globalTempDir(),
226 [Function onDone = null]) { 226 [Function onDone = null]) {
227 // If DumpRenderTree is required, and not yet updated, wait for update. 227 // If DumpRenderTree is required, and not yet updated, wait for update.
228 if (DumpRenderTreeUpdater.componentRequiresDRT(configuration['component']) 228 if (configuration['runtime'] == 'drt' && !DumpRenderTreeUpdater.updated) {
229 && !DumpRenderTreeUpdater.updated) {
230 Expect.isTrue(DumpRenderTreeUpdater.isActive); 229 Expect.isTrue(DumpRenderTreeUpdater.isActive);
231 DumpRenderTreeUpdater.onUpdated.add(() { 230 DumpRenderTreeUpdater.onUpdated.add(() {
232 forEachTest(onTest, testCache, globalTempDir, onDone); 231 forEachTest(onTest, testCache, globalTempDir, onDone);
233 }); 232 });
234 return; 233 return;
235 } 234 }
236 235
237 doTest = onTest; 236 doTest = onTest;
238 doDone = (onDone != null) ? onDone : (() => null); 237 doDone = (onDone != null) ? onDone : (() => null);
239 globalTemporaryDirectory = globalTempDir; 238 globalTemporaryDirectory = globalTempDir;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 // find tests in weird ways (testing that they contain "#"). 314 // find tests in weird ways (testing that they contain "#").
316 // They need to be redone. 315 // They need to be redone.
317 // TODO(1058): This does not work on Windows. 316 // TODO(1058): This does not work on Windows.
318 start = filename.indexOf(directoryPath); 317 start = filename.indexOf(directoryPath);
319 if (start != -1) { 318 if (start != -1) {
320 testName = filename.substring(start + directoryPath.length + 1); 319 testName = filename.substring(start + directoryPath.length + 1);
321 } else { 320 } else {
322 testName = filename; 321 testName = filename;
323 } 322 }
324 323
325 if (configuration['component'] != 'dartc') { 324 if (configuration['compiler'] != 'dartc') {
326 if (testName.endsWith('.dart')) { 325 if (testName.endsWith('.dart')) {
327 testName = testName.substring(0, testName.length - 5); 326 testName = testName.substring(0, testName.length - 5);
328 } 327 }
329 } 328 }
330 } 329 }
331 Set<String> expectations = testExpectations.expectations(testName); 330 Set<String> expectations = testExpectations.expectations(testName);
332 if (configuration['report']) { 331 if (configuration['report']) {
333 // Tests with multiple VMOptions are counted more than once. 332 // Tests with multiple VMOptions are counted more than once.
334 for (var dummy in optionsFromFile["vmOptions"]) { 333 for (var dummy in optionsFromFile["vmOptions"]) {
335 SummaryReport.add(expectations); 334 SummaryReport.add(expectations);
336 } 335 }
337 } 336 }
338 if (expectations.contains(SKIP)) return; 337 if (expectations.contains(SKIP)) return;
339 338
340 if (TestUtils.isBrowserComponent(configuration['component'])) { 339 if (TestUtils.isBrowserRuntime(configuration['runtime'])) {
341 enqueueBrowserTest(info, testName, expectations); 340 enqueueBrowserTest(info, testName, expectations);
342 } else { 341 } else {
343 enqueueStandardTest(info, testName, expectations); 342 enqueueStandardTest(info, testName, expectations);
344 } 343 }
345 } 344 }
346 345
347 void enqueueStandardTest(TestInformation info, 346 void enqueueStandardTest(TestInformation info,
348 String testName, 347 String testName,
349 Set<String> expectations) { 348 Set<String> expectations) {
350 bool isNegative = info.isNegative || 349 bool isNegative = info.isNegative ||
351 (configuration['checked'] && info.isNegativeIfChecked); 350 (configuration['checked'] && info.isNegativeIfChecked);
352 351
353 if (configuration['component'] == 'dartc') { 352 if (configuration['compiler'] == 'dartc') {
354 // dartc can detect static type warnings by the 353 // dartc can detect static type warnings by the
355 // format of the error line 354 // format of the error line
356 if (info.hasFatalTypeErrors) { 355 if (info.hasFatalTypeErrors) {
357 isNegative = true; 356 isNegative = true;
358 } else if (info.hasRuntimeErrors) { 357 } else if (info.hasRuntimeErrors) {
359 isNegative = false; 358 isNegative = false;
360 } 359 }
361 } 360 }
362 361
363 var argumentLists = argumentListsFromFile(info.filename, 362 var argumentLists = argumentListsFromFile(info.filename,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 TestUtils.buildDir(configuration), 410 TestUtils.buildDir(configuration),
412 directoryPath, 411 directoryPath,
413 createTestCase, 412 createTestCase,
414 testGeneratorDone); 413 testGeneratorDone);
415 } else { 414 } else {
416 createTestCase(filename, optionsFromFile['isNegative']); 415 createTestCase(filename, optionsFromFile['isNegative']);
417 } 416 }
418 } 417 }
419 418
420 /** 419 /**
421 * The [StandardTestSuite] has support for testing components that 420 * The [StandardTestSuite] has support for tests that
422 * compile a test from Dart to Javascript, and then run the resulting 421 * compile a test from Dart to Javascript, and then run the resulting
423 * Javascript. This function creates a working directory to hold the 422 * Javascript. This function creates a working directory to hold the
424 * Javascript version of the test, and copies the appropriate framework 423 * Javascript version of the test, and copies the appropriate framework
425 * files to that directory. It creates a [BrowserTestCase], which has 424 * files to that directory. It creates a [BrowserTestCase], which has
426 * two sequential steps to be run by the [ProcessQueue when] the test is 425 * two sequential steps to be run by the [ProcessQueue when] the test is
427 * executed: a compilation 426 * executed: a compilation
428 * step and an execution step, both with the appropriate executable and 427 * step and an execution step, both with the appropriate executable and
429 * arguments. 428 * arguments.
430 */ 429 */
431 void enqueueBrowserTest(TestInformation info, 430 void enqueueBrowserTest(TestInformation info,
432 String testName, 431 String testName,
433 Set<String> expectations) { 432 Set<String> expectations) {
434 Map optionsFromFile = info.optionsFromFile; 433 Map optionsFromFile = info.optionsFromFile;
435 String filename = info.filename; 434 String filename = info.filename;
436 if (optionsFromFile['isMultitest']) return; 435 if (optionsFromFile['isMultitest']) return;
437 bool isWebTest = optionsFromFile['containsDomImport']; 436 bool isWebTest = optionsFromFile['containsDomImport'];
438 bool isLibraryDefinition = optionsFromFile['isLibraryDefinition']; 437 bool isLibraryDefinition = optionsFromFile['isLibraryDefinition'];
439 if (!isLibraryDefinition && optionsFromFile['containsSourceOrImport']) { 438 if (!isLibraryDefinition && optionsFromFile['containsSourceOrImport']) {
440 print('Warning for $filename: Browser tests require #library ' + 439 print('Warning for $filename: Browser tests require #library ' +
441 'in any file that uses #import, #source, or #resource'); 440 'in any file that uses #import, #source, or #resource');
442 } 441 }
443 442
444 final String component = configuration['component']; 443 final String compiler = configuration['compiler'];
444 final String runtime = configuration['runtime'];
445 final String testPath = 445 final String testPath =
446 new File(filename).fullPathSync().replaceAll('\\', '/'); 446 new File(filename).fullPathSync().replaceAll('\\', '/');
447 447
448 for (var vmOptions in optionsFromFile['vmOptions']) { 448 for (var vmOptions in optionsFromFile['vmOptions']) {
449 // Create a unique temporary directory for each set of vmOptions. 449 // Create a unique temporary directory for each set of vmOptions.
450 // TODO(dart:429): Replace separate replaceAlls with a RegExp when 450 // TODO(dart:429): Replace separate replaceAlls with a RegExp when
451 // replaceAll(RegExp, String) is implemented. 451 // replaceAll(RegExp, String) is implemented.
452 String optionsName = ''; 452 String optionsName = '';
453 if (optionsFromFile['vmOptions'].length > 1) { 453 if (optionsFromFile['vmOptions'].length > 1) {
454 optionsName = Strings.join(vmOptions, '-').replaceAll('-','') 454 optionsName = Strings.join(vmOptions, '-').replaceAll('-','')
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 // TODO(efortuna): this shortening of htmlFilename is a band-aid until 492 // TODO(efortuna): this shortening of htmlFilename is a band-aid until
493 // the above TODO gets fixed. Windows cannot have paths that are longer 493 // the above TODO gets fixed. Windows cannot have paths that are longer
494 // than 260 characters, and without this hack, we were running past the 494 // than 260 characters, and without this hack, we were running past the
495 // the limit. 495 // the limit.
496 String htmlFilename = getHtmlName(filename); 496 String htmlFilename = getHtmlName(filename);
497 while ('${tempDir.path}/../$htmlFilename'.length >= 260) { 497 while ('${tempDir.path}/../$htmlFilename'.length >= 260) {
498 htmlFilename = htmlFilename.substring(htmlFilename.length~/2); 498 htmlFilename = htmlFilename.substring(htmlFilename.length~/2);
499 } 499 }
500 htmlPath = '${tempDir.path}/../$htmlFilename'; 500 htmlPath = '${tempDir.path}/../$htmlFilename';
501 } 501 }
502 final String scriptPath = (component == 'dartium') ? 502 final String scriptPath = (compiler == 'none' && runtime == 'drt') ?
503 dartWrapperFilename : compiledDartWrapperFilename; 503 dartWrapperFilename : compiledDartWrapperFilename;
504 // Create the HTML file for the test. 504 // Create the HTML file for the test.
505 RandomAccessFile htmlTest = new File(htmlPath).openSync(FileMode.WRITE); 505 RandomAccessFile htmlTest = new File(htmlPath).openSync(FileMode.WRITE);
506 String filePrefix = ''; 506 String filePrefix = '';
507 if (new Platform().operatingSystem() == 'windows') { 507 if (new Platform().operatingSystem() == 'windows') {
508 // Firefox on Windows does not like absolute file path names that start 508 // Firefox on Windows does not like absolute file path names that start
509 // with 'C:' adding 'file:///' solves the problem. 509 // with 'C:' adding 'file:///' solves the problem.
510 filePrefix = 'file:///'; 510 filePrefix = 'file:///';
511 } 511 }
512 htmlTest.writeStringSync(GetHtmlContents( 512 htmlTest.writeStringSync(GetHtmlContents(
513 filename, 513 filename,
514 '$filePrefix$dartDir/client/testing/unittest/test_controller.js', 514 '$filePrefix$dartDir/client/testing/unittest/test_controller.js',
515 scriptType, 515 scriptType,
516 filePrefix + scriptPath)); 516 filePrefix + scriptPath));
517 htmlTest.closeSync(); 517 htmlTest.closeSync();
518 518
519 // Construct the command(s) that compile all the inputs needed by the 519 // Construct the command(s) that compile all the inputs needed by the
520 // browser test. For dartium, this will be noop commands. 520 // browser test. For running Dart in DRT, this will be noop commands.
521 List<Command> commands = []; 521 List<Command> commands = [];
522 if (component != 'dartium') { 522 if (compiler != 'none' && runtime == 'drt') {
523 commands.add(_compileCommand( 523 commands.add(_compileCommand(
524 dartWrapperFilename, compiledDartWrapperFilename, 524 dartWrapperFilename, compiledDartWrapperFilename,
525 component, tempDir.path, vmOptions)); 525 compiler, tempDir.path, vmOptions));
526 526
527 // some tests require compiling multiple input scripts. 527 // some tests require compiling multiple input scripts.
528 List<String> otherScripts = optionsFromFile['otherScripts']; 528 List<String> otherScripts = optionsFromFile['otherScripts'];
529 for (String name in otherScripts) { 529 for (String name in otherScripts) {
530 int end = filename.lastIndexOf('/'); 530 int end = filename.lastIndexOf('/');
531 if (end == -1) { 531 if (end == -1) {
532 print('Warning: error processing "OtherScripts" of $filename.'); 532 print('Warning: error processing "OtherScripts" of $filename.');
533 print('Skipping test ($testName).'); 533 print('Skipping test ($testName).');
534 return; 534 return;
535 } 535 }
536 String dir = filename.substring(0, end); 536 String dir = filename.substring(0, end);
537 end = name.lastIndexOf('.dart'); 537 end = name.lastIndexOf('.dart');
538 if (end == -1) { 538 if (end == -1) {
539 print('Warning: error processing "OtherScripts" in $filename.'); 539 print('Warning: error processing "OtherScripts" in $filename.');
540 print('Skipping test ($testName).'); 540 print('Skipping test ($testName).');
541 return; 541 return;
542 } 542 }
543 String compiledName = '${name.substring(0, end)}.js'; 543 String compiledName = '${name.substring(0, end)}.js';
544 commands.add(_compileCommand( 544 commands.add(_compileCommand(
545 '$dir/$name', '${tempDir.path}/$compiledName', 545 '$dir/$name', '${tempDir.path}/$compiledName',
546 component, tempDir.path, vmOptions)); 546 compiler, tempDir.path, vmOptions));
547 } 547 }
548 } 548 }
549 549
550 // Construct the command that executes the browser test 550 // Construct the command that executes the browser test
551 List<String> args; 551 List<String> args;
552 if (component == 'webdriver') { 552 if (runtime == 'ie' || runtime == 'ff' || runtime == 'chrome' ||
553 runtime == 'safari' || runtime == 'opera') {
553 args = ['$dartDir/tools/testing/run_selenium.py', 554 args = ['$dartDir/tools/testing/run_selenium.py',
554 '--browser=${configuration["browser"]}', 555 '--browser=$runtime',
555 '--timeout=${configuration["timeout"] - 2}', 556 '--timeout=${configuration["timeout"] - 2}',
556 '--out=$htmlPath']; 557 '--out=$htmlPath'];
557 } else { 558 } else {
558 args = [ 559 args = [
559 '$dartDir/tools/testing/drt-trampoline.py', 560 '$dartDir/tools/testing/drt-trampoline.py',
560 dumpRenderTreeFilename, 561 dumpRenderTreeFilename,
561 '--no-timeout' 562 '--no-timeout'
562 ]; 563 ];
563 if (component == 'dartium') { 564 if (runtime == 'drt' && compiler == 'none') {
564 var dartFlags = ['--ignore-unrecognized-flags']; 565 var dartFlags = ['--ignore-unrecognized-flags'];
565 if (configuration["checked"]) { 566 if (configuration["checked"]) {
566 dartFlags.add('--enable_asserts'); 567 dartFlags.add('--enable_asserts');
567 dartFlags.add("--enable_type_checks"); 568 dartFlags.add("--enable_type_checks");
568 } 569 }
569 dartFlags.addAll(vmOptions); 570 dartFlags.addAll(vmOptions);
570 args.add('--dart-flags=${Strings.join(dartFlags, " ")}'); 571 args.add('--dart-flags=${Strings.join(dartFlags, " ")}');
571 } 572 }
572 args.add(htmlPath); 573 args.add(htmlPath);
573 } 574 }
574 commands.add(new Command('python', args)); 575 commands.add(new Command('python', args));
575 576
576 // Create BrowserTestCase and queue it. 577 // Create BrowserTestCase and queue it.
577 var testCase = new BrowserTestCase(testName, commands, configuration, 578 var testCase = new BrowserTestCase(testName, commands, configuration,
578 completeHandler, expectations, optionsFromFile['isNegative']); 579 completeHandler, expectations, optionsFromFile['isNegative']);
579 doTest(testCase); 580 doTest(testCase);
580 } 581 }
581 } 582 }
582 583
583 /** Helper to create a compilation command for a single input file. */ 584 /** Helper to create a compilation command for a single input file. */
584 Command _compileCommand(String inputFile, String outputFile, 585 Command _compileCommand(String inputFile, String outputFile,
585 String component, String dir, var vmOptions) { 586 String compiler, String dir, var vmOptions) {
586 String executable = TestUtils.compilerPath(configuration); 587 String executable = TestUtils.compilerPath(configuration);
587 List<String> args = TestUtils.standardOptions(configuration); 588 List<String> args = TestUtils.standardOptions(configuration);
588 switch (component) { 589 switch (compiler) {
589 case 'frogium': 590 case 'frog':
590 case 'legium': 591 case 'frogsh':
591 case 'webdriver': 592 case 'dart2js':
592 String libdir = configuration['froglib']; 593 String libdir = '$dartDir/frog/lib';
593 if (libdir == '') {
594 libdir = '$dartDir/frog/lib';
595 }
596 args.addAll(['--libdir=$libdir', 594 args.addAll(['--libdir=$libdir',
597 '--compile-only', 595 '--compile-only',
598 '--out=$outputFile']); 596 '--out=$outputFile']);
599 args.addAll(vmOptions); 597 args.addAll(vmOptions);
600 args.add(inputFile); 598 args.add(inputFile);
601 break; 599 break;
602 default: 600 default:
603 Expect.fail('unimplemented component $component'); 601 Expect.fail('unimplemented compiler $compiler');
604 } 602 }
605 return new Command(executable, args); 603 return new Command(executable, args);
606 } 604 }
607 605
608 bool get requiresCleanTemporaryDirectory() => 606 bool get requiresCleanTemporaryDirectory() =>
609 configuration['component'] == 'dartc'; 607 configuration['compiler'] == 'dartc';
610 608
611 /** 609 /**
612 * Create a directory for the generated test. If a Dart language test 610 * Create a directory for the generated test. If a Dart language test
613 * needs to be run in a browser, the Dart test needs to be embedded in 611 * needs to be run in a browser, the Dart test needs to be embedded in
614 * an HTML page, with a testing framework based on scripting and DOM events. 612 * an HTML page, with a testing framework based on scripting and DOM events.
615 * These scripts and pages are written to a generated_test directory, 613 * These scripts and pages are written to a generated_test directory,
616 * usually inside the build directory of the checkout. 614 * usually inside the build directory of the checkout.
617 * 615 *
618 * Some tests, such as those using the dartc compiler, need to be run 616 * Some tests, such as those using the dartc compiler, need to be run
619 * with an empty directory as the compiler's work directory. These 617 * with an empty directory as the compiler's work directory. These
620 * tests are copied to a subdirectory of a system-provided temporary 618 * tests are copied to a subdirectory of a system-provided temporary
621 * directory, which is deleted at the end of the test run unless the 619 * directory, which is deleted at the end of the test run unless the
622 * --keep-temporary-files flag is given. 620 * --keep-temporary-files flag is given.
623 * 621 *
624 * Those tests which are already HTML web applications (web tests), with 622 * Those tests which are already HTML web applications (web tests), with
625 * resources including CSS files and HTML files, need to be compiled into 623 * resources including CSS files and HTML files, need to be compiled into
626 * a work directory where the relative URLS to the resources work. 624 * a work directory where the relative URLS to the resources work.
627 * We use a subdirectory of the build directory that is the same number 625 * We use a subdirectory of the build directory that is the same number
628 * of levels down in the checkout as the original path of the web test. 626 * of levels down in the checkout as the original path of the web test.
629 */ 627 */
630 Directory createOutputDirectory(String testPath, String optionsName) { 628 Directory createOutputDirectory(String testPath, String optionsName) {
631 String testUniqueName = 629 String testUniqueName =
632 testPath.substring(dartDir.length + 1, testPath.length - 5); 630 testPath.substring(dartDir.length + 1, testPath.length - 5);
633 testUniqueName = testUniqueName.replaceAll('/', '_'); 631 testUniqueName = testUniqueName.replaceAll('/', '_');
634 testUniqueName += '-$optionsName'; 632 testUniqueName += '-$optionsName';
635 633
636 // Create '[build dir]/generated_tests/$component/$testUniqueName', 634 // Create '[build dir]/generated_tests/$compiler-$runtime/$testUniqueName',
637 // including any intermediate directories that don't exist. 635 // including any intermediate directories that don't exist.
638 var generatedTestPath = ['generated_tests', 636 var generatedTestPath = ['generated_tests',
639 configuration['component'], 637 configuration['compiler'] + '-' +
638 configuration['runtime'],
640 testUniqueName]; 639 testUniqueName];
641 640
642 String tempDirPath = TestUtils.buildDir(configuration); 641 String tempDirPath = TestUtils.buildDir(configuration);
643 if (requiresCleanTemporaryDirectory) { 642 if (requiresCleanTemporaryDirectory) {
644 tempDirPath = globalTemporaryDirectory(); 643 tempDirPath = globalTemporaryDirectory();
645 String debugMode = 644 String debugMode =
646 (configuration['mode'] == 'debug') ? 'Debug_' : 'Release_'; 645 (configuration['mode'] == 'debug') ? 'Debug_' : 'Release_';
647 var temp = ['${debugMode}_${configuration["arch"]}']; 646 var temp = ['${debugMode}_${configuration["arch"]}'];
648 temp.addAll(generatedTestPath); 647 temp.addAll(generatedTestPath);
649 generatedTestPath = temp; 648 generatedTestPath = temp;
(...skipping 18 matching lines...) Expand all
668 if (!tempDir.existsSync()) { 667 if (!tempDir.existsSync()) {
669 tempDir.createSync(); 668 tempDir.createSync();
670 } 669 }
671 } 670 }
672 tempDirPath = new File(tempDirPath).fullPathSync().replaceAll('\\', '/'); 671 tempDirPath = new File(tempDirPath).fullPathSync().replaceAll('\\', '/');
673 return TestUtils.mkdirRecursive(tempDirPath, 672 return TestUtils.mkdirRecursive(tempDirPath,
674 Strings.join(generatedTestPath, '/')); 673 Strings.join(generatedTestPath, '/'));
675 } 674 }
676 675
677 String get scriptType() { 676 String get scriptType() {
678 switch (configuration['component']) { 677 switch (configuration['compiler']) {
679 case 'dartium': 678 case 'none':
680 return 'application/dart'; 679 return 'application/dart';
681 case 'frogium': 680 case 'frog':
682 case 'legium': 681 case 'frogsh':
683 case 'webdriver': 682 case 'dart2js':
683 case 'dartc':
684 return 'text/javascript'; 684 return 'text/javascript';
685 default: 685 default:
686 Expect.fail('Unimplemented component scriptType'); 686 Expect.fail('Non-web runtime, so no scriptType for: ' +
687 '${configuration["compiler"]}');
687 return null; 688 return null;
688 } 689 }
689 } 690 }
690 691
691 String getHtmlName(String filename) { 692 String getHtmlName(String filename) {
692 return filename.replaceAll('/', '_').replaceAll(':', '_') 693 return filename.replaceAll('/', '_').replaceAll(':', '_')
693 .replaceAll('\\', '_') + configuration['component'] + '.html'; 694 .replaceAll('\\', '_') + configuration['compiler'] + '-' +
695 configuration['runtime'] + '.html';
694 } 696 }
695 697
696 String get dumpRenderTreeFilename() { 698 String get dumpRenderTreeFilename() {
697 if (configuration['drt'] != '') { 699 if (configuration['drt'] != '') {
698 return configuration['drt']; 700 return configuration['drt'];
699 } 701 }
700 if (new Platform().operatingSystem() == 'macos') { 702 if (new Platform().operatingSystem() == 'macos') {
701 return '$dartDir/client/tests/drt/DumpRenderTree.app/Contents/' + 703 return '$dartDir/client/tests/drt/DumpRenderTree.app/Contents/' +
702 'MacOS/DumpRenderTree'; 704 'MacOS/DumpRenderTree';
703 } 705 }
(...skipping 18 matching lines...) Expand all
722 } 724 }
723 } 725 }
724 726
725 void completeHandler(TestCase testCase) { 727 void completeHandler(TestCase testCase) {
726 } 728 }
727 729
728 List<List<String>> argumentListsFromFile(String filename, 730 List<List<String>> argumentListsFromFile(String filename,
729 Map optionsFromFile) { 731 Map optionsFromFile) {
730 List args = TestUtils.standardOptions(configuration); 732 List args = TestUtils.standardOptions(configuration);
731 args.addAll(additionalOptions(filename)); 733 args.addAll(additionalOptions(filename));
732 if (configuration['component'] == 'dartc') { 734 if (configuration['compiler'] == 'dartc') {
733 args.add('--error_format'); 735 args.add('--error_format');
734 args.add('machine'); 736 args.add('machine');
735 } 737 }
736 738
737 bool isMultitest = optionsFromFile["isMultitest"]; 739 bool isMultitest = optionsFromFile["isMultitest"];
738 List<String> dartOptions = optionsFromFile["dartOptions"]; 740 List<String> dartOptions = optionsFromFile["dartOptions"];
739 List<List<String>> vmOptionsList = optionsFromFile["vmOptions"]; 741 List<List<String>> vmOptionsList = optionsFromFile["vmOptions"];
740 Expect.isTrue(!isMultitest || dartOptions == null); 742 Expect.isTrue(!isMultitest || dartOptions == null);
741 if (dartOptions == null) { 743 if (dartOptions == null) {
742 args.add(filename); 744 args.add(filename);
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 !filename.contains('com/google/dart/compiler/vm') && 945 !filename.contains('com/google/dart/compiler/vm') &&
944 !filename.contains('com/google/dart/corelib/SharedTests.java'); 946 !filename.contains('com/google/dart/corelib/SharedTests.java');
945 947
946 void forEachTest(Function onTest, 948 void forEachTest(Function onTest,
947 Map testCacheIgnored, 949 Map testCacheIgnored,
948 String globalTempDir(), 950 String globalTempDir(),
949 [Function onDone = null]) { 951 [Function onDone = null]) {
950 doTest = onTest; 952 doTest = onTest;
951 doDone = (onDone != null) ? onDone : (() => null); 953 doDone = (onDone != null) ? onDone : (() => null);
952 954
953 if (configuration['component'] != 'dartc') { 955 if (configuration['compiler'] != 'dartc') {
954 // Do nothing. Asynchronously report that the suite is enqueued. 956 // Do nothing. Asynchronously report that the suite is enqueued.
955 new Timer(0, (timerUnused){ doDone(); }); 957 new Timer(0, (timerUnused){ doDone(); });
956 return; 958 return;
957 } 959 }
958 RegExp pattern = configuration['selectors']['dartc']; 960 RegExp pattern = configuration['selectors']['dartc'];
959 if (!pattern.hasMatch('junit_tests')) { 961 if (!pattern.hasMatch('junit_tests')) {
960 new Timer(0, (timerUnused){ doDone(); }); 962 new Timer(0, (timerUnused){ doDone(); });
961 return; 963 return;
962 } 964 }
963 965
(...skipping 25 matching lines...) Expand all
989 String testRelativePath = 991 String testRelativePath =
990 filename.substring(index + 'compiler/javatests/'.length, 992 filename.substring(index + 'compiler/javatests/'.length,
991 filename.length - '.java'.length); 993 filename.length - '.java'.length);
992 String testClass = testRelativePath.replaceAll('/', '.'); 994 String testClass = testRelativePath.replaceAll('/', '.');
993 testClasses.add(testClass); 995 testClasses.add(testClass);
994 } 996 }
995 } 997 }
996 998
997 void createTest(successIgnored) { 999 void createTest(successIgnored) {
998 String d8 = 1000 String d8 =
999 "$buildDir/d8${TestUtils.executableSuffix(configuration['component'])}"; 1001 "$buildDir/d8${TestUtils.executableSuffix(configuration['runtime'])}";
1000 List<String> args = <String>[ 1002 List<String> args = <String>[
1001 '-ea', 1003 '-ea',
1002 '-classpath', classPath, 1004 '-classpath', classPath,
1003 '-Dcom.google.dart.runner.d8=$d8', 1005 '-Dcom.google.dart.runner.d8=$d8',
1004 '-Dcom.google.dart.corelib.SharedTests.test_py=' + 1006 '-Dcom.google.dart.corelib.SharedTests.test_py=' +
1005 dartDir + '/tools/test.py', 1007 dartDir + '/tools/test.py',
1006 'org.junit.runner.JUnitCore']; 1008 'org.junit.runner.JUnitCore'];
1007 args.addAll(testClasses); 1009 args.addAll(testClasses);
1008 1010
1009 doTest(new TestCase(suiteName, 1011 doTest(new TestCase(suiteName,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 * Copy a [source] file to a new place. 1065 * Copy a [source] file to a new place.
1064 * Assumes that the directory for [dest] already exists. 1066 * Assumes that the directory for [dest] already exists.
1065 */ 1067 */
1066 static void copyFile(File source, File dest) { 1068 static void copyFile(File source, File dest) {
1067 List contents = source.readAsBytesSync(); 1069 List contents = source.readAsBytesSync();
1068 RandomAccessFile handle = dest.openSync(FileMode.WRITE); 1070 RandomAccessFile handle = dest.openSync(FileMode.WRITE);
1069 handle.writeListSync(contents, 0, contents.length); 1071 handle.writeListSync(contents, 0, contents.length);
1070 handle.closeSync(); 1072 handle.closeSync();
1071 } 1073 }
1072 1074
1073 static String executableSuffix(String component) { 1075 static String executableSuffix(String executable) {
1074 if (new Platform().operatingSystem() == 'windows') { 1076 if (new Platform().operatingSystem() == 'windows') {
1075 if (component != 'frogium' 1077 if (executable == 'd8' || executable == 'vm') {
1076 && component != 'legium'
1077 && component != 'webdriver') {
1078 return '.exe'; 1078 return '.exe';
1079 } else { 1079 } else {
1080 return '.bat'; 1080 return '.bat';
1081 } 1081 }
1082 } 1082 }
1083 return ''; 1083 return '';
1084 } 1084 }
1085 1085
1086 static String executableName(Map configuration) { 1086 static String executableName(Map configuration) {
1087 String suffix = executableSuffix(configuration['component']); 1087 String suffix = executableSuffix(configuration['compiler']);
1088 switch (configuration['component']) { 1088 switch (configuration['compiler']) {
1089 case 'vm': 1089 case 'none':
1090 return 'dart$suffix'; 1090 return 'dart$suffix';
1091 case 'dartc': 1091 case 'dartc':
1092 return 'compiler/bin/dartc$suffix'; 1092 return 'compiler/bin/dartc$suffix';
1093 case 'frog': 1093 case 'frog':
1094 case 'dart2js': 1094 case 'dart2js':
1095 return 'frog/bin/frog$suffix'; 1095 return 'frog/bin/frog$suffix';
1096 case 'frogsh': 1096 case 'frogsh':
1097 return 'frog/bin/frogsh$suffix'; 1097 return 'frog/bin/frogsh$suffix';
1098 default: 1098 default:
1099 throw "Unknown executable for: ${configuration['component']}"; 1099 throw "Unknown executable for: ${configuration['compiler']}";
1100 } 1100 }
1101 } 1101 }
1102 1102
1103 static String compilerName(Map configuration) { 1103 static String compilerName(Map configuration) {
1104 String suffix = executableSuffix(configuration['component']); 1104 String suffix = executableSuffix(configuration['compiler']);
1105 switch (configuration['component']) { 1105 switch (configuration['compiler']) {
1106 case 'dartc': 1106 case 'dartc':
1107 return 'compiler/bin/dartc$suffix'; 1107 return 'compiler/bin/dartc$suffix';
1108 case 'frogium': 1108 case 'frog':
1109 case 'legium': 1109 case 'dart2js':
1110 case 'webdriver':
1111 return 'frog/bin/frog$suffix'; 1110 return 'frog/bin/frog$suffix';
1112 default: 1111 default:
1113 throw "Unknown compiler for: ${configuration['component']}"; 1112 throw "Unknown compiler for: ${configuration['compiler']}";
1114 } 1113 }
1115 } 1114 }
1116 1115
1117 static String dartShellFileName(Map configuration) { 1116 static String dartShellFileName(Map configuration) {
1118 var name = '${buildDir(configuration)}/${executableName(configuration)}'; 1117 var name = '${buildDir(configuration)}/${executableName(configuration)}';
1119 if (!(new File(name)).existsSync() && !configuration['list']) { 1118 if (!(new File(name)).existsSync() && !configuration['list']) {
1120 throw "Executable '$name' does not exist"; 1119 throw "Executable '$name' does not exist";
1121 } 1120 }
1122 return name; 1121 return name;
1123 } 1122 }
1124 1123
1125 static String compilerPath(Map configuration) { 1124 static String compilerPath(Map configuration) {
1126 if (configuration['component'] == 'dartium') { 1125 if (configuration['compiler'] == 'none') {
1127 return null; // No separate compiler for dartium tests. 1126 return null; // No separate compiler for dartium tests.
1128 } 1127 }
1129 var name = configuration['frog']; 1128 var name = '${buildDir(configuration)}/${compilerName(configuration)}';
1130 if (name == '') {
1131 name = '${buildDir(configuration)}/${compilerName(configuration)}';
1132 }
1133 if (!(new File(name)).existsSync() && !configuration['list']) { 1129 if (!(new File(name)).existsSync() && !configuration['list']) {
1134 throw "Executable '$name' does not exist"; 1130 throw "Executable '$name' does not exist";
1135 } 1131 }
1136 return name; 1132 return name;
1137 } 1133 }
1138 1134
1139 static String outputDir(Map configuration) { 1135 static String outputDir(Map configuration) {
1140 var result = ''; 1136 var result = '';
1141 var system = configuration['system']; 1137 var system = configuration['system'];
1142 if (system == 'linux') { 1138 if (system == 'linux') {
(...skipping 16 matching lines...) Expand all
1159 String toolsDir = scriptPath.substring(0, scriptPath.lastIndexOf('/')); 1155 String toolsDir = scriptPath.substring(0, scriptPath.lastIndexOf('/'));
1160 return new File('$toolsDir/..').fullPathSync().replaceAll('\\', '/'); 1156 return new File('$toolsDir/..').fullPathSync().replaceAll('\\', '/');
1161 } 1157 }
1162 1158
1163 static List<String> standardOptions(Map configuration) { 1159 static List<String> standardOptions(Map configuration) {
1164 List args = ["--ignore-unrecognized-flags"]; 1160 List args = ["--ignore-unrecognized-flags"];
1165 if (configuration["checked"]) { 1161 if (configuration["checked"]) {
1166 args.add('--enable_asserts'); 1162 args.add('--enable_asserts');
1167 args.add("--enable_type_checks"); 1163 args.add("--enable_type_checks");
1168 } 1164 }
1169 if (configuration["component"] == "dart2js" 1165 if (configuration["compiler"] == "dart2js") {
1170 || configuration["component"] == "legium") {
1171 args.add("--verbose"); 1166 args.add("--verbose");
1172 args.add("--leg"); 1167 args.add("--leg");
1173 if (configuration["host_checked"]) { 1168 if (configuration["host_checked"]) {
1174 args.add("--vm_flags=--enable_asserts --enable_type_checks"); 1169 args.add("--vm_flags=--enable_asserts --enable_type_checks");
1175 } 1170 }
1176 if (configuration["component"] == "dart2js") { 1171 if (configuration['runtime'] != 'drt') {
1177 args.add("--allow-mock-compilation"); 1172 args.add("--allow-mock-compilation");
1178 } 1173 }
1179 } 1174 }
1180 return args; 1175 return args;
1181 } 1176 }
1182 1177
1183 static bool isBrowserComponent(String component) => 1178 static bool isBrowserRuntime(String runtime) =>
1184 const <String>['dartium', 1179 const <String>['drt',
1185 'frogium', 1180 'ie',
1186 'legium', 1181 'safari',
1187 'webdriver'].some((x) => x == component); 1182 'opera',
1183 'chrome',
1184 'ff'].some((x) => x == runtime);
1188 } 1185 }
1189 1186
1190 class SummaryReport { 1187 class SummaryReport {
1191 static int total = 0; 1188 static int total = 0;
1192 static int skipped = 0; 1189 static int skipped = 0;
1193 static int noCrash = 0; 1190 static int noCrash = 0;
1194 static int pass = 0; 1191 static int pass = 0;
1195 static int failOk = 0; 1192 static int failOk = 0;
1196 static int fail = 0; 1193 static int fail = 0;
1197 static int crash = 0; 1194 static int crash = 0;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 * $noCrash tests are expected to be flaky but not crash 1228 * $noCrash tests are expected to be flaky but not crash
1232 * $pass tests are expected to pass 1229 * $pass tests are expected to pass
1233 * $failOk tests are expected to fail that we won't fix 1230 * $failOk tests are expected to fail that we won't fix
1234 * $fail tests are expected to fail that we should fix 1231 * $fail tests are expected to fail that we should fix
1235 * $crash tests are expected to crash that we should fix 1232 * $crash tests are expected to crash that we should fix
1236 * $timeout tests are allowed to timeout 1233 * $timeout tests are allowed to timeout
1237 """; 1234 """;
1238 print(report); 1235 print(report);
1239 } 1236 }
1240 } 1237 }
OLDNEW
« no previous file with comments | « tools/testing/dart/test_runner.dart ('k') | utils/tests/css/css.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698