| 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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 options.environment['_PUB_TEST_TOKEN_ENDPOINT'] = | 382 options.environment['_PUB_TEST_TOKEN_ENDPOINT'] = |
| 383 tokenEndpoint.toString(); | 383 tokenEndpoint.toString(); |
| 384 } | 384 } |
| 385 return options; | 385 return options; |
| 386 }); | 386 }); |
| 387 | 387 |
| 388 return new ScheduledProcess.start(dartBin, dartArgs, options: optionsFuture, | 388 return new ScheduledProcess.start(dartBin, dartArgs, options: optionsFuture, |
| 389 description: args.isEmpty ? 'pub' : 'pub ${args.first}'); | 389 description: args.isEmpty ? 'pub' : 'pub ${args.first}'); |
| 390 } | 390 } |
| 391 | 391 |
| 392 /// Whether pub is running from within the Dart SDK, as opposed to from the Dart | |
| 393 /// source repository. | |
| 394 bool get _runningFromSdk => | |
| 395 fileExists(relativeToPub(path.join('..', '..', '..', '..', 'version'))); | |
| 396 | |
| 397 // TODO(nweiz): use the built-in mechanism for accessing this once it exists | 392 // TODO(nweiz): use the built-in mechanism for accessing this once it exists |
| 398 // (issue 9119). | 393 // (issue 9119). |
| 399 /// The path to the `packages` directory from which pub loads its dependencies. | 394 /// The path to the `packages` directory from which pub loads its dependencies. |
| 400 String get _packageRoot { | 395 String get _packageRoot { |
| 401 if (_runningFromSdk) { | 396 return path.absolute(path.join( |
| 402 return path.absolute(relativeToPub( | 397 path.dirname(new Options().executable), '..', '..', 'packages')); |
| 403 path.join('..', '..', '..', '..', 'packages'))); | |
| 404 } else { | |
| 405 return path.absolute(path.join( | |
| 406 path.dirname(new Options().executable), '..', '..', 'packages')); | |
| 407 } | |
| 408 } | 398 } |
| 409 | 399 |
| 410 /// Skips the current test if Git is not installed. This validates that the | 400 /// Skips the current test if Git is not installed. This validates that the |
| 411 /// current test is running on a buildbot in which case we expect git to be | 401 /// current test is running on a buildbot in which case we expect git to be |
| 412 /// installed. If we are not running on the buildbot, we will instead see if | 402 /// installed. If we are not running on the buildbot, we will instead see if |
| 413 /// git is installed and skip the test if not. This way, users don't need to | 403 /// git is installed and skip the test if not. This way, users don't need to |
| 414 /// have git installed to run the tests locally (unless they actually care | 404 /// have git installed to run the tests locally (unless they actually care |
| 415 /// about the pub git tests). | 405 /// about the pub git tests). |
| 416 /// | 406 /// |
| 417 /// This will also increase the [Schedule] timeout to 30 seconds on Windows, | 407 /// This will also increase the [Schedule] timeout to 30 seconds on Windows, |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 bool matches(item, MatchState matchState) { | 616 bool matches(item, MatchState matchState) { |
| 627 if (item is! Pair) return false; | 617 if (item is! Pair) return false; |
| 628 return _firstMatcher.matches(item.first, matchState) && | 618 return _firstMatcher.matches(item.first, matchState) && |
| 629 _lastMatcher.matches(item.last, matchState); | 619 _lastMatcher.matches(item.last, matchState); |
| 630 } | 620 } |
| 631 | 621 |
| 632 Description describe(Description description) { | 622 Description describe(Description description) { |
| 633 description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); | 623 description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); |
| 634 } | 624 } |
| 635 } | 625 } |
| OLD | NEW |