OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1432 return timeout(_stderrFuture.then((stream) => stream.toList()) | 1432 return timeout(_stderrFuture.then((stream) => stream.toList()) |
1433 .then((lines) => lines.join("\n")), | 1433 .then((lines) => lines.join("\n")), |
1434 _SCHEDULE_TIMEOUT, | 1434 _SCHEDULE_TIMEOUT, |
1435 "waiting for the last stderr line from process $name"); | 1435 "waiting for the last stderr line from process $name"); |
1436 }); | 1436 }); |
1437 } | 1437 } |
1438 | 1438 |
1439 /// Writes [line] to the process as stdin. | 1439 /// Writes [line] to the process as stdin. |
1440 void writeLine(String line) { | 1440 void writeLine(String line) { |
1441 _schedule((_) => _processFuture.then( | 1441 _schedule((_) => _processFuture.then( |
1442 (p) => p.stdin.writeln('$line'))); | 1442 (p) => p.stdin.add(encodeUtf8('$line\n')))); |
1443 } | 1443 } |
1444 | 1444 |
1445 /// Kills the process, and waits until it's dead. | 1445 /// Kills the process, and waits until it's dead. |
1446 void kill() { | 1446 void kill() { |
1447 _endScheduled = true; | 1447 _endScheduled = true; |
1448 _schedule((_) { | 1448 _schedule((_) { |
1449 _endExpected = true; | 1449 _endExpected = true; |
1450 _process.kill(); | 1450 _process.kill(); |
1451 timeout(_exitCodeFuture, _SCHEDULE_TIMEOUT, | 1451 timeout(_exitCodeFuture, _SCHEDULE_TIMEOUT, |
1452 "waiting for process $name to die"); | 1452 "waiting for process $name to die"); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1633 /// calling [completion] is unnecessary. | 1633 /// calling [completion] is unnecessary. |
1634 void expectLater(Future actual, matcher, {String reason, | 1634 void expectLater(Future actual, matcher, {String reason, |
1635 FailureHandler failureHandler, bool verbose: false}) { | 1635 FailureHandler failureHandler, bool verbose: false}) { |
1636 _schedule((_) { | 1636 _schedule((_) { |
1637 return actual.then((value) { | 1637 return actual.then((value) { |
1638 expect(value, matcher, reason: reason, failureHandler: failureHandler, | 1638 expect(value, matcher, reason: reason, failureHandler: failureHandler, |
1639 verbose: false); | 1639 verbose: false); |
1640 }); | 1640 }); |
1641 }); | 1641 }); |
1642 } | 1642 } |
OLD | NEW |