| 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 8c96a0c574f5177a9d3bbf9c54eb3fbedcf5e31e..9765d463969cbd3b5a5a7099dd7ad9ba712cd58c 100644
|
| --- a/dart/tools/testing/dart/test_runner.dart
|
| +++ b/dart/tools/testing/dart/test_runner.dart
|
| @@ -457,7 +457,10 @@ class ModifyPubspecYamlCommand extends ScriptCommand {
|
| ModifyPubspecYamlCommand._(this._pubspecYamlFile,
|
| this._destinationFile,
|
| this._dependencyOverrides)
|
| - : super._("modify_pubspec");
|
| + : super._("modify_pubspec") {
|
| + assert(_pubspecYamlFile.endsWith("pubspec.yaml"));
|
| + assert(_destinationFile.endsWith("pubspec.yaml"));
|
| + }
|
|
|
| String get reproductionCommand =>
|
| "Adding necessary dependency overrides to '$_pubspecYamlFile' "
|
| @@ -466,8 +469,13 @@ class ModifyPubspecYamlCommand extends ScriptCommand {
|
| Future<ScriptCommandOutputImpl> run() {
|
| var watch = new Stopwatch()..start();
|
|
|
| + var pubspecLockFile =
|
| + _destinationFile.substring(0, _destinationFile.length - ".yaml".length)
|
| + + ".lock";
|
| +
|
| var file = new io.File(_pubspecYamlFile);
|
| var destinationFile = new io.File(_destinationFile);
|
| + var lockfile = new io.File(pubspecLockFile);
|
| return file.readAsString().then((String yamlString) {
|
| var dependencyOverrideSection = new StringBuffer();
|
| if (_dependencyOverrides.isNotEmpty) {
|
| @@ -484,7 +492,13 @@ class ModifyPubspecYamlCommand extends ScriptCommand {
|
| });
|
| }
|
| var modifiedYamlString = "$yamlString\n$dependencyOverrideSection";
|
| - return destinationFile.writeAsString(modifiedYamlString);
|
| + return destinationFile.writeAsString(modifiedYamlString).then((_) {
|
| + lockfile.exists().then((bool lockfileExists) {
|
| + if (lockfileExists) {
|
| + return lockfile.delete();
|
| + }
|
| + });
|
| + });
|
| }).then((_) {
|
| return new ScriptCommandOutputImpl(
|
| this, Expectation.PASS, "", watch.elapsed);
|
| @@ -511,6 +525,54 @@ 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");
|
| + }
|
| + var link = new io.Link(_link);
|
| +
|
| + return link.exists()
|
| + .then((bool exists) { if (exists) return link.delete(); })
|
| + .then((_) => 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._();
|
|
|
| @@ -596,6 +658,10 @@ class CommandBuilder {
|
| return _getUniqueCommand(command);
|
| }
|
|
|
| + Command getMakeSymlinkCommand(String link, String target) {
|
| + return _getUniqueCommand(new MakeSymlinkCommand._(link, target));
|
| + }
|
| +
|
| Command getModifyPubspecCommand(String pubspecYamlFile, Map depsOverrides,
|
| {String destinationFile: null}) {
|
| if (destinationFile == null) destinationFile = pubspecYamlFile;
|
|
|