| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // TODO(rnystrom): Hack in the cache directory path. Should pass this | 101 // TODO(rnystrom): Hack in the cache directory path. Should pass this |
| 102 // in using environment var once #752 is done. | 102 // in using environment var once #752 is done. |
| 103 args.add('--cachedir=${pathInSandbox(cachePath)}'); | 103 args.add('--cachedir=${pathInSandbox(cachePath)}'); |
| 104 | 104 |
| 105 // TODO(rnystrom): Hack in the SDK path. Should pass this in using | 105 // TODO(rnystrom): Hack in the SDK path. Should pass this in using |
| 106 // environment var once #752 is done. | 106 // environment var once #752 is done. |
| 107 args.add('--sdkdir=${pathInSandbox(sdkPath)}'); | 107 args.add('--sdkdir=${pathInSandbox(sdkPath)}'); |
| 108 | 108 |
| 109 return _runPub(args, pathInSandbox(appPath)); | 109 return _runPub(args, pathInSandbox(appPath)); |
| 110 }).chain((result) { | 110 }).chain((result) { |
| 111 _validateOutput(output, result.stdout); | |
| 112 | |
| 113 Expect.equals(result.stderr.length, 0, | 111 Expect.equals(result.stderr.length, 0, |
| 114 'Did not expect any output on stderr, and got:\n' + | 112 'Did not expect any output on stderr, and got:\n' + |
| 115 Strings.join(result.stderr, '\n')); | 113 Strings.join(result.stderr, '\n')); |
| 116 | 114 |
| 117 Expect.equals(result.exitCode, exitCode, | 115 Expect.equals(result.exitCode, exitCode, |
| 118 'Pub returned exit code ${result.exitCode}, expected $exitCode.'); | 116 'Pub returned exit code ${result.exitCode}, expected $exitCode.'); |
| 119 | 117 |
| 118 _validateOutput(output, result.stdout); |
| 119 |
| 120 return _runScheduled(createdSandboxDir, _scheduledAfterPub); | 120 return _runScheduled(createdSandboxDir, _scheduledAfterPub); |
| 121 }); | 121 }); |
| 122 | 122 |
| 123 future.then((_) { | 123 future.then((_) { |
| 124 deleteSandboxIfCreated(asyncDone); | 124 deleteSandboxIfCreated(asyncDone); |
| 125 }); | 125 }); |
| 126 | 126 |
| 127 future.handleException((error) { | 127 future.handleException((error) { |
| 128 // If an error occurs during testing, delete the sandbox, throw the error so | 128 // If an error occurs during testing, delete the sandbox, throw the error so |
| 129 // that the test framework sees it, then finally call asyncDone so that the | 129 // that the test framework sees it, then finally call asyncDone so that the |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 _scheduledBeforePub.add(event); | 385 _scheduledBeforePub.add(event); |
| 386 } | 386 } |
| 387 | 387 |
| 388 /** | 388 /** |
| 389 * Schedules a callback to be called after Pub is run with [runPub]. | 389 * Schedules a callback to be called after Pub is run with [runPub]. |
| 390 */ | 390 */ |
| 391 void _scheduleAfterPub(_ScheduledEvent event) { | 391 void _scheduleAfterPub(_ScheduledEvent event) { |
| 392 if (_scheduledAfterPub == null) _scheduledAfterPub = []; | 392 if (_scheduledAfterPub == null) _scheduledAfterPub = []; |
| 393 _scheduledAfterPub.add(event); | 393 _scheduledAfterPub.add(event); |
| 394 } | 394 } |
| OLD | NEW |