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

Side by Side Diff: sdk/lib/_internal/pub/test/version_solver_test.dart

Issue 365993007: Support "pub downgrade". (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 5 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
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_upgrade_test; 5 library pub_upgrade_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 10
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 'myapp 0.0.0': { 916 'myapp 0.0.0': {
917 'a': '<=2.0.0-dev' 917 'a': '<=2.0.0-dev'
918 }, 918 },
919 'a 1.0.0': {}, 919 'a 1.0.0': {},
920 'a 1.1.0': {}, 920 'a 1.1.0': {},
921 'a 2.0.0-dev': {}, 921 'a 2.0.0-dev': {},
922 'a 2.0.0': {} 922 'a 2.0.0': {}
923 }, result: { 923 }, result: {
924 'myapp from root': '0.0.0', 924 'myapp from root': '0.0.0',
925 'a': '1.1.0' 925 'a': '1.1.0'
926 }); 926 });
Bob Nystrom 2014/07/09 18:19:00 It would be nice to have unit tests for the other
nweiz 2014/07/09 21:28:58 I thought this code was mostly for testing behavio
Bob Nystrom 2014/07/10 17:46:11 It tries to test all of the solving behavior that
nweiz 2014/07/14 21:52:05 I moved over downgrades_dependency, but the other
927
928 testResolve('use earliest allowed prerelease if no stable versions match '
929 'while downgrading', {
930 'myapp 0.0.0': {
931 'a': '>=2.0.0-dev.1 <3.0.0'
932 },
933 'a 1.0.0': {},
934 'a 2.0.0-dev.1': {},
935 'a 2.0.0-dev.2': {},
936 'a 2.0.0-dev.3': {}
937 }, result: {
938 'myapp from root': '0.0.0',
939 'a': '2.0.0-dev.1'
940 }, downgrade: true);
927 } 941 }
928 942
929 void override() { 943 void override() {
930 testResolve('chooses best version matching override constraint', { 944 testResolve('chooses best version matching override constraint', {
931 'myapp 0.0.0': { 945 'myapp 0.0.0': {
932 'a': 'any' 946 'a': 'any'
933 }, 947 },
934 'a 1.0.0': {}, 948 'a 1.0.0': {},
935 'a 2.0.0': {}, 949 'a 2.0.0': {},
936 'a 3.0.0': {} 950 'a 3.0.0': {}
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 }, overrides: { 1066 }, overrides: {
1053 'foo': 'any' 1067 'foo': 'any'
1054 }, result: { 1068 }, result: {
1055 'myapp from root': '0.0.0', 1069 'myapp from root': '0.0.0',
1056 'foo': '0.0.0' 1070 'foo': '0.0.0'
1057 }); 1071 });
1058 } 1072 }
1059 1073
1060 testResolve(String description, Map packages, { 1074 testResolve(String description, Map packages, {
1061 Map lockfile, Map overrides, Map result, FailMatcherBuilder error, 1075 Map lockfile, Map overrides, Map result, FailMatcherBuilder error,
1062 int maxTries}) { 1076 int maxTries, bool downgrade: false}) {
1063 _testResolve(test, description, packages, lockfile: lockfile, 1077 _testResolve(test, description, packages, lockfile: lockfile,
1064 overrides: overrides, result: result, error: error, maxTries: maxTries); 1078 overrides: overrides, result: result, error: error, maxTries: maxTries,
1079 downgrade: downgrade);
1065 } 1080 }
1066 1081
1067 solo_testResolve(String description, Map packages, { 1082 solo_testResolve(String description, Map packages, {
1068 Map lockfile, Map overrides, Map result, FailMatcherBuilder error, 1083 Map lockfile, Map overrides, Map result, FailMatcherBuilder error,
1069 int maxTries}) { 1084 int maxTries, bool downgrade: false}) {
1070 log.verbosity = log.Verbosity.SOLVER; 1085 log.verbosity = log.Verbosity.SOLVER;
1071 _testResolve(solo_test, description, packages, lockfile: lockfile, 1086 _testResolve(solo_test, description, packages, lockfile: lockfile,
1072 overrides: overrides, result: result, error: error, maxTries: maxTries); 1087 overrides: overrides, result: result, error: error, maxTries: maxTries,
1088 downgrade: downgrade);
1073 } 1089 }
1074 1090
1075 _testResolve(void testFn(String description, Function body), 1091 _testResolve(void testFn(String description, Function body),
1076 String description, Map packages, { 1092 String description, Map packages, {
1077 Map lockfile, Map overrides, Map result, FailMatcherBuilder error, 1093 Map lockfile, Map overrides, Map result, FailMatcherBuilder error,
1078 int maxTries}) { 1094 int maxTries, bool downgrade: false}) {
1079 if (maxTries == null) maxTries = 1; 1095 if (maxTries == null) maxTries = 1;
1080 1096
1081 testFn(description, () { 1097 testFn(description, () {
1082 var cache = new SystemCache('.'); 1098 var cache = new SystemCache('.');
1083 source1 = new MockSource('mock1'); 1099 source1 = new MockSource('mock1');
1084 source2 = new MockSource('mock2'); 1100 source2 = new MockSource('mock2');
1085 cache.register(source1); 1101 cache.register(source1);
1086 cache.register(source2); 1102 cache.register(source2);
1087 cache.sources.setDefault(source1.name); 1103 cache.sources.setDefault(source1.name);
1088 1104
(...skipping 28 matching lines...) Expand all
1117 var realLockFile = new LockFile.empty(); 1133 var realLockFile = new LockFile.empty();
1118 if (lockfile != null) { 1134 if (lockfile != null) {
1119 lockfile.forEach((name, version) { 1135 lockfile.forEach((name, version) {
1120 version = new Version.parse(version); 1136 version = new Version.parse(version);
1121 realLockFile.packages[name] = 1137 realLockFile.packages[name] =
1122 new PackageId(name, source1.name, version, name); 1138 new PackageId(name, source1.name, version, name);
1123 }); 1139 });
1124 } 1140 }
1125 1141
1126 // Resolve the versions. 1142 // Resolve the versions.
1127 var future = resolveVersions(cache.sources, root, lockFile: realLockFile); 1143 var future = resolveVersions(
1144 downgrade ? SolveType.DOWNGRADE : SolveType.GET,
1145 cache.sources, root, lockFile: realLockFile);
1128 1146
1129 var matcher; 1147 var matcher;
1130 if (result != null) { 1148 if (result != null) {
1131 matcher = new SolveSuccessMatcher(result, maxTries); 1149 matcher = new SolveSuccessMatcher(result, maxTries);
1132 } else if (error != null) { 1150 } else if (error != null) {
1133 matcher = error(maxTries); 1151 matcher = error(maxTries);
1134 } 1152 }
1135 1153
1136 expect(future, completion(matcher)); 1154 expect(future, completion(matcher));
1137 }); 1155 });
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 } 1491 }
1474 1492
1475 var source = "mock1"; 1493 var source = "mock1";
1476 if (match[7] != null) { 1494 if (match[7] != null) {
1477 source = match[7]; 1495 source = match[7];
1478 if (source == "root") source = null; 1496 if (source == "root") source = null;
1479 } 1497 }
1480 1498
1481 return new PackageId(name, source, parsedVersion, description); 1499 return new PackageId(name, source, parsedVersion, description);
1482 } 1500 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698