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

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: 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 side-by-side diff with in-line comments
Download patch
« tools/testing/dart/test_runner.dart ('K') | « tools/testing/dart/test_runner.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/testing/dart/test_suite.dart
diff --git a/tools/testing/dart/test_suite.dart b/tools/testing/dart/test_suite.dart
index 84fd882b2df7fd3a2a5c5304f2ff6009ee9d9b3e..8d4300df016804a864e8646be100da2e410e3560 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");
@@ -443,6 +444,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".
@@ -698,7 +712,12 @@ 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(dartShellFileName, args)];
+ List<Command> commands =
+ <Command>[new Dart2JsCommand("$tempDir/out.js",
+ !useDart2JsFromSdk,
+ dart2JsBootstrapDependencies,
+ dartShellFileName,
+ args)];
if (info.hasCompileError) {
// Do not attempt to run the compiled result. A compilation
// error should be reported by the compilation command.
@@ -999,6 +1018,13 @@ class StandardTestSuite extends TestSuite {
args.insertRange(0, 1, executable);
executable = dartShellFileName;
}
+ if (configuration['compiler'] == 'dart2js') {
+ return new Dart2JsCommand(outputFile,
+ !useDart2JsFromSdk,
+ dart2JsBootstrapDependencies,
+ dartShellFileName,
+ args);
+ }
return new Command(executable, args);
}
@@ -1460,6 +1486,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(uri.path);
+ _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
@@ -1468,7 +1519,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(new Directory.current().path);
/**
* Creates a directory using a [relativePath] to an existing
* [base] directory if that [relativePath] does not already exist.
@@ -1516,6 +1568,13 @@ 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'];
« tools/testing/dart/test_runner.dart ('K') | « tools/testing/dart/test_runner.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698