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

Unified Diff: tools/testing/dart/test_suite.dart

Issue 11369216: Added support for skipping redundant dart2js compilations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fixed long lines Created 8 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 side-by-side diff with in-line comments
Download patch
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..356d22c42765564cad905533679edf4347ec706c 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,9 @@ 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 +1602,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 +1613,26 @@ class TestUtils {
}
}
+ static Path absolutePath(Path path) {
+ 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());

Powered by Google App Engine
This is Rietveld 408576698