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 14 matching lines...) Expand all Loading... | |
25 // TODO(rnystrom): Using "gitlib" as the prefix here is ugly, but "git" collides | 25 // TODO(rnystrom): Using "gitlib" as the prefix here is ugly, but "git" collides |
26 // with the git descriptor method. Maybe we should try to clean up the top level | 26 // with the git descriptor method. Maybe we should try to clean up the top level |
27 // scope a bit? | 27 // scope a bit? |
28 import '../lib/src/git.dart' as gitlib; | 28 import '../lib/src/git.dart' as gitlib; |
29 import '../lib/src/http.dart'; | 29 import '../lib/src/http.dart'; |
30 import '../lib/src/io.dart'; | 30 import '../lib/src/io.dart'; |
31 import '../lib/src/lock_file.dart'; | 31 import '../lib/src/lock_file.dart'; |
32 import '../lib/src/log.dart' as log; | 32 import '../lib/src/log.dart' as log; |
33 import '../lib/src/package.dart'; | 33 import '../lib/src/package.dart'; |
34 import '../lib/src/safe_http_server.dart'; | 34 import '../lib/src/safe_http_server.dart'; |
35 import '../lib/src/source/path.dart'; | |
36 import '../lib/src/source_registry.dart'; | |
35 import '../lib/src/system_cache.dart'; | 37 import '../lib/src/system_cache.dart'; |
36 import '../lib/src/utils.dart'; | 38 import '../lib/src/utils.dart'; |
37 import '../lib/src/validator.dart'; | 39 import '../lib/src/validator.dart'; |
38 import '../lib/src/version.dart'; | 40 import '../lib/src/version.dart'; |
39 import 'descriptor.dart' as d; | 41 import 'descriptor.dart' as d; |
40 | 42 |
41 /// This should be called at the top of a test file to set up an appropriate | 43 /// This should be called at the top of a test file to set up an appropriate |
42 /// test configuration for the machine running the tests. | 44 /// test configuration for the machine running the tests. |
43 initConfig() { | 45 initConfig() { |
44 useCompactVMConfiguration(); | 46 useCompactVMConfiguration(); |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
598 | 600 |
599 schedule(() { | 601 schedule(() { |
600 return gitlib.isInstalled.then((installed) { | 602 return gitlib.isInstalled.then((installed) { |
601 if (installed) return; | 603 if (installed) return; |
602 if (runningOnBuildbot) return; | 604 if (runningOnBuildbot) return; |
603 currentSchedule.abort(); | 605 currentSchedule.abort(); |
604 }); | 606 }); |
605 }, 'ensuring that Git is installed'); | 607 }, 'ensuring that Git is installed'); |
606 } | 608 } |
607 | 609 |
610 /// Lists all the sources required for tests. | |
611 final SourceRegistry _sources = new SourceRegistry() | |
612 ..register(new PathSource()); | |
Bob Nystrom
2013/10/28 22:13:32
Since this is just used in one method, let's just
Anton Moiseev
2013/11/03 11:11:43
Done.
| |
613 | |
608 /// Create a lock file for [package] without running `pub get`. | 614 /// Create a lock file for [package] without running `pub get`. |
609 /// | 615 /// |
610 /// This creates a lock file with only path dependencies. [sandbox] is a list of | 616 /// This creates a lock file with only path dependencies. [sandbox] is a list of |
611 /// dependencies to be found in the sandbox directory. [pkg] is a list of | 617 /// dependencies to be found in the sandbox directory. [pkg] is a list of |
612 /// packages in the Dart repo's "pkg" directory; each package listed here and | 618 /// packages in the Dart repo's "pkg" directory; each package listed here and |
613 /// all its dependencies will be linked to the version in the Dart repo. | 619 /// all its dependencies will be linked to the version in the Dart repo. |
614 void createLockFile(String package, {Iterable<String> sandbox, | 620 void createLockFile(String package, {Iterable<String> sandbox, |
615 Iterable<String> pkg}) { | 621 Iterable<String> pkg}) { |
616 var dependencies = {}; | 622 var dependencies = {}; |
617 | 623 |
(...skipping 23 matching lines...) Expand all Loading... | |
641 } | 647 } |
642 | 648 |
643 var lockFile = new LockFile.empty(); | 649 var lockFile = new LockFile.empty(); |
644 dependencies.forEach((name, dependencyPath) { | 650 dependencies.forEach((name, dependencyPath) { |
645 var id = new PackageId(name, 'path', new Version(0, 0, 0), { | 651 var id = new PackageId(name, 'path', new Version(0, 0, 0), { |
646 'path': dependencyPath, | 652 'path': dependencyPath, |
647 'relative': path.isRelative(dependencyPath) | 653 'relative': path.isRelative(dependencyPath) |
648 }); | 654 }); |
649 lockFile.packages[name] = id; | 655 lockFile.packages[name] = id; |
650 }); | 656 }); |
651 d.file(path.join(package, 'pubspec.lock'), lockFile.serialize()).create(); | 657 |
658 d.file(path.join(package, 'pubspec.lock'), | |
659 lockFile.serialize(null, _sources)).create(); | |
652 } | 660 } |
653 | 661 |
654 /// Use [client] as the mock HTTP client for this test. | 662 /// Use [client] as the mock HTTP client for this test. |
655 /// | 663 /// |
656 /// Note that this will only affect HTTP requests made via http.dart in the | 664 /// Note that this will only affect HTTP requests made via http.dart in the |
657 /// parent process. | 665 /// parent process. |
658 void useMockClient(MockClient client) { | 666 void useMockClient(MockClient client) { |
659 var oldInnerClient = httpClient.inner; | 667 var oldInnerClient = httpClient.inner; |
660 httpClient.inner = client; | 668 httpClient.inner = client; |
661 currentSchedule.onComplete.schedule(() { | 669 currentSchedule.onComplete.schedule(() { |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
836 bool matches(item, Map matchState) { | 844 bool matches(item, Map matchState) { |
837 if (item is! Pair) return false; | 845 if (item is! Pair) return false; |
838 return _firstMatcher.matches(item.first, matchState) && | 846 return _firstMatcher.matches(item.first, matchState) && |
839 _lastMatcher.matches(item.last, matchState); | 847 _lastMatcher.matches(item.last, matchState); |
840 } | 848 } |
841 | 849 |
842 Description describe(Description description) { | 850 Description describe(Description description) { |
843 description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); | 851 description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); |
844 } | 852 } |
845 } | 853 } |
OLD | NEW |