OLD | NEW |
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 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 'foo 4.0.0': {'bar': '4.0.0'}, | 787 'foo 4.0.0': {'bar': '4.0.0'}, |
788 'bar 1.0.0': {'sdk': goodVersion }, | 788 'bar 1.0.0': {'sdk': goodVersion }, |
789 'bar 2.0.0': {'sdk': goodVersion }, | 789 'bar 2.0.0': {'sdk': goodVersion }, |
790 'bar 3.0.0': {'sdk': badVersion }, | 790 'bar 3.0.0': {'sdk': badVersion }, |
791 'bar 4.0.0': {'sdk': badVersion } | 791 'bar 4.0.0': {'sdk': badVersion } |
792 }, result: { | 792 }, result: { |
793 'myapp from root': '0.0.0', | 793 'myapp from root': '0.0.0', |
794 'foo': '2.0.0', | 794 'foo': '2.0.0', |
795 'bar': '2.0.0' | 795 'bar': '2.0.0' |
796 }, maxTries: 3); | 796 }, maxTries: 3); |
| 797 |
| 798 testResolve('ignores SDK constraints on bleeding edge', { |
| 799 'myapp 0.0.0': {'sdk': badVersion } |
| 800 }, result: { |
| 801 'myapp from root': '0.0.0' |
| 802 }, useBleedingEdgeSdkVersion: true); |
797 } | 803 } |
798 | 804 |
799 void prerelease() { | 805 void prerelease() { |
800 testResolve('prefer stable versions over unstable', { | 806 testResolve('prefer stable versions over unstable', { |
801 'myapp 0.0.0': { | 807 'myapp 0.0.0': { |
802 'a': 'any' | 808 'a': 'any' |
803 }, | 809 }, |
804 'a 1.0.0': {}, | 810 'a 1.0.0': {}, |
805 'a 1.1.0-dev': {}, | 811 'a 1.1.0-dev': {}, |
806 'a 2.0.0-dev': {}, | 812 'a 2.0.0-dev': {}, |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 }, overrides: { | 982 }, overrides: { |
977 'foo': 'any' | 983 'foo': 'any' |
978 }, result: { | 984 }, result: { |
979 'myapp from root': '0.0.0', | 985 'myapp from root': '0.0.0', |
980 'foo': '0.0.0' | 986 'foo': '0.0.0' |
981 }); | 987 }); |
982 } | 988 } |
983 | 989 |
984 testResolve(String description, Map packages, { | 990 testResolve(String description, Map packages, { |
985 Map lockfile, Map overrides, Map result, FailMatcherBuilder error, | 991 Map lockfile, Map overrides, Map result, FailMatcherBuilder error, |
986 int maxTries}) { | 992 int maxTries, bool useBleedingEdgeSdkVersion}) { |
987 _testResolve(test, description, packages, lockfile: lockfile, | 993 _testResolve(test, description, packages, lockfile: lockfile, |
988 overrides: overrides, result: result, error: error, maxTries: maxTries); | 994 overrides: overrides, result: result, error: error, maxTries: maxTries, |
| 995 useBleedingEdgeSdkVersion: useBleedingEdgeSdkVersion); |
989 } | 996 } |
990 | 997 |
991 solo_testResolve(String description, Map packages, { | 998 solo_testResolve(String description, Map packages, { |
992 Map lockfile, Map overrides, Map result, FailMatcherBuilder error, | 999 Map lockfile, Map overrides, Map result, FailMatcherBuilder error, |
993 int maxTries}) { | 1000 int maxTries, bool useBleedingEdgeSdkVersion}) { |
994 log.showSolver(); | 1001 log.showSolver(); |
995 _testResolve(solo_test, description, packages, lockfile: lockfile, | 1002 _testResolve(solo_test, description, packages, lockfile: lockfile, |
996 overrides: overrides, result: result, error: error, maxTries: maxTries); | 1003 overrides: overrides, result: result, error: error, maxTries: maxTries, |
| 1004 useBleedingEdgeSdkVersion: useBleedingEdgeSdkVersion); |
997 } | 1005 } |
998 | 1006 |
999 _testResolve(void testFn(String description, Function body), | 1007 _testResolve(void testFn(String description, Function body), |
1000 String description, Map packages, { | 1008 String description, Map packages, { |
1001 Map lockfile, Map overrides, Map result, FailMatcherBuilder error, | 1009 Map lockfile, Map overrides, Map result, FailMatcherBuilder error, |
1002 int maxTries}) { | 1010 int maxTries, bool useBleedingEdgeSdkVersion}) { |
1003 if (maxTries == null) maxTries = 1; | 1011 if (maxTries == null) maxTries = 1; |
| 1012 if (useBleedingEdgeSdkVersion == null) useBleedingEdgeSdkVersion = false; |
1004 | 1013 |
1005 testFn(description, () { | 1014 testFn(description, () { |
1006 var cache = new SystemCache('.'); | 1015 var cache = new SystemCache('.'); |
1007 source1 = new MockSource('mock1'); | 1016 source1 = new MockSource('mock1'); |
1008 source2 = new MockSource('mock2'); | 1017 source2 = new MockSource('mock2'); |
1009 cache.register(source1); | 1018 cache.register(source1); |
1010 cache.register(source2); | 1019 cache.register(source2); |
1011 cache.sources.setDefault(source1.name); | 1020 cache.sources.setDefault(source1.name); |
1012 | 1021 |
1013 // Build the test package graph. | 1022 // Build the test package graph. |
(...skipping 26 matching lines...) Expand all Loading... |
1040 // Parse the lockfile. | 1049 // Parse the lockfile. |
1041 var realLockFile = new LockFile.empty(); | 1050 var realLockFile = new LockFile.empty(); |
1042 if (lockfile != null) { | 1051 if (lockfile != null) { |
1043 lockfile.forEach((name, version) { | 1052 lockfile.forEach((name, version) { |
1044 version = new Version.parse(version); | 1053 version = new Version.parse(version); |
1045 realLockFile.packages[name] = | 1054 realLockFile.packages[name] = |
1046 new PackageId(name, source1.name, version, name); | 1055 new PackageId(name, source1.name, version, name); |
1047 }); | 1056 }); |
1048 } | 1057 } |
1049 | 1058 |
| 1059 // Make a version number like the continuous build's version. |
| 1060 var previousVersion = sdk.version; |
| 1061 if (useBleedingEdgeSdkVersion) { |
| 1062 sdk.version = new Version(0, 1, 2, build: '0_r12345_juser'); |
| 1063 } |
| 1064 |
1050 // Resolve the versions. | 1065 // Resolve the versions. |
1051 var future = resolveVersions(cache.sources, root, lockFile: realLockFile); | 1066 var future = resolveVersions(cache.sources, root, lockFile: realLockFile); |
1052 | 1067 |
1053 var matcher; | 1068 var matcher; |
1054 if (result != null) { | 1069 if (result != null) { |
1055 matcher = new SolveSuccessMatcher(result, maxTries); | 1070 matcher = new SolveSuccessMatcher(result, maxTries); |
1056 } else if (error != null) { | 1071 } else if (error != null) { |
1057 matcher = error(maxTries); | 1072 matcher = error(maxTries); |
1058 } | 1073 } |
1059 | 1074 |
| 1075 future = future.whenComplete(() { |
| 1076 if (useBleedingEdgeSdkVersion) { |
| 1077 sdk.version = previousVersion; |
| 1078 } |
| 1079 }); |
| 1080 |
1060 expect(future, completion(matcher)); | 1081 expect(future, completion(matcher)); |
1061 }); | 1082 }); |
1062 } | 1083 } |
1063 | 1084 |
1064 typedef SolveFailMatcher FailMatcherBuilder(int maxTries); | 1085 typedef SolveFailMatcher FailMatcherBuilder(int maxTries); |
1065 | 1086 |
1066 FailMatcherBuilder noVersion(List<String> packages) { | 1087 FailMatcherBuilder noVersion(List<String> packages) { |
1067 return (maxTries) => new SolveFailMatcher(packages, maxTries, | 1088 return (maxTries) => new SolveFailMatcher(packages, maxTries, |
1068 NoVersionException); | 1089 NoVersionException); |
1069 } | 1090 } |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1385 } | 1406 } |
1386 | 1407 |
1387 var source = "mock1"; | 1408 var source = "mock1"; |
1388 if (match[7] != null) { | 1409 if (match[7] != null) { |
1389 source = match[7]; | 1410 source = match[7]; |
1390 if (source == "root") source = null; | 1411 if (source == "root") source = null; |
1391 } | 1412 } |
1392 | 1413 |
1393 return new PackageId(name, source, parsedVersion, description); | 1414 return new PackageId(name, source, parsedVersion, description); |
1394 } | 1415 } |
OLD | NEW |