| 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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 warning: warning, exitCode: exitCode); | 347 warning: warning, exitCode: exitCode); |
| 348 } | 348 } |
| 349 | 349 |
| 350 /// Schedules starting the "pub [global] run" process and validates the | 350 /// Schedules starting the "pub [global] run" process and validates the |
| 351 /// expected startup output. | 351 /// expected startup output. |
| 352 /// | 352 /// |
| 353 /// If [global] is `true`, this invokes "pub global run", otherwise it does | 353 /// If [global] is `true`, this invokes "pub global run", otherwise it does |
| 354 /// "pub run". | 354 /// "pub run". |
| 355 /// | 355 /// |
| 356 /// Returns the `pub run` process. | 356 /// Returns the `pub run` process. |
| 357 ScheduledProcess pubRun({bool global: false, Iterable<String> args}) { | 357 ScheduledProcess pubRun({bool shouldGetFirst: false, bool global: false, |
| 358 Iterable<String> args}) { |
| 358 var pubArgs = global ? ["global", "run"] : ["run"]; | 359 var pubArgs = global ? ["global", "run"] : ["run"]; |
| 359 pubArgs.addAll(args); | 360 pubArgs.addAll(args); |
| 360 var pub = startPub(args: pubArgs); | 361 var pub = startPub(args: pubArgs); |
| 361 | 362 |
| 363 if (shouldGetFirst) { |
| 364 pub.stdout.expect(consumeThrough(anyOf([ |
| 365 "Got dependencies!", |
| 366 matches(new RegExp(r"^Changed \d+ dependenc")) |
| 367 ]))); |
| 368 } |
| 369 |
| 362 // Loading sources and transformers isn't normally printed, but the pub test | 370 // Loading sources and transformers isn't normally printed, but the pub test |
| 363 // infrastructure runs pub in verbose mode, which enables this. | 371 // infrastructure runs pub in verbose mode, which enables this. |
| 364 pub.stdout.expect(consumeWhile(startsWith("Loading"))); | 372 pub.stdout.expect(consumeWhile(startsWith("Loading"))); |
| 365 | 373 |
| 366 return pub; | 374 return pub; |
| 367 } | 375 } |
| 368 | 376 |
| 369 /// Defines an integration test. | 377 /// Defines an integration test. |
| 370 /// | 378 /// |
| 371 /// The [body] should schedule a series of operations which will be run | 379 /// The [body] should schedule a series of operations which will be run |
| (...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 _lastMatcher.matches(item.last, matchState); | 1007 _lastMatcher.matches(item.last, matchState); |
| 1000 } | 1008 } |
| 1001 | 1009 |
| 1002 Description describe(Description description) { | 1010 Description describe(Description description) { |
| 1003 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); | 1011 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); |
| 1004 } | 1012 } |
| 1005 } | 1013 } |
| 1006 | 1014 |
| 1007 /// A [StreamMatcher] that matches multiple lines of output. | 1015 /// A [StreamMatcher] that matches multiple lines of output. |
| 1008 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); | 1016 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); |
| OLD | NEW |