OLD | NEW |
| (Empty) |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
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. | |
4 | |
5 import 'package:pub_semver/pub_semver.dart'; | |
6 | |
7 import 'descriptor.dart' as d; | |
8 import 'test_pub.dart'; | |
9 import '../lib/src/barback.dart' as barback; | |
10 | |
11 main() { | |
12 initConfig(); | |
13 | |
14 var constraint = barback.pubConstraints["barback"]; | |
15 var current = constraint.min.toString(); | |
16 var previous = | |
17 new Version(constraint.min.major, constraint.min.minor - 1, 0).toString(); | |
18 var nextPatch = constraint.min.nextPatch.toString(); | |
19 var max = constraint.max.toString(); | |
20 | |
21 var sourceSpanVersion = barback.pubConstraints["source_span"].min.toString(); | |
22 var stackTraceVersion = barback.pubConstraints["stack_trace"].min.toString(); | |
23 | |
24 forBothPubGetAndUpgrade((command) { | |
25 integration("implicitly constrains barback to versions pub supports", () { | |
26 servePackages((builder) { | |
27 builder.serve("barback", previous); | |
28 builder.serve("barback", current); | |
29 builder.serve("barback", nextPatch); | |
30 builder.serve("barback", max); | |
31 builder.serve("source_span", sourceSpanVersion); | |
32 builder.serve("stack_trace", stackTraceVersion); | |
33 }); | |
34 | |
35 d.appDir({ | |
36 "barback": "any" | |
37 }).create(); | |
38 | |
39 pubCommand(command); | |
40 | |
41 d.packagesDir({ | |
42 "barback": nextPatch | |
43 }).validate(); | |
44 }); | |
45 | |
46 integration("discovers transitive dependency on barback", () { | |
47 servePackages((builder) { | |
48 builder.serve("barback", previous); | |
49 builder.serve("barback", current); | |
50 builder.serve("barback", nextPatch); | |
51 builder.serve("barback", max); | |
52 builder.serve("source_span", sourceSpanVersion); | |
53 builder.serve("stack_trace", stackTraceVersion); | |
54 }); | |
55 | |
56 d.dir( | |
57 "foo", | |
58 [d.libDir("foo", "foo 0.0.1"), d.libPubspec("foo", "0.0.1", deps: { | |
59 "barback": "any" | |
60 })]).create(); | |
61 | |
62 d.appDir({ | |
63 "foo": { | |
64 "path": "../foo" | |
65 } | |
66 }).create(); | |
67 | |
68 pubCommand(command); | |
69 | |
70 d.packagesDir({ | |
71 "barback": nextPatch, | |
72 "foo": "0.0.1" | |
73 }).validate(); | |
74 }); | |
75 | |
76 integration( | |
77 "pub's implicit constraint uses the same source and " | |
78 "description as a dependency override", | |
79 () { | |
80 servePackages((builder) { | |
81 builder.serve("source_span", sourceSpanVersion); | |
82 builder.serve("stack_trace", stackTraceVersion); | |
83 }); | |
84 | |
85 d.dir( | |
86 'barback', | |
87 [ | |
88 d.libDir('barback', 'barback $current'), | |
89 d.libPubspec('barback', current),]).create(); | |
90 | |
91 d.dir(appPath, [d.pubspec({ | |
92 "name": "myapp", | |
93 "dependency_overrides": { | |
94 "barback": { | |
95 "path": "../barback" | |
96 } | |
97 } | |
98 })]).create(); | |
99 | |
100 pubCommand(command); | |
101 | |
102 d.packagesDir({ | |
103 "barback": current | |
104 }).validate(); | |
105 }); | |
106 }); | |
107 | |
108 integration("unlock if the locked version doesn't meet pub's constraint", () { | |
109 servePackages((builder) { | |
110 builder.serve("barback", previous); | |
111 builder.serve("barback", current); | |
112 builder.serve("source_span", sourceSpanVersion); | |
113 builder.serve("stack_trace", stackTraceVersion); | |
114 }); | |
115 | |
116 d.appDir({ | |
117 "barback": "any" | |
118 }).create(); | |
119 | |
120 // Hand-create a lockfile to pin barback to an older version. | |
121 createLockFile("myapp", hosted: { | |
122 "barback": previous | |
123 }); | |
124 | |
125 pubGet(); | |
126 | |
127 // It should be upgraded. | |
128 d.packagesDir({ | |
129 "barback": current | |
130 }).validate(); | |
131 }); | |
132 | |
133 integration( | |
134 "includes pub in the error if a solve failed because there " | |
135 "is no version available", | |
136 () { | |
137 servePackages((builder) { | |
138 builder.serve("barback", previous); | |
139 builder.serve("source_span", sourceSpanVersion); | |
140 builder.serve("stack_trace", stackTraceVersion); | |
141 }); | |
142 | |
143 d.appDir({ | |
144 "barback": "any" | |
145 }).create(); | |
146 | |
147 pubGet(error: """ | |
148 Package barback 0.12.0 does not match >=$current <$max derived from: | |
149 - myapp 0.0.0 depends on version any | |
150 - pub itself depends on version >=$current <$max"""); | |
151 }); | |
152 | |
153 integration( | |
154 "includes pub in the error if a solve failed because there " | |
155 "is a disjoint constraint", | |
156 () { | |
157 servePackages((builder) { | |
158 builder.serve("barback", previous); | |
159 builder.serve("barback", current); | |
160 builder.serve("source_span", sourceSpanVersion); | |
161 builder.serve("stack_trace", stackTraceVersion); | |
162 }); | |
163 | |
164 d.appDir({ | |
165 "barback": previous | |
166 }).create(); | |
167 | |
168 pubGet(error: """ | |
169 Incompatible version constraints on barback: | |
170 - myapp 0.0.0 depends on version $previous | |
171 - pub itself depends on version >=$current <$max"""); | |
172 }); | |
173 } | |
OLD | NEW |