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