Chromium Code Reviews

Side by Side Diff: test/test_pub.dart

Issue 2044253003: Refactor Source and SourceRegistry. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Rename LiveSource to BoundSource. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « test/pubspec_test.dart ('k') | test/version_solver_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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';
(...skipping 35 matching lines...)
46 /// enabled. 46 /// enabled.
47 Matcher isMinifiedDart2JSOutput = 47 Matcher isMinifiedDart2JSOutput =
48 isNot(contains("// The code supports the following hooks")); 48 isNot(contains("// The code supports the following hooks"));
49 49
50 /// A [Matcher] that matches JavaScript generated by dart2js with minification 50 /// A [Matcher] that matches JavaScript generated by dart2js with minification
51 /// disabled. 51 /// disabled.
52 Matcher isUnminifiedDart2JSOutput = 52 Matcher isUnminifiedDart2JSOutput =
53 contains("// The code supports the following hooks"); 53 contains("// The code supports the following hooks");
54 54
55 /// The entrypoint for pub itself. 55 /// The entrypoint for pub itself.
56 final _entrypoint = new Entrypoint( 56 final _entrypoint = new Entrypoint(pubRoot, new SystemCache(isOffline: true));
57 pubRoot, new SystemCache.withSources(isOffline: true));
58 57
59 /// Converts [value] into a YAML string. 58 /// Converts [value] into a YAML string.
60 String yaml(value) => JSON.encode(value); 59 String yaml(value) => JSON.encode(value);
61 60
62 /// The full path to the created sandbox directory for an integration test. 61 /// The full path to the created sandbox directory for an integration test.
63 String get sandboxDir => _sandboxDir; 62 String get sandboxDir => _sandboxDir;
64 String _sandboxDir; 63 String _sandboxDir;
65 64
66 /// The path of the package cache directory used for tests, relative to the 65 /// The path of the package cache directory used for tests, relative to the
67 /// sandbox directory. 66 /// sandbox directory.
(...skipping 401 matching lines...)
469 /// [sandbox] is a list of path dependencies to be found in the sandbox 468 /// [sandbox] is a list of path dependencies to be found in the sandbox
470 /// directory. [pkg] is a list of packages in the Dart repo's "pkg" directory; 469 /// directory. [pkg] is a list of packages in the Dart repo's "pkg" directory;
471 /// each package listed here and all its dependencies will be linked to the 470 /// each package listed here and all its dependencies will be linked to the
472 /// version in the Dart repo. 471 /// version in the Dart repo.
473 /// 472 ///
474 /// [hosted] is a list of package names to version strings for dependencies on 473 /// [hosted] is a list of package names to version strings for dependencies on
475 /// hosted packages. 474 /// hosted packages.
476 void createLockFile(String package, {Iterable<String> sandbox, 475 void createLockFile(String package, {Iterable<String> sandbox,
477 Map<String, String> hosted}) { 476 Map<String, String> hosted}) {
478 schedule(() async { 477 schedule(() async {
479 var cache = new SystemCache.withSources( 478 var cache = new SystemCache(rootDir: p.join(sandboxDir, cachePath));
480 rootDir: p.join(sandboxDir, cachePath));
481 479
482 var lockFile = _createLockFile(cache.sources, 480 var lockFile = _createLockFile(cache.sources,
483 sandbox: sandbox, hosted: hosted); 481 sandbox: sandbox, hosted: hosted);
484 482
485 await d.dir(package, [ 483 await d.dir(package, [
486 d.file('pubspec.lock', lockFile.serialize(null)), 484 d.file('pubspec.lock', lockFile.serialize(null)),
487 d.file('.packages', lockFile.packagesFile(package)) 485 d.file('.packages', lockFile.packagesFile(cache, package))
488 ]).create(); 486 ]).create();
489 }, "creating lockfile for $package"); 487 }, "creating lockfile for $package");
490 } 488 }
491 489
492 /// Like [createLockFile], but creates only a `.packages` file without a 490 /// Like [createLockFile], but creates only a `.packages` file without a
493 /// lockfile. 491 /// lockfile.
494 void createPackagesFile(String package, {Iterable<String> sandbox, 492 void createPackagesFile(String package, {Iterable<String> sandbox,
495 Map<String, String> hosted}) { 493 Map<String, String> hosted}) {
496 schedule(() async { 494 schedule(() async {
497 var cache = new SystemCache.withSources( 495 var cache = new SystemCache(rootDir: p.join(sandboxDir, cachePath));
498 rootDir: p.join(sandboxDir, cachePath));
499
500 var lockFile = _createLockFile(cache.sources, 496 var lockFile = _createLockFile(cache.sources,
501 sandbox: sandbox, hosted: hosted); 497 sandbox: sandbox, hosted: hosted);
502 498
503 await d.dir(package, [ 499 await d.dir(package, [
504 d.file('.packages', lockFile.packagesFile(package)) 500 d.file('.packages', lockFile.packagesFile(cache, package))
505 ]).create(); 501 ]).create();
506 }, "creating .packages for $package"); 502 }, "creating .packages for $package");
507 } 503 }
508 504
509 /// Creates a lock file for [package] without running `pub get`. 505 /// Creates a lock file for [package] without running `pub get`.
510 /// 506 ///
511 /// [sandbox] is a list of path dependencies to be found in the sandbox 507 /// [sandbox] is a list of path dependencies to be found in the sandbox
512 /// directory. [pkg] is a list of packages in the Dart repo's "pkg" directory; 508 /// directory. [pkg] is a list of packages in the Dart repo's "pkg" directory;
513 /// each package listed here and all its dependencies will be linked to the 509 /// each package listed here and all its dependencies will be linked to the
514 /// version in the Dart repo. 510 /// version in the Dart repo.
(...skipping 203 matching lines...)
718 /// A function that creates a [Validator] subclass. 714 /// A function that creates a [Validator] subclass.
719 typedef Validator ValidatorCreator(Entrypoint entrypoint); 715 typedef Validator ValidatorCreator(Entrypoint entrypoint);
720 716
721 /// Schedules a single [Validator] to run on the [appPath]. 717 /// Schedules a single [Validator] to run on the [appPath].
722 /// 718 ///
723 /// Returns a scheduled Future that contains the errors and warnings produced 719 /// Returns a scheduled Future that contains the errors and warnings produced
724 /// by that validator. 720 /// by that validator.
725 Future<Pair<List<String>, List<String>>> schedulePackageValidation( 721 Future<Pair<List<String>, List<String>>> schedulePackageValidation(
726 ValidatorCreator fn) { 722 ValidatorCreator fn) {
727 return schedule(() { 723 return schedule(() {
728 var cache = new SystemCache.withSources( 724 var cache = new SystemCache(rootDir: p.join(sandboxDir, cachePath));
729 rootDir: p.join(sandboxDir, cachePath));
730
731 return new Future.sync(() { 725 return new Future.sync(() {
732 var validator = fn(new Entrypoint(p.join(sandboxDir, appPath), cache)); 726 var validator = fn(new Entrypoint(p.join(sandboxDir, appPath), cache));
733 return validator.validate().then((_) { 727 return validator.validate().then((_) {
734 return new Pair(validator.errors, validator.warnings); 728 return new Pair(validator.errors, validator.warnings);
735 }); 729 });
736 }); 730 });
737 }, "validating package"); 731 }, "validating package");
738 } 732 }
739 733
740 /// A matcher that matches a Pair. 734 /// A matcher that matches a Pair.
(...skipping 12 matching lines...)
753 _lastMatcher.matches(item.last, matchState); 747 _lastMatcher.matches(item.last, matchState);
754 } 748 }
755 749
756 Description describe(Description description) { 750 Description describe(Description description) {
757 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); 751 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]);
758 } 752 }
759 } 753 }
760 754
761 /// A [StreamMatcher] that matches multiple lines of output. 755 /// A [StreamMatcher] that matches multiple lines of output.
762 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); 756 StreamMatcher emitsLines(String output) => inOrder(output.split("\n"));
OLDNEW
« no previous file with comments | « test/pubspec_test.dart ('k') | test/version_solver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine