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 /// Test infrastructure for testing pub. Unlike typical unit tests, most pub | 5 /// Test infrastructure for testing pub. Unlike typical unit tests, most pub |
6 /// tests are integration tests that stage some stuff on the file system, run | 6 /// tests are integration tests that stage some stuff on the file system, run |
7 /// pub, and then validate the results. This library provides an API to build | 7 /// pub, and then validate the results. This library provides an API to build |
8 /// tests like that. | 8 /// tests like that. |
9 library test_pub; | 9 library test_pub; |
10 | 10 |
(...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1308 /// Whether the process is expected to terminate at this point. | 1308 /// Whether the process is expected to terminate at this point. |
1309 bool _endExpected = false; | 1309 bool _endExpected = false; |
1310 | 1310 |
1311 /// Wraps a [Process] [Future] in a scheduled process. | 1311 /// Wraps a [Process] [Future] in a scheduled process. |
1312 ScheduledProcess(this.name, Future<PubProcess> process) | 1312 ScheduledProcess(this.name, Future<PubProcess> process) |
1313 : _processFuture = process { | 1313 : _processFuture = process { |
1314 var pairFuture = process.then((p) { | 1314 var pairFuture = process.then((p) { |
1315 _process = p; | 1315 _process = p; |
1316 | 1316 |
1317 byteStreamToLines(stream) { | 1317 byteStreamToLines(stream) { |
1318 var handledErrors = wrapStream(stream.handleError((e) { | 1318 return streamToLines(new ByteStream(stream.handleError((e) { |
1319 registerException(e.error, e.stackTrace); | 1319 registerException(e.error, e.stackTrace); |
1320 })); | 1320 })).toStringStream()); |
1321 return streamToLines(new ByteStream(handledErrors).toStringStream()); | |
1322 } | 1321 } |
1323 | 1322 |
1324 var stdoutTee = tee(byteStreamToLines(p.stdout)); | 1323 var stdoutTee = tee(byteStreamToLines(p.stdout)); |
1325 var stdoutPair = streamWithSubscription(stdoutTee.last); | 1324 var stdoutPair = streamWithSubscription(stdoutTee.last); |
1326 _stdout = stdoutPair.first; | 1325 _stdout = stdoutPair.first; |
1327 _stdoutSubscription = stdoutPair.last; | 1326 _stdoutSubscription = stdoutPair.last; |
1328 | 1327 |
1329 var stderrTee = tee(byteStreamToLines(p.stderr)); | 1328 var stderrTee = tee(byteStreamToLines(p.stderr)); |
1330 var stderrPair = streamWithSubscription(stderrTee.last); | 1329 var stderrPair = streamWithSubscription(stderrTee.last); |
1331 _stderr = stderrPair.first; | 1330 _stderr = stderrPair.first; |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1634 /// calling [completion] is unnecessary. | 1633 /// calling [completion] is unnecessary. |
1635 void expectLater(Future actual, matcher, {String reason, | 1634 void expectLater(Future actual, matcher, {String reason, |
1636 FailureHandler failureHandler, bool verbose: false}) { | 1635 FailureHandler failureHandler, bool verbose: false}) { |
1637 _schedule((_) { | 1636 _schedule((_) { |
1638 return actual.then((value) { | 1637 return actual.then((value) { |
1639 expect(value, matcher, reason: reason, failureHandler: failureHandler, | 1638 expect(value, matcher, reason: reason, failureHandler: failureHandler, |
1640 verbose: false); | 1639 verbose: false); |
1641 }); | 1640 }); |
1642 }); | 1641 }); |
1643 } | 1642 } |
OLD | NEW |