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

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

Issue 11280061: Revert "Added support for skipping redundant dart2js compilations." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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) 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,
11 * and creating [TestCase]s for those files that meet the relevant criteria. 11 * and creating [TestCase]s for those files that meet the relevant criteria.
12 * - Preparing tests, including copying files and frameworks to temporary 12 * - Preparing tests, including copying files and frameworks to temporary
13 * directories, and computing the command line and arguments to be run. 13 * directories, and computing the command line and arguments to be run.
14 */ 14 */
15 #library("test_suite"); 15 #library("test_suite");
16 16
17 #import("dart:io"); 17 #import("dart:io");
18 #import("dart:isolate"); 18 #import("dart:isolate");
19 #import("status_file_parser.dart"); 19 #import("status_file_parser.dart");
20 #import("test_runner.dart"); 20 #import("test_runner.dart");
21 #import("multitest.dart"); 21 #import("multitest.dart");
22 #import("drt_updater.dart"); 22 #import("drt_updater.dart");
23 #import("dart:uri");
24 23
25 #source("browser_test.dart"); 24 #source("browser_test.dart");
26 25
27 26
28 // TODO(rnystrom): Add to dart:core? 27 // TODO(rnystrom): Add to dart:core?
29 /** 28 /**
30 * A simple function that tests [arg] and returns `true` or `false`. 29 * A simple function that tests [arg] and returns `true` or `false`.
31 */ 30 */
32 typedef bool Predicate<T>(T arg); 31 typedef bool Predicate<T>(T arg);
33 32
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 Map configuration, Path directory) { 432 Map configuration, Path directory) {
434 final name = directory.filename; 433 final name = directory.filename;
435 434
436 return new StandardTestSuite(configuration, 435 return new StandardTestSuite(configuration,
437 name, directory, 436 name, directory,
438 ['$directory/$name.status', '$directory/${name}_dart2js.status'], 437 ['$directory/$name.status', '$directory/${name}_dart2js.status'],
439 isTestFilePredicate: (filename) => filename.endsWith('_test.dart'), 438 isTestFilePredicate: (filename) => filename.endsWith('_test.dart'),
440 recursive: true); 439 recursive: true);
441 } 440 }
442 441
443 Collection<Uri> get dart2JsBootstrapDependencies {
444 if (!useDart2JsFromSdk) return [];
445
446 var snapshotPath = TestUtils.absolutePath(new Path(buildDir).join(
447 new Path('dart-sdk/lib/_internal/compiler/'
448 'implementation/dart2js.dart.snapshot'))).toString();
449 return [new Uri.fromComponents(scheme: 'file', path: snapshotPath)];
450 }
451
452 bool get useDart2JsFromSdk {
453 return configuration['use_sdk'];
454 }
455
456 /** 442 /**
457 * The default implementation assumes a file is a test if 443 * The default implementation assumes a file is a test if
458 * it ends in "Test.dart". 444 * it ends in "Test.dart".
459 */ 445 */
460 bool isTestFile(String filename) { 446 bool isTestFile(String filename) {
461 // Use the specified predicate, if provided. 447 // Use the specified predicate, if provided.
462 if (isTestFilePredicate != null) return isTestFilePredicate(filename); 448 if (isTestFilePredicate != null) return isTestFilePredicate(filename);
463 449
464 return filename.endsWith("Test.dart"); 450 return filename.endsWith("Test.dart");
465 } 451 }
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 info: info)); 687 info: info));
702 } 688 }
703 } 689 }
704 690
705 List<Command> makeCommands(TestInformation info, var vmOptions, var args) { 691 List<Command> makeCommands(TestInformation info, var vmOptions, var args) {
706 switch (configuration['compiler']) { 692 switch (configuration['compiler']) {
707 case 'dart2js': 693 case 'dart2js':
708 args = new List.from(args); 694 args = new List.from(args);
709 String tempDir = createOutputDirectory(info.filePath, ''); 695 String tempDir = createOutputDirectory(info.filePath, '');
710 args.add('--out=$tempDir/out.js'); 696 args.add('--out=$tempDir/out.js');
711 List<Command> commands = 697 List<Command> commands = <Command>[new Command(dartShellFileName, args)];
712 <Command>[new Dart2JsCommand("$tempDir/out.js",
713 !useDart2JsFromSdk,
714 dart2JsBootstrapDependencies,
715 dartShellFileName,
716 args)];
717 if (info.hasCompileError) { 698 if (info.hasCompileError) {
718 // Do not attempt to run the compiled result. A compilation 699 // Do not attempt to run the compiled result. A compilation
719 // error should be reported by the compilation command. 700 // error should be reported by the compilation command.
720 } else if (configuration['runtime'] == 'd8') { 701 } else if (configuration['runtime'] == 'd8') {
721 commands.add(new Command(d8FileName, ['$tempDir/out.js'])); 702 commands.add(new Command(d8FileName, ['$tempDir/out.js']));
722 } else if (configuration['runtime'] == 'jsshell') { 703 } else if (configuration['runtime'] == 'jsshell') {
723 commands.add(new Command(jsShellFileName, ['$tempDir/out.js'])); 704 commands.add(new Command(jsShellFileName, ['$tempDir/out.js']));
724 } 705 }
725 return commands; 706 return commands;
726 707
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 args.add(inputFile); 1000 args.add(inputFile);
1020 break; 1001 break;
1021 default: 1002 default:
1022 Expect.fail('unimplemented compiler $compiler'); 1003 Expect.fail('unimplemented compiler $compiler');
1023 } 1004 }
1024 if (executable.endsWith('.dart')) { 1005 if (executable.endsWith('.dart')) {
1025 // Run the compiler script via the Dart VM. 1006 // Run the compiler script via the Dart VM.
1026 args.insertRange(0, 1, executable); 1007 args.insertRange(0, 1, executable);
1027 executable = dartShellFileName; 1008 executable = dartShellFileName;
1028 } 1009 }
1029 if (configuration['compiler'] == 'dart2js') {
1030 return new Dart2JsCommand(outputFile,
1031 !useDart2JsFromSdk,
1032 dart2JsBootstrapDependencies,
1033 dartShellFileName,
1034 args);
1035 }
1036 return new Command(executable, args); 1010 return new Command(executable, args);
1037 } 1011 }
1038 1012
1039 /** 1013 /**
1040 * Create a directory for the generated test. If a Dart language test 1014 * Create a directory for the generated test. If a Dart language test
1041 * needs to be run in a browser, the Dart test needs to be embedded in 1015 * needs to be run in a browser, the Dart test needs to be embedded in
1042 * an HTML page, with a testing framework based on scripting and DOM events. 1016 * an HTML page, with a testing framework based on scripting and DOM events.
1043 * These scripts and pages are written to a generated_test directory 1017 * These scripts and pages are written to a generated_test directory
1044 * inside the build directory of the checkout. 1018 * inside the build directory of the checkout.
1045 * 1019 *
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1513 '$dartDir/third_party/rhino/1_7R3/js.jar', 1487 '$dartDir/third_party/rhino/1_7R3/js.jar',
1514 '$dartDir/third_party/hamcrest/v1_3/hamcrest-core-1.3.0RC2.jar', 1488 '$dartDir/third_party/hamcrest/v1_3/hamcrest-core-1.3.0RC2.jar',
1515 '$dartDir/third_party/hamcrest/v1_3/hamcrest-generator-1.3.0RC2.jar', 1489 '$dartDir/third_party/hamcrest/v1_3/hamcrest-generator-1.3.0RC2.jar',
1516 '$dartDir/third_party/hamcrest/v1_3/hamcrest-integration-1.3.0RC2.jar', 1490 '$dartDir/third_party/hamcrest/v1_3/hamcrest-integration-1.3.0RC2.jar',
1517 '$dartDir/third_party/hamcrest/v1_3/hamcrest-library-1.3.0RC2.jar', 1491 '$dartDir/third_party/hamcrest/v1_3/hamcrest-library-1.3.0RC2.jar',
1518 '$dartDir/third_party/junit/v4_8_2/junit.jar'], 1492 '$dartDir/third_party/junit/v4_8_2/junit.jar'],
1519 Platform.operatingSystem == 'windows'? ';': ':'); // Path separator. 1493 Platform.operatingSystem == 'windows'? ';': ':'); // Path separator.
1520 } 1494 }
1521 } 1495 }
1522 1496
1523 class LastModifiedCache {
1524 Map<String, Date> _cache = <String, Date>{};
1525
1526 /**
1527 * Returns the last modified date of the given [uri].
1528 *
1529 * The return value will be cached for future queries. If [uri] is a local
1530 * file, it's last modified [Date] will be returned. If the file does not
1531 * exist, null will be returned instead.
1532 * In case [uri] is not a local file, this method will always return
1533 * the current date.
1534 */
1535 Date getLastModified(Uri uri) {
1536 if (uri.scheme == "file") {
1537 if (_cache.containsKey(uri.path)) {
1538 return _cache[uri.path];
1539 }
1540 var file = new File(new Path(uri.path).toNativePath());
1541 _cache[uri.path] = file.existsSync() ? file.lastModifiedSync() : null;
1542 return _cache[uri.path];
1543 }
1544 return new Date.now();
1545 }
1546 }
1547
1548 class TestUtils { 1497 class TestUtils {
1549 /** 1498 /**
1550 * The libraries in this directory relies on finding various files 1499 * The libraries in this directory relies on finding various files
1551 * relative to the 'test.dart' script in '.../dart/tools/test.dart'. If 1500 * relative to the 'test.dart' script in '.../dart/tools/test.dart'. If
1552 * the main script using 'test_suite.dart' is not there, the main 1501 * the main script using 'test_suite.dart' is not there, the main
1553 * script must set this to '.../dart/tools/test.dart'. 1502 * script must set this to '.../dart/tools/test.dart'.
1554 */ 1503 */
1555 static String testScriptPath = new Options().script; 1504 static String testScriptPath = new Options().script;
1556 static LastModifiedCache lastModifiedCache = new LastModifiedCache(); 1505
1557 static Path currentWorkingDirectory = new Path.fromNative(new Directory.curren t().path);
1558 /** 1506 /**
1559 * Creates a directory using a [relativePath] to an existing 1507 * Creates a directory using a [relativePath] to an existing
1560 * [base] directory if that [relativePath] does not already exist. 1508 * [base] directory if that [relativePath] does not already exist.
1561 */ 1509 */
1562 static Directory mkdirRecursive(Path base, Path relativePath) { 1510 static Directory mkdirRecursive(Path base, Path relativePath) {
1563 Directory dir = new Directory.fromPath(base); 1511 Directory dir = new Directory.fromPath(base);
1564 Expect.isTrue(dir.existsSync(), 1512 Expect.isTrue(dir.existsSync(),
1565 "Expected ${dir} to already exist"); 1513 "Expected ${dir} to already exist");
1566 var segments = relativePath.segments(); 1514 var segments = relativePath.segments();
1567 for (String segment in segments) { 1515 for (String segment in segments) {
(...skipping 27 matching lines...) Expand all
1595 // waterfall UI. 1543 // waterfall UI.
1596 return ".flaky.log"; 1544 return ".flaky.log";
1597 } 1545 }
1598 1546
1599 static void ensureExists(String filename, Map configuration) { 1547 static void ensureExists(String filename, Map configuration) {
1600 if (!configuration['list'] && !(new File(filename).existsSync())) { 1548 if (!configuration['list'] && !(new File(filename).existsSync())) {
1601 throw "Executable '$filename' does not exist"; 1549 throw "Executable '$filename' does not exist";
1602 } 1550 }
1603 } 1551 }
1604 1552
1605 static Path absolutePath(Path path) {
1606 if (!path.isAbsolute) {
1607 return currentWorkingDirectory.join(path);
1608 }
1609 return path;
1610 }
1611
1612 static String outputDir(Map configuration) { 1553 static String outputDir(Map configuration) {
1613 var result = ''; 1554 var result = '';
1614 var system = configuration['system']; 1555 var system = configuration['system'];
1615 if (system == 'linux') { 1556 if (system == 'linux') {
1616 result = 'out/'; 1557 result = 'out/';
1617 } else if (system == 'macos') { 1558 } else if (system == 'macos') {
1618 result = 'xcodebuild/'; 1559 result = 'xcodebuild/';
1619 } else if (system == 'windows') { 1560 } else if (system == 'windows') {
1620 result = 'build/'; 1561 result = 'build/';
1621 } 1562 }
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1730 * $pass tests are expected to pass 1671 * $pass tests are expected to pass
1731 * $failOk tests are expected to fail that we won't fix 1672 * $failOk tests are expected to fail that we won't fix
1732 * $fail tests are expected to fail that we should fix 1673 * $fail tests are expected to fail that we should fix
1733 * $crash tests are expected to crash that we should fix 1674 * $crash tests are expected to crash that we should fix
1734 * $timeout tests are allowed to timeout 1675 * $timeout tests are allowed to timeout
1735 * $compileErrorSkip tests are skipped on browsers due to compile-time error 1676 * $compileErrorSkip tests are skipped on browsers due to compile-time error
1736 """; 1677 """;
1737 print(report); 1678 print(report);
1738 } 1679 }
1739 } 1680 }
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