| 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 | 203 |
| 204 return ensureDir(pathInSandbox(appPath)).chain((_) { | 204 return ensureDir(pathInSandbox(appPath)).chain((_) { |
| 205 // TODO(rnystrom): Hack in the cache directory path. Should pass this in | 205 // TODO(rnystrom): Hack in the cache directory path. Should pass this in |
| 206 // using environment var once #752 is done. | 206 // using environment var once #752 is done. |
| 207 args.insertRange(0, 1, '--cachedir=${pathInSandbox(cachePath)}'); | 207 args.insertRange(0, 1, '--cachedir=${pathInSandbox(cachePath)}'); |
| 208 | 208 |
| 209 // TODO(rnystrom): Hack in the SDK path. Should pass this in using | 209 // TODO(rnystrom): Hack in the SDK path. Should pass this in using |
| 210 // environment var once #752 is done. | 210 // environment var once #752 is done. |
| 211 args.insertRange(0, 1, '--sdkdir=${pathInSandbox(sdkPath)}'); | 211 args.insertRange(0, 1, '--sdkdir=${pathInSandbox(sdkPath)}'); |
| 212 | 212 |
| 213 // If an error occurs in pub during testing, we want it to print the stack |
| 214 // trace so it can be debugged. |
| 215 args.insertRange(0, 1, '--trace'); |
| 216 |
| 213 return _runPub(args, pathInSandbox(appPath), pipeStdout: output == null, | 217 return _runPub(args, pathInSandbox(appPath), pipeStdout: output == null, |
| 214 pipeStderr: error == null); | 218 pipeStderr: error == null); |
| 215 }).transform((result) { | 219 }).transform((result) { |
| 216 _validateOutput(output, result.stdout); | 220 _validateOutput(output, result.stdout); |
| 217 _validateOutput(error, result.stderr); | 221 _validateOutput(error, result.stderr); |
| 218 | 222 |
| 219 Expect.equals(result.exitCode, exitCode, | 223 Expect.equals(result.exitCode, exitCode, |
| 220 'Pub returned exit code ${result.exitCode}, expected $exitCode.'); | 224 'Pub returned exit code ${result.exitCode}, expected $exitCode.'); |
| 221 | 225 |
| 222 return null; | 226 return null; |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 } | 722 } |
| 719 | 723 |
| 720 /** | 724 /** |
| 721 * Schedules a callback to be called after Pub is run with [runPub], even if it | 725 * Schedules a callback to be called after Pub is run with [runPub], even if it |
| 722 * fails. | 726 * fails. |
| 723 */ | 727 */ |
| 724 void _scheduleCleanup(_ScheduledEvent event) { | 728 void _scheduleCleanup(_ScheduledEvent event) { |
| 725 if (_scheduledCleanup == null) _scheduledCleanup = []; | 729 if (_scheduledCleanup == null) _scheduledCleanup = []; |
| 726 _scheduledCleanup.add(event); | 730 _scheduledCleanup.add(event); |
| 727 } | 731 } |
| OLD | NEW |