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; |
11 | 11 |
12 import 'dart:async'; | 12 import 'dart:async'; |
13 import 'dart:convert'; | 13 import 'dart:convert'; |
14 import 'dart:io'; | 14 import 'dart:io'; |
15 import 'dart:math'; | 15 import 'dart:math'; |
16 | 16 |
17 import 'package:http/testing.dart'; | 17 import 'package:http/testing.dart'; |
18 import 'package:path/path.dart' as p; | 18 import 'package:path/path.dart' as p; |
| 19 import 'package:pub_semver/pub_semver.dart'; |
19 import 'package:scheduled_test/scheduled_process.dart'; | 20 import 'package:scheduled_test/scheduled_process.dart'; |
20 import 'package:scheduled_test/scheduled_server.dart'; | 21 import 'package:scheduled_test/scheduled_server.dart'; |
21 import 'package:scheduled_test/scheduled_stream.dart'; | 22 import 'package:scheduled_test/scheduled_stream.dart'; |
22 import 'package:scheduled_test/scheduled_test.dart' hide fail; | 23 import 'package:scheduled_test/scheduled_test.dart' hide fail; |
23 import 'package:shelf/shelf.dart' as shelf; | 24 import 'package:shelf/shelf.dart' as shelf; |
24 import 'package:shelf/shelf_io.dart' as shelf_io; | 25 import 'package:shelf/shelf_io.dart' as shelf_io; |
25 import 'package:unittest/compact_vm_config.dart'; | 26 import 'package:unittest/compact_vm_config.dart'; |
26 import 'package:yaml/yaml.dart'; | 27 import 'package:yaml/yaml.dart'; |
27 | 28 |
28 import '../lib/src/entrypoint.dart'; | 29 import '../lib/src/entrypoint.dart'; |
29 import '../lib/src/exit_codes.dart' as exit_codes; | 30 import '../lib/src/exit_codes.dart' as exit_codes; |
30 // TODO(rnystrom): Using "gitlib" as the prefix here is ugly, but "git" collides | 31 // TODO(rnystrom): Using "gitlib" as the prefix here is ugly, but "git" collides |
31 // with the git descriptor method. Maybe we should try to clean up the top level | 32 // with the git descriptor method. Maybe we should try to clean up the top level |
32 // scope a bit? | 33 // scope a bit? |
33 import '../lib/src/git.dart' as gitlib; | 34 import '../lib/src/git.dart' as gitlib; |
34 import '../lib/src/http.dart'; | 35 import '../lib/src/http.dart'; |
35 import '../lib/src/io.dart'; | 36 import '../lib/src/io.dart'; |
36 import '../lib/src/lock_file.dart'; | 37 import '../lib/src/lock_file.dart'; |
37 import '../lib/src/log.dart' as log; | 38 import '../lib/src/log.dart' as log; |
38 import '../lib/src/package.dart'; | 39 import '../lib/src/package.dart'; |
39 import '../lib/src/pubspec.dart'; | 40 import '../lib/src/pubspec.dart'; |
40 import '../lib/src/source/hosted.dart'; | 41 import '../lib/src/source/hosted.dart'; |
41 import '../lib/src/source/path.dart'; | 42 import '../lib/src/source/path.dart'; |
42 import '../lib/src/source_registry.dart'; | 43 import '../lib/src/source_registry.dart'; |
43 import '../lib/src/system_cache.dart'; | 44 import '../lib/src/system_cache.dart'; |
44 import '../lib/src/utils.dart'; | 45 import '../lib/src/utils.dart'; |
45 import '../lib/src/validator.dart'; | 46 import '../lib/src/validator.dart'; |
46 import '../lib/src/version.dart'; | |
47 import 'descriptor.dart' as d; | 47 import 'descriptor.dart' as d; |
48 import 'serve_packages.dart'; | 48 import 'serve_packages.dart'; |
49 | 49 |
50 export 'serve_packages.dart'; | 50 export 'serve_packages.dart'; |
51 | 51 |
52 /// This should be called at the top of a test file to set up an appropriate | 52 /// This should be called at the top of a test file to set up an appropriate |
53 /// test configuration for the machine running the tests. | 53 /// test configuration for the machine running the tests. |
54 initConfig() { | 54 initConfig() { |
55 useCompactVMConfiguration(); | 55 useCompactVMConfiguration(); |
56 filterStacks = true; | 56 filterStacks = true; |
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
977 _lastMatcher.matches(item.last, matchState); | 977 _lastMatcher.matches(item.last, matchState); |
978 } | 978 } |
979 | 979 |
980 Description describe(Description description) { | 980 Description describe(Description description) { |
981 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); | 981 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); |
982 } | 982 } |
983 } | 983 } |
984 | 984 |
985 /// A [StreamMatcher] that matches multiple lines of output. | 985 /// A [StreamMatcher] that matches multiple lines of output. |
986 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); | 986 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); |
OLD | NEW |