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