Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: utils/tests/pub/version_solver_test.dart

Issue 14247026: Disable SDK constraint checking on bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add test. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « utils/tests/pub/command_line_config.dart ('k') | no next file » | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 library pub_update_test; 5 library pub_update_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 'foo 4.0.0': {'bar': '4.0.0'}, 604 'foo 4.0.0': {'bar': '4.0.0'},
605 'bar 1.0.0': {'sdk': goodVersion }, 605 'bar 1.0.0': {'sdk': goodVersion },
606 'bar 2.0.0': {'sdk': goodVersion }, 606 'bar 2.0.0': {'sdk': goodVersion },
607 'bar 3.0.0': {'sdk': badVersion }, 607 'bar 3.0.0': {'sdk': badVersion },
608 'bar 4.0.0': {'sdk': badVersion } 608 'bar 4.0.0': {'sdk': badVersion }
609 }, result: { 609 }, result: {
610 'myapp from root': '0.0.0', 610 'myapp from root': '0.0.0',
611 'foo': '2.0.0', 611 'foo': '2.0.0',
612 'bar': '2.0.0' 612 'bar': '2.0.0'
613 }, maxTries: 3); 613 }, maxTries: 3);
614
615 testResolve('ignores SDK constraints on bleeding edge', {
616 'myapp 0.0.0': {'sdk': badVersion }
617 }, result: {
618 'myapp from root': '0.0.0'
619 }, useBleedingEdgeSdkVersion: true);
614 } 620 }
615 621
616 testResolve(description, packages, 622 testResolve(description, packages,
617 {lockfile, result, FailMatcherBuilder error, int maxTries}) { 623 {lockfile, result, FailMatcherBuilder error, int maxTries,
624 bool useBleedingEdgeSdkVersion}) {
618 if (maxTries == null) maxTries = 1; 625 if (maxTries == null) maxTries = 1;
626 if (useBleedingEdgeSdkVersion == null) useBleedingEdgeSdkVersion = false;
619 627
620 test(description, () { 628 test(description, () {
621 var cache = new SystemCache('.'); 629 var cache = new SystemCache('.');
622 source1 = new MockSource('mock1'); 630 source1 = new MockSource('mock1');
623 source2 = new MockSource('mock2'); 631 source2 = new MockSource('mock2');
624 cache.register(source1); 632 cache.register(source1);
625 cache.register(source2); 633 cache.register(source2);
626 cache.sources.setDefault(source1.name); 634 cache.sources.setDefault(source1.name);
627 635
628 // Build the test package graph. 636 // Build the test package graph.
(...skipping 30 matching lines...) Expand all
659 667
660 var realLockFile = new LockFile.empty(); 668 var realLockFile = new LockFile.empty();
661 if (lockfile != null) { 669 if (lockfile != null) {
662 lockfile.forEach((name, version) { 670 lockfile.forEach((name, version) {
663 version = new Version.parse(version); 671 version = new Version.parse(version);
664 realLockFile.packages[name] = 672 realLockFile.packages[name] =
665 new PackageId(name, source1, version, name); 673 new PackageId(name, source1, version, name);
666 }); 674 });
667 } 675 }
668 676
677 // Make a version number like the continuous build's version.
678 var previousVersion = sdk.version;
679 if (useBleedingEdgeSdkVersion) {
680 sdk.version = new Version(0, 1, 2, build: '0_r12345_juser');
681 }
682
669 // Resolve the versions. 683 // Resolve the versions.
670 var future = resolveVersions(cache.sources, root, 684 var future = resolveVersions(cache.sources, root,
671 lockFile: realLockFile); 685 lockFile: realLockFile);
672 686
673 var matcher; 687 var matcher;
674 if (result != null) { 688 if (result != null) {
675 matcher = new SolveSuccessMatcher(result, maxTries); 689 matcher = new SolveSuccessMatcher(result, maxTries);
676 } else if (error != null) { 690 } else if (error != null) {
677 matcher = error(maxTries); 691 matcher = error(maxTries);
678 } 692 }
679 693
694 future = future.whenComplete(() {
695 if (useBleedingEdgeSdkVersion) {
696 sdk.version = previousVersion;
697 }
698 });
nweiz 2013/04/19 18:42:07 I would find it a little cleaner if you did this w
Bob Nystrom 2013/04/19 21:13:04 I tried that, but it looked weird to me jammed in
699
680 expect(future, completion(matcher)); 700 expect(future, completion(matcher));
681 }); 701 });
682 } 702 }
683 703
684 typedef SolveFailMatcher FailMatcherBuilder(int maxTries); 704 typedef SolveFailMatcher FailMatcherBuilder(int maxTries);
685 705
686 FailMatcherBuilder noVersion(List<String> packages) { 706 FailMatcherBuilder noVersion(List<String> packages) {
687 return (maxTries) => new SolveFailMatcher(packages, maxTries, 707 return (maxTries) => new SolveFailMatcher(packages, maxTries,
688 NoVersionException); 708 NoVersionException);
689 } 709 }
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 }; 985 };
966 986
967 var match = new RegExp(r"(.*) from (.*)").firstMatch(description); 987 var match = new RegExp(r"(.*) from (.*)").firstMatch(description);
968 if (match != null) { 988 if (match != null) {
969 name = match[1]; 989 name = match[1];
970 source = sourceNames[match[2]]; 990 source = sourceNames[match[2]];
971 } 991 }
972 992
973 callback(isDev, name, source); 993 callback(isDev, name, source);
974 } 994 }
OLDNEW
« no previous file with comments | « utils/tests/pub/command_line_config.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698