| Index: utils/tests/pub/test_pub.dart
|
| diff --git a/utils/tests/pub/test_pub.dart b/utils/tests/pub/test_pub.dart
|
| index 63301f40a51d2a9cb27183d31f0323ae3900401e..523e233f67f520ad052af271477416dad5e8bc28 100644
|
| --- a/utils/tests/pub/test_pub.dart
|
| +++ b/utils/tests/pub/test_pub.dart
|
| @@ -31,6 +31,7 @@ import '../../pub/git_source.dart';
|
| import '../../pub/hosted_source.dart';
|
| import '../../pub/http.dart';
|
| import '../../pub/io.dart';
|
| +import '../../pub/path_source.dart';
|
| import '../../pub/sdk_source.dart';
|
| import '../../pub/system_cache.dart';
|
| import '../../pub/utils.dart';
|
| @@ -404,6 +405,9 @@ Future<Map> _dependencyListToMap(List<Map> dependencies) {
|
| case "hosted":
|
| source = new HostedSource();
|
| break;
|
| + case "path":
|
| + source = new PathSource();
|
| + break;
|
| case "sdk":
|
| source = new SdkSource();
|
| break;
|
| @@ -427,6 +431,8 @@ String _packageName(String sourceName, description) {
|
| case "hosted":
|
| if (description is String) return description;
|
| return description['name'];
|
| + case "path":
|
| + return basename(description);
|
| case "sdk":
|
| return description;
|
| default:
|
| @@ -434,6 +440,10 @@ String _packageName(String sourceName, description) {
|
| }
|
| }
|
|
|
| +/// The full path to the created sandbox directory for an integration test.
|
| +String get sandboxDir => _sandboxDir.path;
|
| +Directory _sandboxDir;
|
| +
|
| /// The path of the package cache directory used for tests. Relative to the
|
| /// sandbox directory.
|
| final String cachePath = "cache";
|
| @@ -488,27 +498,32 @@ void _integration(String description, void body(), [Function testFn]) {
|
| file('version', '0.1.2.3')
|
| ]).scheduleCreate();
|
|
|
| + _sandboxDir = createTempDir();
|
| +
|
| // Schedule the test.
|
| body();
|
|
|
| // Run all of the scheduled tasks. If an error occurs, it will propagate
|
| // through the futures back up to here where we can hand it off to unittest.
|
| var asyncDone = expectAsync0(() {});
|
| - var sandboxDir = createTempDir();
|
| - return timeout(_runScheduled(sandboxDir, _scheduled),
|
| + return timeout(_runScheduled(_scheduled),
|
| _TIMEOUT, 'waiting for a test to complete').catchError((e) {
|
| - return _runScheduled(sandboxDir, _scheduledOnException).then((_) {
|
| + return _runScheduled(_scheduledOnException).then((_) {
|
| // Rethrow the original error so it keeps propagating.
|
| throw e;
|
| });
|
| }).whenComplete(() {
|
| // Clean up after ourselves. Do this first before reporting back to
|
| // unittest because it will advance to the next test immediately.
|
| - return _runScheduled(sandboxDir, _scheduledCleanup).then((_) {
|
| + return _runScheduled(_scheduledCleanup).then((_) {
|
| _scheduled = null;
|
| _scheduledCleanup = null;
|
| _scheduledOnException = null;
|
| - if (sandboxDir != null) return deleteDir(sandboxDir);
|
| + if (_sandboxDir != null) {
|
| + var dir = _sandboxDir;
|
| + _sandboxDir = null;
|
| + return deleteDir(dir);
|
| + }
|
| });
|
| }).then((_) {
|
| // If we got here, the test completed successfully so tell unittest so.
|
| @@ -532,6 +547,14 @@ String get testDirectory {
|
| return getFullPath(dir);
|
| }
|
|
|
| +/// Schedules renaming (moving) the directory at [from] to [to], both of which
|
| +/// are assumed to be relative to [sandboxDir].
|
| +void scheduleRename(String from, String to) {
|
| + _schedule((sandboxDir) {
|
| + return renameDir(join(sandboxDir, from), join(sandboxDir, to));
|
| + });
|
| +}
|
| +
|
| /// Schedules a call to the Pub command-line utility. Runs Pub with [args] and
|
| /// validates that its results match [output], [error], and [exitCode].
|
| void schedulePub({List args, Pattern output, Pattern error,
|
| @@ -602,7 +625,6 @@ void confirmPublish(ScheduledProcess pub) {
|
| pub.writeLine("y");
|
| }
|
|
|
| -
|
| /// Calls [fn] with appropriately modified arguments to run a pub process. [fn]
|
| /// should have the same signature as [startProcess], except that the returned
|
| /// [Future] may have a type other than [Process].
|
| @@ -677,7 +699,7 @@ void useMockClient(MockClient client) {
|
| });
|
| }
|
|
|
| -Future _runScheduled(Directory parentDir, List<_ScheduledEvent> scheduled) {
|
| +Future _runScheduled(List<_ScheduledEvent> scheduled) {
|
| if (scheduled == null) return new Future.immediate(null);
|
| var iterator = scheduled.iterator;
|
|
|
| @@ -688,7 +710,7 @@ Future _runScheduled(Directory parentDir, List<_ScheduledEvent> scheduled) {
|
| return new Future.immediate(null);
|
| }
|
|
|
| - var future = iterator.current(parentDir);
|
| + var future = iterator.current(_sandboxDir);
|
| if (future != null) {
|
| return future.then(runNextEvent);
|
| } else {
|
| @@ -1167,7 +1189,7 @@ class NothingDescriptor extends Descriptor {
|
| typedef Validator ValidatorCreator(Entrypoint entrypoint);
|
|
|
| /// Schedules a single [Validator] to run on the [appPath]. Returns a scheduled
|
| -/// Future that contains the erros and warnings produced by that validator.
|
| +/// Future that contains the errors and warnings produced by that validator.
|
| Future<Pair<List<String>, List<String>>> schedulePackageValidation(
|
| ValidatorCreator fn) {
|
| return _scheduleValue((sandboxDir) {
|
|
|