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

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

Issue 256743009: Cache output of dart2js compilations that went wrong on disk. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 7 months 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
« no previous file with comments | « tools/testing/dart/multitest.dart ('k') | tools/testing/dart/test_suite.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/testing/dart/test_runner.dart
===================================================================
--- tools/testing/dart/test_runner.dart (revision 36157)
+++ tools/testing/dart/test_runner.dart (working copy)
@@ -93,6 +93,9 @@
String toString() => reproductionCommand;
Future<bool> get outputIsUpToDate => new Future.value(false);
+
+ Future<String> get cachedOutput => new Future.value(null);
+ Future writeCachedOutput(CommandOutput output) => new Future.value(null);
}
class ProcessCommand extends Command {
@@ -172,6 +175,24 @@
bool _neverSkipCompilation;
List<Uri> _bootstrapDependencies;
+ Future writeCachedOutput(CommandOutput output) {
+ var file = new io.File(TestUtils.cachedOutputFile(_outputFile));
+ return file.writeAsString(output.json)
+ .catchError((error) {
+ DebugLogger.warning("Could not write cached output: $error");
+ return null;
+ });
+ }
+
+ Future<CommandOutput> get cachedOutput {
+ var file = new io.File(TestUtils.cachedOutputFile(_outputFile));
+ return file.exists().then((exists) {
+ if (exists) return file.readAsString().then((content) {
+ return new CompilationCommandOutputImpl.fromJson(this, content);
+ });;
+ });
+ }
+
CompilationCommand._(String displayName,
this._outputFile,
this._neverSkipCompilation,
@@ -205,22 +226,28 @@
});
}
+ bool isUpToDate(lastModified, dependencies) {
+ if (lastModified == null) return false;
+ for (var dependency in dependencies) {
+ var dependencyLastModified =
+ TestUtils.lastModifiedCache.getLastModified(dependency);
+ if (dependencyLastModified == null ||
+ dependencyLastModified.isAfter(lastModified)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
return readDepsFile("$_outputFile.deps").then((dependencies) {
if (dependencies != null) {
dependencies.addAll(_bootstrapDependencies);
- var jsOutputLastModified = TestUtils.lastModifiedCache.getLastModified(
- new Uri(scheme: 'file', path: _outputFile));
- if (jsOutputLastModified != null) {
- for (var dependency in dependencies) {
- var dependencyLastModified =
- TestUtils.lastModifiedCache.getLastModified(dependency);
- if (dependencyLastModified == null ||
- dependencyLastModified.isAfter(jsOutputLastModified)) {
- return false;
- }
- }
- return true;
- }
+ // We check if the cached output is up to date, if so we return true
+ var cachedOutputFile = TestUtils.cachedOutputFile(_outputFile);
+ var cachedOutputUri = new Uri(scheme: 'file', path: cachedOutputFile);
+ var cachedOutputLastModified =
+ TestUtils.lastModifiedCache.getLastModified(cachedOutputUri);
+ return isUpToDate(cachedOutputLastModified, dependencies);
}
return false;
});
@@ -919,6 +946,8 @@
List<String> get diagnostics;
bool get compilationSkipped;
+
+ String get json;
}
class CommandOutputImpl extends UniqueObject implements CommandOutput {
@@ -1008,6 +1037,9 @@
}
return Expectation.FAIL;
}
+
+ String get json => null;
+
}
class BrowserCommandOutputImpl extends CommandOutputImpl {
@@ -1605,6 +1637,32 @@
exitCode == 0 ? Expectation.PASS : Expectation.COMPILETIME_ERROR;
return _negateOutcomeIfNegativeTest(outcome, testCase.isNegative);
}
+
+ String get json {
+ var map = {
+ 'stdout': stdout,
+ 'stderr': stderr,
+ 'exitCode': exitCode,
+ 'timedOut': timedOut,
+ };
+ return JSON.encode(map);
+ }
+
+ factory CompilationCommandOutputImpl.fromJson(Command command,
+ String json) {
+ var obj = JSON.decode(json);
+ for (var v in ['stdout', 'stderr', 'exitCode', 'timedOut']) {
+ assert(obj.containsKey(v));
+ }
+ return new CompilationCommandOutputImpl(command,
+ obj['exitCode'],
+ obj['timedOut'],
+ obj['stdout'],
+ obj['stderr'],
+ const Duration(seconds: 0),
+ true);
+
+ }
}
class JsCommandlineOutputImpl extends CommandOutputImpl
@@ -1802,10 +1860,12 @@
}
void _runCommand() {
- command.outputIsUpToDate.then((bool isUpToDate) {
+ command.outputIsUpToDate.then((isUpToDate) {
if (isUpToDate) {
compilationSkipped = true;
- _commandComplete(0);
+ command.cachedOutput.then((cached) {
+ _commandComplete(cached.exitCode, cachedOutput: cached);
+ });
} else {
var processEnvironment = _createProcessEnvironment();
Future processFuture =
@@ -1898,12 +1958,17 @@
});
}
- void _commandComplete(int exitCode) {
+ void _commandComplete(int exitCode, {cachedOutput: null}) {
if (timeoutTimer != null) {
timeoutTimer.cancel();
}
- var commandOutput = _createCommandOutput(command, exitCode);
- completer.complete(commandOutput);
+ if (cachedOutput != null) {
+ completer.complete(cachedOutput);
+ } else {
+ var commandOutput = _createCommandOutput(command, exitCode);
+ command.writeCachedOutput(commandOutput);
+ completer.complete(commandOutput);
+ }
}
CommandOutput _createCommandOutput(ProcessCommand command, int exitCode) {
« no previous file with comments | « tools/testing/dart/multitest.dart ('k') | tools/testing/dart/test_suite.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698