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 22 matching lines...) Expand all Loading... |
33 sdk.version = new Version(1, 2, 3); | 33 sdk.version = new Version(1, 2, 3); |
34 | 34 |
35 group('basic graph', basicGraph); | 35 group('basic graph', basicGraph); |
36 group('with lockfile', withLockFile); | 36 group('with lockfile', withLockFile); |
37 group('root dependency', rootDependency); | 37 group('root dependency', rootDependency); |
38 group('dev dependency', devDependency); | 38 group('dev dependency', devDependency); |
39 group('unsolvable', unsolvable); | 39 group('unsolvable', unsolvable); |
40 group('bad source', badSource); | 40 group('bad source', badSource); |
41 group('backtracking', backtracking); | 41 group('backtracking', backtracking); |
42 group('SDK constraint', sdkConstraint); | 42 group('SDK constraint', sdkConstraint); |
| 43 group('pre-release', prerelease); |
43 } | 44 } |
44 | 45 |
45 void basicGraph() { | 46 void basicGraph() { |
46 testResolve('no dependencies', { | 47 testResolve('no dependencies', { |
47 'myapp 0.0.0': {} | 48 'myapp 0.0.0': {} |
48 }, result: { | 49 }, result: { |
49 'myapp from root': '0.0.0' | 50 'myapp from root': '0.0.0' |
50 }); | 51 }); |
51 | 52 |
52 testResolve('simple dependency tree', { | 53 testResolve('simple dependency tree', { |
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 'bar': '2.0.0' | 794 'bar': '2.0.0' |
794 }, maxTries: 3); | 795 }, maxTries: 3); |
795 | 796 |
796 testResolve('ignores SDK constraints on bleeding edge', { | 797 testResolve('ignores SDK constraints on bleeding edge', { |
797 'myapp 0.0.0': {'sdk': badVersion } | 798 'myapp 0.0.0': {'sdk': badVersion } |
798 }, result: { | 799 }, result: { |
799 'myapp from root': '0.0.0' | 800 'myapp from root': '0.0.0' |
800 }, useBleedingEdgeSdkVersion: true); | 801 }, useBleedingEdgeSdkVersion: true); |
801 } | 802 } |
802 | 803 |
| 804 void prerelease() { |
| 805 testResolve('prefer stable versions over unstable', { |
| 806 'myapp 0.0.0': { |
| 807 'a': 'any' |
| 808 }, |
| 809 'a 1.0.0': {}, |
| 810 'a 1.1.0-dev': {}, |
| 811 'a 2.0.0-dev': {}, |
| 812 'a 3.0.0-dev': {} |
| 813 }, result: { |
| 814 'myapp from root': '0.0.0', |
| 815 'a': '1.0.0' |
| 816 }); |
| 817 |
| 818 testResolve('use latest allowed prerelease if no stable versions match', { |
| 819 'myapp 0.0.0': { |
| 820 'a': '<2.0.0' |
| 821 }, |
| 822 'a 1.0.0-dev': {}, |
| 823 'a 1.1.0-dev': {}, |
| 824 'a 2.0.0-dev': {}, |
| 825 'a 3.0.0': {} |
| 826 }, result: { |
| 827 'myapp from root': '0.0.0', |
| 828 'a': '2.0.0-dev' |
| 829 }); |
| 830 |
| 831 testResolve('use an earlier stable version on a < constraint', { |
| 832 'myapp 0.0.0': { |
| 833 'a': '<2.0.0' |
| 834 }, |
| 835 'a 1.0.0': {}, |
| 836 'a 1.1.0': {}, |
| 837 'a 2.0.0-dev': {}, |
| 838 'a 2.0.0': {} |
| 839 }, result: { |
| 840 'myapp from root': '0.0.0', |
| 841 'a': '1.1.0' |
| 842 }); |
| 843 |
| 844 testResolve('prefer a stable version even if constraint mentions unstable', { |
| 845 'myapp 0.0.0': { |
| 846 'a': '<=2.0.0-dev' |
| 847 }, |
| 848 'a 1.0.0': {}, |
| 849 'a 1.1.0': {}, |
| 850 'a 2.0.0-dev': {}, |
| 851 'a 2.0.0': {} |
| 852 }, result: { |
| 853 'myapp from root': '0.0.0', |
| 854 'a': '1.1.0' |
| 855 }); |
| 856 } |
| 857 |
803 testResolve(description, packages, { | 858 testResolve(description, packages, { |
804 lockfile, result, FailMatcherBuilder error, int maxTries, | 859 lockfile, result, FailMatcherBuilder error, int maxTries, |
805 bool useBleedingEdgeSdkVersion}) { | 860 bool useBleedingEdgeSdkVersion}) { |
806 _testResolve(test, description, packages, lockfile: lockfile, result: result, | 861 _testResolve(test, description, packages, lockfile: lockfile, result: result, |
807 error: error, maxTries: maxTries, | 862 error: error, maxTries: maxTries, |
808 useBleedingEdgeSdkVersion: useBleedingEdgeSdkVersion); | 863 useBleedingEdgeSdkVersion: useBleedingEdgeSdkVersion); |
809 } | 864 } |
810 | 865 |
811 solo_testResolve(description, packages, { | 866 solo_testResolve(description, packages, { |
812 lockfile, result, FailMatcherBuilder error, int maxTries, | 867 lockfile, result, FailMatcherBuilder error, int maxTries, |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 var source = "mock1"; | 1243 var source = "mock1"; |
1189 var match = new RegExp(r"(.*) from (.*)").firstMatch(description); | 1244 var match = new RegExp(r"(.*) from (.*)").firstMatch(description); |
1190 if (match != null) { | 1245 if (match != null) { |
1191 name = match[1]; | 1246 name = match[1]; |
1192 source = match[2]; | 1247 source = match[2]; |
1193 if (source == "root") source = null; | 1248 if (source == "root") source = null; |
1194 } | 1249 } |
1195 | 1250 |
1196 callback(isDev, name, source); | 1251 callback(isDev, name, source); |
1197 } | 1252 } |
OLD | NEW |