Chromium Code Reviews| Index: dart/tools/testing/dart/test_runner.dart |
| diff --git a/dart/tools/testing/dart/test_runner.dart b/dart/tools/testing/dart/test_runner.dart |
| index 70a57c3caa58b7a7ee28ef1b1a032e47bdfb9f69..0f4adf066403b1f779b9108b82f7f21e003d6941 100644 |
| --- a/dart/tools/testing/dart/test_runner.dart |
| +++ b/dart/tools/testing/dart/test_runner.dart |
| @@ -362,6 +362,33 @@ class JSCommandlineCommand extends ProcessCommand { |
| environmentOverrides); |
| } |
| +class PubCommand extends ProcessCommand { |
| + final String command; |
| + |
| + PubCommand._(String pubCommand, |
| + String pubExecutable, |
| + String pubspecYamlDirectory, |
| + String pubCacheDirectory) |
| + : super._('pub_$pubCommand', |
| + new io.File(pubExecutable).absolute.path, |
| + [pubCommand], |
| + {'PUB_CACHE' : pubCacheDirectory}, |
| + pubspecYamlDirectory), command = pubCommand; |
| + |
| + void _buildHashCode(HashCodeBuilder builder) { |
| + super._buildHashCode(builder); |
| + builder.add(command); |
| + } |
| + |
| + bool _equal(Command other) { |
| + return |
| + other is PubCommand && |
| + super._equal(other) && |
| + command == other.command; |
| + } |
| +} |
| + |
| + |
| /* Script command are executed by dart code. */ |
| abstract class ScriptCommand extends Command { |
| ScriptCommand._(String displayName) : super._(displayName); |
| @@ -491,6 +518,57 @@ class ModifyPubspecYamlCommand extends ScriptCommand { |
| } |
| } |
| +/* |
| + * [MakeSymlinkCommand] makes a symbolic link to another directory. |
| + */ |
| +class MakeSymlinkCommand extends ScriptCommand { |
| + String _link; |
| + String _target; |
| + |
| + MakeSymlinkCommand._(this._link, this._target) : super._('make_symlink'); |
| + |
| + String get reproductionCommand => |
| + "Make symbolic link '$_link' (target: $_target)'."; |
| + |
| + Future<ScriptCommandOutputImpl> run() { |
| + var watch = new Stopwatch()..start(); |
| + var targetFile = new io.Directory(_target); |
| + return targetFile.exists().then((bool targetExists) { |
| + if (!targetExists) { |
| + throw new Exception("Target '$_target' does not exist"); |
| + } |
| + }).then((_) { |
|
ricow1
2014/01/06 10:39:14
delete this line, there is nothing async in the bl
|
| + var link = new io.Link(_link); |
| + return link.exists().then((bool exists) { |
| + if (exists) { |
| + return link.delete().then((_) => link.create(_target)); |
| + } |
| + return link.create(_target); |
| + }); |
| + }).then((_) { |
| + return new ScriptCommandOutputImpl( |
| + this, Expectation.PASS, "", watch.elapsed); |
| + }).catchError((error) { |
| + return new ScriptCommandOutputImpl( |
| + this, Expectation.FAIL, "An error occured: $error.", watch.elapsed); |
| + }); |
| + } |
| + |
| + void _buildHashCode(HashCodeBuilder builder) { |
| + super._buildHashCode(builder); |
| + builder.add(_link); |
| + builder.add(_target); |
| + } |
| + |
| + bool _equal(Command other) { |
| + return |
| + other is MakeSymlinkCommand && |
| + super._equal(other) && |
| + _link == other._link && |
| + _target == other._target; |
| + } |
| +} |
| + |
| class CommandBuilder { |
| static final CommandBuilder instance = new CommandBuilder._(); |
| @@ -569,10 +647,15 @@ class CommandBuilder { |
| String pubExecutable, |
| String pubspecYamlDirectory, |
| String pubCacheDirectory) { |
| - var envOverrides = {'PUB_CACHE' : pubCacheDirectory}; |
| - pubExecutable = new io.File(pubExecutable).absolute.path; |
| - return getProcessCommand('pub_$pubCommand', |
| - pubExecutable, [pubCommand], envOverrides, pubspecYamlDirectory); |
| + var command = new PubCommand._(pubCommand, |
| + pubExecutable, |
| + pubspecYamlDirectory, |
| + pubCacheDirectory); |
| + return _getUniqueCommand(command); |
| + } |
| + |
| + Command getMakeSymlinkCommand(String link, String target) { |
| + return _getUniqueCommand(new MakeSymlinkCommand._(link, target)); |
| } |
| Command getModifyPubspecCommand(String pubspecYamlFile, Map depsOverrides, |
| @@ -1483,6 +1566,26 @@ class JsCommandlineOutputImpl extends CommandOutputImpl |
| } |
| } |
| +class PubCommandOutputImpl extends CommandOutputImpl { |
| + PubCommandOutputImpl(PubCommand command, int exitCode, bool timedOut, |
| + List<int> stdout, List<int> stderr, Duration time) |
| + : super(command, exitCode, timedOut, stdout, stderr, time, false); |
| + |
| + Expectation result(TestCase testCase) { |
| + // Handle crashes and timeouts first |
| + if (hasCrashed) return Expectation.CRASH; |
| + if (hasTimedOut) return Expectation.TIMEOUT; |
| + |
| + if (exitCode == 0) { |
| + return Expectation.PASS; |
| + } else if ((command as PubCommand).command == 'get') { |
| + return Expectation.PUB_GET_ERROR; |
| + } else { |
| + return Expectation.FAIL; |
| + } |
| + } |
| +} |
| + |
| class ScriptCommandOutputImpl extends CommandOutputImpl { |
| final Expectation _result; |
| @@ -1529,6 +1632,9 @@ CommandOutput createCommandOutput(Command command, |
| } else if (command is JSCommandlineCommand) { |
| return new JsCommandlineOutputImpl( |
| command, exitCode, timedOut, stdout, stderr, time); |
| + } else if (command is PubCommand) { |
| + return new PubCommandOutputImpl( |
| + command, exitCode, timedOut, stdout, stderr, time); |
| } |
| return new CommandOutputImpl( |
| @@ -2517,7 +2623,7 @@ class ProcessQueue { |
| Timer _debugTimer; |
| // If we haven't seen a single test finishing during a 10 minute period |
| // something is definitly wrong, so we dump the debugging information. |
| - final debugTimerDuration = const Duration(minutes: 10); |
| + final debugTimerDuration = const Duration(minutes: 1); |
| void cancelDebugTimer() { |
| if (_debugTimer != null) { |
| @@ -2572,6 +2678,7 @@ class ProcessQueue { |
| eventAllTestsKnown(); |
| }); |
| + |
| // Queue commands as they become "runnable" |
| var commandEnqueuer = new CommandEnqueuer(_graph); |