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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 } | 552 } |
553 | 553 |
554 /// Schedules renaming (moving) the directory at [from] to [to], both of which | 554 /// Schedules renaming (moving) the directory at [from] to [to], both of which |
555 /// are assumed to be relative to [sandboxDir]. | 555 /// are assumed to be relative to [sandboxDir]. |
556 void scheduleRename(String from, String to) { | 556 void scheduleRename(String from, String to) { |
557 _schedule((sandboxDir) { | 557 _schedule((sandboxDir) { |
558 return renameDir(path.join(sandboxDir, from), path.join(sandboxDir, to)); | 558 return renameDir(path.join(sandboxDir, from), path.join(sandboxDir, to)); |
559 }); | 559 }); |
560 } | 560 } |
561 | 561 |
| 562 |
| 563 /// Schedules creating a symlink at path [symlink] that points to [target], |
| 564 /// both of which are assumed to be relative to [sandboxDir]. |
| 565 void scheduleSymlink(String target, String symlink) { |
| 566 _schedule((sandboxDir) { |
| 567 return createSymlink(path.join(sandboxDir, target), |
| 568 path.join(sandboxDir, symlink)); |
| 569 }); |
| 570 } |
| 571 |
562 /// Schedules a call to the Pub command-line utility. Runs Pub with [args] and | 572 /// Schedules a call to the Pub command-line utility. Runs Pub with [args] and |
563 /// validates that its results match [output], [error], and [exitCode]. | 573 /// validates that its results match [output], [error], and [exitCode]. |
564 void schedulePub({List args, Pattern output, Pattern error, | 574 void schedulePub({List args, Pattern output, Pattern error, |
565 Future<Uri> tokenEndpoint, int exitCode: 0}) { | 575 Future<Uri> tokenEndpoint, int exitCode: 0}) { |
566 _schedule((sandboxDir) { | 576 _schedule((sandboxDir) { |
567 return _doPub(runProcess, sandboxDir, args, tokenEndpoint).then((result) { | 577 return _doPub(runProcess, sandboxDir, args, tokenEndpoint).then((result) { |
568 var failures = []; | 578 var failures = []; |
569 | 579 |
570 _validateOutput(failures, 'stdout', output, result.stdout); | 580 _validateOutput(failures, 'stdout', output, result.stdout); |
571 _validateOutput(failures, 'stderr', error, result.stderr); | 581 _validateOutput(failures, 'stderr', error, result.stderr); |
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1624 /// calling [completion] is unnecessary. | 1634 /// calling [completion] is unnecessary. |
1625 void expectLater(Future actual, matcher, {String reason, | 1635 void expectLater(Future actual, matcher, {String reason, |
1626 FailureHandler failureHandler, bool verbose: false}) { | 1636 FailureHandler failureHandler, bool verbose: false}) { |
1627 _schedule((_) { | 1637 _schedule((_) { |
1628 return actual.then((value) { | 1638 return actual.then((value) { |
1629 expect(value, matcher, reason: reason, failureHandler: failureHandler, | 1639 expect(value, matcher, reason: reason, failureHandler: failureHandler, |
1630 verbose: false); | 1640 verbose: false); |
1631 }); | 1641 }); |
1632 }); | 1642 }); |
1633 } | 1643 } |
OLD | NEW |