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 import 'dart:async'; | 10 import 'dart:async'; |
11 import 'dart:convert'; | 11 import 'dart:convert'; |
12 import 'dart:io'; | 12 import 'dart:io'; |
13 import 'dart:math'; | 13 import 'dart:math'; |
14 | 14 |
15 import 'package:http/testing.dart'; | 15 import 'package:http/testing.dart'; |
16 import 'package:path/path.dart' as p; | 16 import 'package:path/path.dart' as p; |
17 import 'package:pub/src/entrypoint.dart'; | 17 import 'package:pub/src/entrypoint.dart'; |
18 import 'package:pub/src/exceptions.dart'; | 18 import 'package:pub/src/exceptions.dart'; |
19 import 'package:pub/src/exit_codes.dart' as exit_codes; | 19 import 'package:pub/src/exit_codes.dart' as exit_codes; |
20 // TODO(rnystrom): Using "gitlib" as the prefix here is ugly, but "git" collides | 20 // TODO(rnystrom): Using "gitlib" as the prefix here is ugly, but "git" collides |
21 // with the git descriptor method. Maybe we should try to clean up the top level | 21 // with the git descriptor method. Maybe we should try to clean up the top level |
22 // scope a bit? | 22 // scope a bit? |
23 import 'package:pub/src/git.dart' as gitlib; | 23 import 'package:pub/src/git.dart' as gitlib; |
24 import 'package:pub/src/http.dart'; | 24 import 'package:pub/src/http.dart'; |
25 import 'package:pub/src/io.dart'; | 25 import 'package:pub/src/io.dart'; |
26 import 'package:pub/src/lock_file.dart'; | 26 import 'package:pub/src/lock_file.dart'; |
27 import 'package:pub/src/log.dart' as log; | 27 import 'package:pub/src/log.dart' as log; |
28 import 'package:pub/src/package.dart'; | |
29 import 'package:pub/src/source_registry.dart'; | 28 import 'package:pub/src/source_registry.dart'; |
30 import 'package:pub/src/system_cache.dart'; | 29 import 'package:pub/src/system_cache.dart'; |
31 import 'package:pub/src/utils.dart'; | 30 import 'package:pub/src/utils.dart'; |
32 import 'package:pub/src/validator.dart'; | 31 import 'package:pub/src/validator.dart'; |
33 import 'package:pub_semver/pub_semver.dart'; | 32 import 'package:pub_semver/pub_semver.dart'; |
34 import 'package:scheduled_test/scheduled_process.dart'; | 33 import 'package:scheduled_test/scheduled_process.dart'; |
35 import 'package:scheduled_test/scheduled_server.dart'; | 34 import 'package:scheduled_test/scheduled_server.dart'; |
36 import 'package:scheduled_test/scheduled_stream.dart'; | 35 import 'package:scheduled_test/scheduled_stream.dart'; |
37 import 'package:scheduled_test/scheduled_test.dart' hide fail; | 36 import 'package:scheduled_test/scheduled_test.dart' hide fail; |
38 | 37 |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 var dependencies = {}; | 515 var dependencies = {}; |
517 | 516 |
518 if (sandbox != null) { | 517 if (sandbox != null) { |
519 for (var package in sandbox) { | 518 for (var package in sandbox) { |
520 dependencies[package] = '../$package'; | 519 dependencies[package] = '../$package'; |
521 } | 520 } |
522 } | 521 } |
523 | 522 |
524 var packages = dependencies.keys.map((name) { | 523 var packages = dependencies.keys.map((name) { |
525 var dependencyPath = dependencies[name]; | 524 var dependencyPath = dependencies[name]; |
526 return new PackageId(name, 'path', new Version(0, 0, 0), { | 525 return sources.path.idFor(name, new Version(0, 0, 0), dependencyPath); |
527 'path': dependencyPath, | |
528 'relative': p.isRelative(dependencyPath) | |
529 }); | |
530 }).toList(); | 526 }).toList(); |
531 | 527 |
532 if (hosted != null) { | 528 if (hosted != null) { |
533 hosted.forEach((name, version) { | 529 hosted.forEach((name, version) { |
534 var id = new PackageId(name, 'hosted', new Version.parse(version), name); | 530 var id = sources.hosted.idFor(name, new Version.parse(version)); |
535 packages.add(id); | 531 packages.add(id); |
536 }); | 532 }); |
537 } | 533 } |
538 | 534 |
539 return new LockFile(packages, sources); | 535 return new LockFile(packages); |
540 } | 536 } |
541 | 537 |
542 /// Returns the path to the version of [package] used by pub. | 538 /// Returns the path to the version of [package] used by pub. |
543 String packagePath(String package) { | 539 String packagePath(String package) { |
544 if (runningFromDartRepo) { | 540 if (runningFromDartRepo) { |
545 return dirExists(p.join(dartRepoRoot, 'pkg', package)) | 541 return dirExists(p.join(dartRepoRoot, 'pkg', package)) |
546 ? p.join(dartRepoRoot, 'pkg', package) | 542 ? p.join(dartRepoRoot, 'pkg', package) |
547 : p.join(dartRepoRoot, 'third_party', 'pkg', package); | 543 : p.join(dartRepoRoot, 'third_party', 'pkg', package); |
548 } | 544 } |
549 | 545 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 _lastMatcher.matches(item.last, matchState); | 743 _lastMatcher.matches(item.last, matchState); |
748 } | 744 } |
749 | 745 |
750 Description describe(Description description) { | 746 Description describe(Description description) { |
751 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); | 747 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); |
752 } | 748 } |
753 } | 749 } |
754 | 750 |
755 /// A [StreamMatcher] that matches multiple lines of output. | 751 /// A [StreamMatcher] that matches multiple lines of output. |
756 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); | 752 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); |
OLD | NEW |