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

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 0c646ad0e213d8df50de07153d37abcbdaa6fbc5..0934dc1a36f8bfaf86b8f86c343f01e7891c0f7a 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) {
ahe 2012/11/14 18:46:16 Bail-out early: if (!useDart2jsFromSdk) return nu
kustermann 2012/11/16 14:58:42 Done.
+ var snapshotPath = TestUtils.absolutePath(new Path(buildDir).
+ join(new Path('dart-sdk/lib/_internal/compiler/implementation/dart2js.dart.snapshot')));
ricow1 2012/11/14 08:53:28 Long line
ahe 2012/11/14 18:46:16 You can always split a string in two using: new P
kustermann 2012/11/16 14:58:42 Done.
kustermann 2012/11/16 14:58:42 Done.
+ return [new Uri("file://$snapshotPath")];
ahe 2012/11/14 18:46:16 See http://blogs.msdn.com/b/ie/archive/2006/12/06/
+ }
+ return null;
+ }
+
+ 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,8 @@ 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)];
ahe 2012/11/14 18:46:16 Long line.
ahe 2012/11/14 18:46:16 It is not necessary to pass in !useDart2JsFromSdk.
kustermann 2012/11/16 14:58:42 Done.
kustermann 2012/11/16 14:58:42 I changed dart2JsBootstrapDependencies to return [
if (info.hasCompileError) {
// Do not attempt to run the compiled result. A compilation
// error should be reported by the compilation command.
@@ -999,6 +1014,10 @@ 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 +1479,30 @@ class JUnitTestSuite extends TestSuite {
}
}
+class TimeStampCache {
+ Map<String,Date> _cache = <String,Date>{};
ahe 2012/11/14 18:46:16 Add space after comma (twice).
kustermann 2012/11/16 14:58:42 Done.
+
+ /**
+ * Returns the timestamp of the given [Uri] and caches the result for
ahe 2012/11/14 18:46:16 Try to write documentation comments so that the fi
kustermann 2012/11/16 14:58:42 Done.
+ * 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 getTimeStamp(Uri uri) {
ahe 2012/11/14 18:46:16 I would have called this "getLastModified".
kustermann 2012/11/16 14:58:42 Done.
+ 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,6 +1511,7 @@ class TestUtils {
* script must set this to '.../dart/tools/test.dart'.
*/
static String testScriptPath = new Options().script;
+ static TimeStampCache timestampCache = new TimeStampCache();
Bill Hesse 2012/11/14 09:37:34 Why not cache currentDirectoryPath here, the way t
kustermann 2012/11/16 14:58:42 Done.
/**
* Creates a directory using a [relativePath] to an existing
@@ -1515,6 +1559,14 @@ class TestUtils {
}
}
+ static Path absolutePath(Path path) {
+ if (!path.isAbsolute) {
+ var cwd = new Path(new Directory.current().path);
Bill Hesse 2012/11/14 09:37:34 Can we cache this (new Path(new Directory.current(
kustermann 2012/11/16 14:58:42 Done.
+ return cwd.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