| 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 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 return server.url.chain((url) { | 622 return server.url.chain((url) { |
| 623 var tokenEndpoint = url.resolve('/token'); | 623 var tokenEndpoint = url.resolve('/token'); |
| 624 if (args == null) args = []; | 624 if (args == null) args = []; |
| 625 args = flatten(['lish', '--server', url.toString(), args]); | 625 args = flatten(['lish', '--server', url.toString(), args]); |
| 626 return _doPub(startProcess, sandboxDir, args, tokenEndpoint); | 626 return _doPub(startProcess, sandboxDir, args, tokenEndpoint); |
| 627 }); | 627 }); |
| 628 }); | 628 }); |
| 629 return new ScheduledProcess("pub lish", process); | 629 return new ScheduledProcess("pub lish", process); |
| 630 } | 630 } |
| 631 | 631 |
| 632 /// Handles the beginning confirmation process for uploading a packages. |
| 633 /// Ensures that the right output is shown and then enters "y" to confirm the |
| 634 /// upload. |
| 635 void confirmPublish(ScheduledProcess pub) { |
| 636 // TODO(rnystrom): This is overly specific and inflexible regarding different |
| 637 // test packages. Should validate this a little more loosely. |
| 638 expectLater(pub.nextLine(), equals('Publishing "test_pkg" 1.0.0:')); |
| 639 expectLater(pub.nextLine(), equals("|-- LICENSE")); |
| 640 expectLater(pub.nextLine(), equals("|-- lib")); |
| 641 expectLater(pub.nextLine(), equals("| '-- test_pkg.dart")); |
| 642 expectLater(pub.nextLine(), equals("'-- pubspec.yaml")); |
| 643 expectLater(pub.nextLine(), equals("")); |
| 644 |
| 645 pub.writeLine("y"); |
| 646 } |
| 647 |
| 648 |
| 632 /// Calls [fn] with appropriately modified arguments to run a pub process. [fn] | 649 /// Calls [fn] with appropriately modified arguments to run a pub process. [fn] |
| 633 /// should have the same signature as [startProcess], except that the returned | 650 /// should have the same signature as [startProcess], except that the returned |
| 634 /// [Future] may have a type other than [Process]. | 651 /// [Future] may have a type other than [Process]. |
| 635 Future _doPub(Function fn, sandboxDir, List<String> args, Uri tokenEndpoint) { | 652 Future _doPub(Function fn, sandboxDir, List<String> args, Uri tokenEndpoint) { |
| 636 String pathInSandbox(path) => join(getFullPath(sandboxDir), path); | 653 String pathInSandbox(path) => join(getFullPath(sandboxDir), path); |
| 637 | 654 |
| 638 return ensureDir(pathInSandbox(appPath)).chain((_) { | 655 return ensureDir(pathInSandbox(appPath)).chain((_) { |
| 639 // Find a Dart executable we can use to spawn. Use the same one that was | 656 // Find a Dart executable we can use to spawn. Use the same one that was |
| 640 // used to run this script itself. | 657 // used to run this script itself. |
| 641 var dartBin = new Options().executable; | 658 var dartBin = new Options().executable; |
| (...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1641 /// calling [completion] is unnecessary. | 1658 /// calling [completion] is unnecessary. |
| 1642 void expectLater(Future actual, matcher, {String reason, | 1659 void expectLater(Future actual, matcher, {String reason, |
| 1643 FailureHandler failureHandler, bool verbose: false}) { | 1660 FailureHandler failureHandler, bool verbose: false}) { |
| 1644 _schedule((_) { | 1661 _schedule((_) { |
| 1645 return actual.transform((value) { | 1662 return actual.transform((value) { |
| 1646 expect(value, matcher, reason: reason, failureHandler: failureHandler, | 1663 expect(value, matcher, reason: reason, failureHandler: failureHandler, |
| 1647 verbose: false); | 1664 verbose: false); |
| 1648 }); | 1665 }); |
| 1649 }); | 1666 }); |
| 1650 } | 1667 } |
| OLD | NEW |