| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Test infrastructure for testing pub. Unlike typical unit tests, most pub | 6 * Test infrastructure for testing pub. Unlike typical unit tests, most pub |
| 7 * tests are integration tests that stage some stuff on the file system, run | 7 * tests are integration tests that stage some stuff on the file system, run |
| 8 * pub, and then validate the results. This library provides an API to build | 8 * pub, and then validate the results. This library provides an API to build |
| 9 * tests like that. | 9 * tests like that. |
| 10 */ | 10 */ |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 * validates that its results match [output], [error], and [exitCode]. | 196 * validates that its results match [output], [error], and [exitCode]. |
| 197 */ | 197 */ |
| 198 void schedulePub([List<String> args, Pattern output, Pattern error, | 198 void schedulePub([List<String> args, Pattern output, Pattern error, |
| 199 int exitCode = 0]) { | 199 int exitCode = 0]) { |
| 200 _schedule((sandboxDir) { | 200 _schedule((sandboxDir) { |
| 201 String pathInSandbox(path) => join(getFullPath(sandboxDir), path); | 201 String pathInSandbox(path) => join(getFullPath(sandboxDir), path); |
| 202 | 202 |
| 203 return ensureDir(pathInSandbox(appPath)).chain((_) { | 203 return ensureDir(pathInSandbox(appPath)).chain((_) { |
| 204 // TODO(rnystrom): Hack in the cache directory path. Should pass this in | 204 // TODO(rnystrom): Hack in the cache directory path. Should pass this in |
| 205 // using environment var once #752 is done. | 205 // using environment var once #752 is done. |
| 206 args.add('--cachedir=${pathInSandbox(cachePath)}'); | 206 args.insertRange(0, 1, '--cachedir=${pathInSandbox(cachePath)}'); |
| 207 | 207 |
| 208 // TODO(rnystrom): Hack in the SDK path. Should pass this in using | 208 // TODO(rnystrom): Hack in the SDK path. Should pass this in using |
| 209 // environment var once #752 is done. | 209 // environment var once #752 is done. |
| 210 args.add('--sdkdir=${pathInSandbox(sdkPath)}'); | 210 args.insertRange(0, 1, '--sdkdir=${pathInSandbox(sdkPath)}'); |
| 211 | 211 |
| 212 return _runPub(args, pathInSandbox(appPath), pipeStdout: output == null, | 212 return _runPub(args, pathInSandbox(appPath), pipeStdout: output == null, |
| 213 pipeStderr: error == null); | 213 pipeStderr: error == null); |
| 214 }).transform((result) { | 214 }).transform((result) { |
| 215 _validateOutput(output, result.stdout); | 215 _validateOutput(output, result.stdout); |
| 216 _validateOutput(error, result.stderr); | 216 _validateOutput(error, result.stderr); |
| 217 | 217 |
| 218 Expect.equals(result.exitCode, exitCode, | 218 Expect.equals(result.exitCode, exitCode, |
| 219 'Pub returned exit code ${result.exitCode}, expected $exitCode.'); | 219 'Pub returned exit code ${result.exitCode}, expected $exitCode.'); |
| 220 | 220 |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 } | 717 } |
| 718 | 718 |
| 719 /** | 719 /** |
| 720 * Schedules a callback to be called after Pub is run with [runPub], even if it | 720 * Schedules a callback to be called after Pub is run with [runPub], even if it |
| 721 * fails. | 721 * fails. |
| 722 */ | 722 */ |
| 723 void _scheduleCleanup(_ScheduledEvent event) { | 723 void _scheduleCleanup(_ScheduledEvent event) { |
| 724 if (_scheduledCleanup == null) _scheduledCleanup = []; | 724 if (_scheduledCleanup == null) _scheduledCleanup = []; |
| 725 _scheduledCleanup.add(event); | 725 _scheduledCleanup.add(event); |
| 726 } | 726 } |
| OLD | NEW |