Chromium Code Reviews| Index: tools/testing/dart/test_suite.dart |
| diff --git a/tools/testing/dart/test_suite.dart b/tools/testing/dart/test_suite.dart |
| index ee4023a610ec1cfd334cbebad66500bfe6b47c5c..0a79069cbc3c7c42d23e25b92be87ac3b471ff11 100644 |
| --- a/tools/testing/dart/test_suite.dart |
| +++ b/tools/testing/dart/test_suite.dart |
| @@ -20,6 +20,7 @@ |
| #import("test_runner.dart"); |
| #import("multitest.dart"); |
| #import("drt_updater.dart"); |
| +#import("dart:uri"); |
| #source("browser_test.dart"); |
| @@ -433,6 +434,19 @@ class StandardTestSuite extends TestSuite { |
| recursive: true); |
| } |
| + Collection<Uri> get dart2JsBootstrapDependencies { |
| + if (!useDart2JsFromSdk) return []; |
| + |
| + var snapshotPath = TestUtils.absolutePath(new Path(buildDir).join( |
| + new Path('dart-sdk/lib/_internal/compiler/' |
| + 'implementation/dart2js.dart.snapshot'))).toString(); |
| + return [new Uri.fromComponents(scheme: 'file', path: snapshotPath)]; |
| + } |
| + |
| + bool get useDart2JsFromSdk { |
| + return configuration['use_sdk']; |
| + } |
| + |
| /** |
| * The default implementation assumes a file is a test if |
| * it ends in "Test.dart". |
| @@ -689,7 +703,13 @@ class StandardTestSuite extends TestSuite { |
| args = new List.from(args); |
| String tempDir = createOutputDirectory(info.filePath, ''); |
| args.add('--out=$tempDir/out.js'); |
| - List<Command> commands = <Command>[new Command(compilerPath, args)]; |
| + |
| + List<Command> commands = |
| + <Command>[new Dart2JsCommand("$tempDir/out.js", |
| + !useDart2JsFromSdk, |
| + dart2JsBootstrapDependencies, |
| + compilerPath, |
| + args)]; |
| if (info.hasCompileError) { |
| // Do not attempt to run the compiled result. A compilation |
| // error should be reported by the compilation command. |
| @@ -998,6 +1018,13 @@ class StandardTestSuite extends TestSuite { |
| args.insertRange(0, 1, executable); |
| executable = dartShellFileName; |
| } |
| + if (configuration['compiler'] == 'dart2js') { |
| + return new Dart2JsCommand(outputFile, |
| + !useDart2JsFromSdk, |
| + dart2JsBootstrapDependencies, |
| + compilerPath, |
| + args); |
| + } |
| return new Command(executable, args); |
| } |
| @@ -1494,6 +1521,31 @@ class JUnitTestSuite extends TestSuite { |
| } |
| } |
| +class LastModifiedCache { |
| + Map<String, Date> _cache = <String, Date>{}; |
| + |
| + /** |
| + * Returns the last modified date of the given [uri]. |
| + * |
| + * The return value will be cached for future queries. If [uri] is a local |
| + * file, it's last modified [Date] will be returned. If the file does not |
| + * exist, null will be returned instead. |
| + * In case [uri] is not a local file, this method will always return |
| + * the current date. |
| + */ |
| + Date getLastModified(Uri uri) { |
| + if (uri.scheme == "file") { |
| + if (_cache.containsKey(uri.path)) { |
| + return _cache[uri.path]; |
| + } |
| + var file = new File(new Path(uri.path).toNativePath()); |
| + _cache[uri.path] = file.existsSync() ? file.lastModifiedSync() : null; |
| + return _cache[uri.path]; |
| + } |
| + return new Date.now(); |
| + } |
| +} |
| + |
| class TestUtils { |
| /** |
| * The libraries in this directory relies on finding various files |
| @@ -1502,7 +1554,8 @@ class TestUtils { |
| * script must set this to '.../dart/tools/test.dart'. |
| */ |
| static String testScriptPath = new Options().script; |
| - |
| + static LastModifiedCache lastModifiedCache = new LastModifiedCache(); |
| + static Path currentWorkingDirectory = new Path.fromNative(new Directory.current().path); |
| /** |
| * Creates a directory using a [relativePath] to an existing |
| * [base] directory if that [relativePath] does not already exist. |
| @@ -1548,7 +1601,7 @@ class TestUtils { |
| // If a flaky test did fail, infos about it (i.e. test name, stdin, stdout) |
| // will be written to this file. This is useful for the debugging of |
| // flaky tests. |
| - // When running on a built bot, the file can be made visible in the |
| + // When running on a built bot, the file can be made visible in the |
| // waterfall UI. |
| return ".flaky.log"; |
| } |
| @@ -1559,6 +1612,26 @@ class TestUtils { |
| } |
| } |
| + static Path absolutePath(Path path) { |
|
Bill Hesse
2012/12/11 10:51:04
We have many places in the code where we instead u
kustermann
2012/12/11 13:11:22
Writing "new Path.fromNative(new File.fromPath(pat
|
| + if (!path.isAbsolute) { |
| + return currentWorkingDirectory.join(path); |
| + } |
| + return path; |
| + } |
| + |
| + static String outputDir(Map configuration) { |
| + var result = ''; |
| + var system = configuration['system']; |
| + if (system == 'linux') { |
| + result = 'out/'; |
| + } else if (system == 'macos') { |
| + result = 'xcodebuild/'; |
| + } else if (system == 'windows') { |
| + result = 'build/'; |
| + } |
| + return result; |
| + } |
| + |
| static Path dartDir() { |
| File scriptFile = new File(testScriptPath); |
| Path scriptPath = new Path.fromNative(scriptFile.fullPathSync()); |