| 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..fc9ca57ca9e7737a228df4ad5d62682da6c3b123 100644
|
| --- a/utils/tests/pub/test_pub.dart
|
| +++ b/utils/tests/pub/test_pub.dart
|
| @@ -99,7 +99,7 @@ Future<int> get port => _portCompleter.future;
|
| void serve([List<Descriptor> contents]) {
|
| var baseDir = dir("serve-dir", contents);
|
|
|
| - _schedule((_) {
|
| + schedule((_) {
|
| return _closeServer().then((_) {
|
| _server = new HttpServer();
|
| _server.defaultRequestHandler = (request, response) {
|
| @@ -177,7 +177,7 @@ void servePackages(List<Map> pubspecs) {
|
| });
|
| }
|
|
|
| - _schedule((_) {
|
| + schedule((_) {
|
| return _awaitObject(pubspecs).then((resolvedPubspecs) {
|
| for (var spec in resolvedPubspecs) {
|
| var name = spec['name'];
|
| @@ -363,6 +363,14 @@ DirectoryDescriptor cacheDir(Map packages) {
|
| ]);
|
| }
|
|
|
| +/// Describes the directory in the system cache where the package [name] at
|
| +/// [version] is stored when installed from the mock package server.
|
| +Future<String> hostedCacheDir(String name, String version) {
|
| + return port.then((p) {
|
| + return path.join(cachePath, "hosted", "localhost%58$p", "$name-$version");
|
| + });
|
| +}
|
| +
|
| /// Describes the file in the system cache that contains the client's OAuth2
|
| /// credentials. The URL "/token" on [server] will be used as the token
|
| /// endpoint for refreshing the access token.
|
| @@ -536,7 +544,7 @@ String get testDirectory {
|
| /// validates that its results match [output], [error], and [exitCode].
|
| void schedulePub({List args, Pattern output, Pattern error,
|
| Future<Uri> tokenEndpoint, int exitCode: 0}) {
|
| - _schedule((sandboxDir) {
|
| + schedule((sandboxDir) {
|
| return _doPub(runProcess, sandboxDir, args, tokenEndpoint).then((result) {
|
| var failures = [];
|
|
|
| @@ -654,7 +662,7 @@ Future _doPub(Function fn, sandboxDir, List args, Future<Uri> tokenEndpoint) {
|
| /// have git installed to run the tests locally (unless they actually care
|
| /// about the pub git tests).
|
| void ensureGit() {
|
| - _schedule((_) {
|
| + schedule((_) {
|
| return gitlib.isInstalled.then((installed) {
|
| if (!installed &&
|
| !Platform.environment.containsKey('BUILDBOT_BUILDERNAME')) {
|
| @@ -805,15 +813,15 @@ abstract class Descriptor {
|
| /// [schedulePub]. The directory will be created relative to the sandbox
|
| /// directory.
|
| // TODO(nweiz): Use implicit closurization once issue 2984 is fixed.
|
| - void scheduleCreate() => _schedule((dir) => this.create(dir));
|
| + void scheduleCreate() => schedule((dir) => this.create(dir));
|
|
|
| /// Schedules the file or directory to be deleted recursively.
|
| - void scheduleDelete() => _schedule((dir) => this.delete(dir));
|
| + void scheduleDelete() => schedule((dir) => this.delete(dir));
|
|
|
| /// Schedules the directory to be validated after Pub is run with
|
| /// [schedulePub]. The directory will be validated relative to the sandbox
|
| /// directory.
|
| - void scheduleValidate() => _schedule((parentDir) => validate(parentDir.path));
|
| + void scheduleValidate() => schedule((parentDir) => validate(parentDir.path));
|
|
|
| /// Asserts that the name of the descriptor is a [String] and returns it.
|
| String get _stringName {
|
| @@ -1039,7 +1047,7 @@ class GitRepoDescriptor extends DirectoryDescriptor {
|
| }
|
|
|
| /// Schedules changes to be committed to the Git repository.
|
| - void scheduleCommit() => _schedule((dir) => this.commit(dir));
|
| + void scheduleCommit() => schedule((dir) => this.commit(dir));
|
|
|
| /// Return a Future that completes to the commit in the git repository
|
| /// referred to by [ref] at the current point in the scheduled test run.
|
| @@ -1053,7 +1061,7 @@ class GitRepoDescriptor extends DirectoryDescriptor {
|
|
|
| /// Schedule a Git command to run in this repository.
|
| void scheduleGit(List<String> args) {
|
| - _schedule((parentDir) {
|
| + schedule((parentDir) {
|
| var gitDir = new Directory(join(parentDir, name));
|
| return _runGit(args, gitDir);
|
| });
|
| @@ -1302,7 +1310,7 @@ class ScheduledProcess {
|
| _stdoutLines = pairFuture.then((pair) => pair.first.toList());
|
| _stderrLines = pairFuture.then((pair) => pair.last.toList());
|
|
|
| - _schedule((_) {
|
| + schedule((_) {
|
| if (!_endScheduled) {
|
| throw new StateError("Scheduled process $name must have shouldExit() "
|
| "or kill() called before the test is run.");
|
| @@ -1404,14 +1412,14 @@ class ScheduledProcess {
|
|
|
| /// Writes [line] to the process as stdin.
|
| void writeLine(String line) {
|
| - _schedule((_) => _processFuture.then(
|
| + schedule((_) => _processFuture.then(
|
| (p) => p.stdin.add('$line\n'.charCodes)));
|
| }
|
|
|
| /// Kills the process, and waits until it's dead.
|
| void kill() {
|
| _endScheduled = true;
|
| - _schedule((_) {
|
| + schedule((_) {
|
| _endExpected = true;
|
| _process.kill();
|
| timeout(_exitCodeFuture, _SCHEDULE_TIMEOUT,
|
| @@ -1423,7 +1431,7 @@ class ScheduledProcess {
|
| /// [expectedExitCode] (if given).
|
| void shouldExit([int expectedExitCode]) {
|
| _endScheduled = true;
|
| - _schedule((_) {
|
| + schedule((_) {
|
| _endExpected = true;
|
| return timeout(_exitCodeFuture, _SCHEDULE_TIMEOUT,
|
| "waiting for process $name to exit").then((exitCode) {
|
| @@ -1561,7 +1569,7 @@ Future _awaitObject(object) {
|
| }
|
|
|
| /// Schedules a callback to be called as part of the test case.
|
| -void _schedule(_ScheduledEvent event) {
|
| +void schedule(_ScheduledEvent event) {
|
| if (_scheduled == null) _scheduled = [];
|
| _scheduled.add(event);
|
| }
|
| @@ -1570,7 +1578,7 @@ void _schedule(_ScheduledEvent event) {
|
| /// [Future].
|
| Future _scheduleValue(_ScheduledEvent event) {
|
| var completer = new Completer();
|
| - _schedule((parentDir) {
|
| + schedule((parentDir) {
|
| chainToCompleter(event(parentDir), completer);
|
| return completer.future;
|
| });
|
| @@ -1599,7 +1607,7 @@ void _scheduleOnException(_ScheduledEvent event) {
|
| /// calling [completion] is unnecessary.
|
| void expectLater(Future actual, matcher, {String reason,
|
| FailureHandler failureHandler, bool verbose: false}) {
|
| - _schedule((_) {
|
| + schedule((_) {
|
| return actual.then((value) {
|
| expect(value, matcher, reason: reason, failureHandler: failureHandler,
|
| verbose: false);
|
|
|