| 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. | 5 /// Test infrastructure for testing pub. |
| 6 /// | 6 /// |
| 7 /// Unlike typical unit tests, most pub tests are integration tests that stage | 7 /// Unlike typical unit tests, most pub tests are integration tests that stage |
| 8 /// some stuff on the file system, run pub, and then validate the results. This | 8 /// some stuff on the file system, run pub, and then validate the results. This |
| 9 /// library provides an API to build tests like that. | 9 /// library provides an API to build tests like that. |
| 10 library test_pub; | 10 library test_pub; |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 } | 515 } |
| 516 | 516 |
| 517 // If there's a snapshot available, use it. The user is responsible for | 517 // If there's a snapshot available, use it. The user is responsible for |
| 518 // ensuring this is up-to-date.. | 518 // ensuring this is up-to-date.. |
| 519 // | 519 // |
| 520 // TODO(nweiz): When the test runner supports plugins, create one to | 520 // TODO(nweiz): When the test runner supports plugins, create one to |
| 521 // auto-generate the snapshot before each run. | 521 // auto-generate the snapshot before each run. |
| 522 var pubPath = p.absolute(p.join(pubRoot, 'bin/pub.dart')); | 522 var pubPath = p.absolute(p.join(pubRoot, 'bin/pub.dart')); |
| 523 if (fileExists('$pubPath.snapshot')) pubPath += '.snapshot'; | 523 if (fileExists('$pubPath.snapshot')) pubPath += '.snapshot'; |
| 524 | 524 |
| 525 var dartArgs = [pubPath, '--verbose']; | 525 var dartArgs = [ |
| 526 dartArgs.addAll(args); | 526 '--package-root=${p.toUri(p.absolute(p.fromUri(Platform.packageRoot)))}', |
| 527 pubPath, |
| 528 '--verbose' |
| 529 ]..addAll(args); |
| 527 | 530 |
| 528 if (tokenEndpoint == null) tokenEndpoint = new Future.value(); | 531 if (tokenEndpoint == null) tokenEndpoint = new Future.value(); |
| 529 var environmentFuture = tokenEndpoint | 532 var environmentFuture = tokenEndpoint |
| 530 .then((tokenEndpoint) => getPubTestEnvironment(tokenEndpoint)) | 533 .then((tokenEndpoint) => getPubTestEnvironment(tokenEndpoint)) |
| 531 .then((pubEnvironment) { | 534 .then((pubEnvironment) { |
| 532 if (environment != null) pubEnvironment.addAll(environment); | 535 if (environment != null) pubEnvironment.addAll(environment); |
| 533 return pubEnvironment; | 536 return pubEnvironment; |
| 534 }); | 537 }); |
| 535 | 538 |
| 536 return new PubProcess.start(dartBin, dartArgs, environment: environmentFuture, | 539 return new PubProcess.start(dartBin, dartArgs, environment: environmentFuture, |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 _lastMatcher.matches(item.last, matchState); | 973 _lastMatcher.matches(item.last, matchState); |
| 971 } | 974 } |
| 972 | 975 |
| 973 Description describe(Description description) { | 976 Description describe(Description description) { |
| 974 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); | 977 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); |
| 975 } | 978 } |
| 976 } | 979 } |
| 977 | 980 |
| 978 /// A [StreamMatcher] that matches multiple lines of output. | 981 /// A [StreamMatcher] that matches multiple lines of output. |
| 979 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); | 982 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); |
| OLD | NEW |