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 forBothPubGetAndUpgrade((command) { | |
15 integration("implicitly constrains it to versions pub supports", () { | |
16 servePackages((builder) { | |
17 builder.serve("barback", current("barback")); | |
18 builder.serve("stack_trace", previous("stack_trace")); | |
19 builder.serve("stack_trace", current("stack_trace")); | |
20 builder.serve("stack_trace", nextPatch("stack_trace")); | |
21 builder.serve("stack_trace", max("stack_trace")); | |
22 builder.serve("source_span", current("source_span")); | |
23 }); | |
24 | |
25 d.appDir({ | |
26 "barback": "any" | |
27 }).create(); | |
28 | |
29 pubCommand(command); | |
30 | |
31 d.packagesDir({ | |
32 "stack_trace": nextPatch("stack_trace") | |
33 }).validate(); | |
34 }); | |
35 | |
36 integration( | |
37 "pub's implicit constraint uses the same source and " | |
38 "description as a dependency override", | |
39 () { | |
40 servePackages((builder) { | |
41 builder.serve("barback", current("barback")); | |
42 builder.serve("stack_trace", nextPatch("stack_trace")); | |
43 builder.serve("source_span", current("source_span")); | |
44 }); | |
45 | |
46 d.dir( | |
47 "stack_trace", | |
48 [ | |
49 d.libDir("stack_trace", 'stack_trace ${current("stack_trace")}'), | |
50 d.libPubspec("stack_trace", current("stack_trace"))]).create(); | |
51 | |
52 d.dir(appPath, [d.pubspec({ | |
53 "name": "myapp", | |
54 "dependencies": { | |
55 "barback": "any" | |
56 }, | |
57 "dependency_overrides": { | |
58 "stack_trace": { | |
59 "path": "../stack_trace" | |
60 }, | |
61 } | |
62 })]).create(); | |
63 | |
64 pubCommand(command); | |
65 | |
66 // Validate that we're using the path dependency version of stack_trace | |
67 // rather than the hosted version. | |
68 d.packagesDir({ | |
69 "stack_trace": current("stack_trace") | |
70 }).validate(); | |
71 }); | |
72 | |
73 integration( | |
74 "doesn't add a constraint if barback isn't in the package " "graph", | |
75 () { | |
76 servePackages((builder) { | |
77 builder.serve("stack_trace", previous("stack_trace")); | |
78 builder.serve("stack_trace", current("stack_trace")); | |
79 builder.serve("stack_trace", nextPatch("stack_trace")); | |
80 builder.serve("stack_trace", max("stack_trace")); | |
81 builder.serve("source_span", current("source_span")); | |
82 }); | |
83 | |
84 d.appDir({ | |
85 "stack_trace": "any" | |
86 }).create(); | |
87 | |
88 pubCommand(command); | |
89 | |
90 d.packagesDir({ | |
91 "stack_trace": max("stack_trace") | |
92 }).validate(); | |
93 }); | |
94 }); | |
95 | |
96 integration( | |
97 "unlocks if the locked version doesn't meet pub's " "constraint", | |
98 () { | |
99 servePackages((builder) { | |
100 builder.serve("barback", current("barback")); | |
101 builder.serve("stack_trace", previous("stack_trace")); | |
102 builder.serve("stack_trace", current("stack_trace")); | |
103 builder.serve("source_span", current("source_span")); | |
104 }); | |
105 | |
106 d.appDir({ | |
107 "barback": "any" | |
108 }).create(); | |
109 | |
110 // Hand-create a lockfile to pin the package to an older version. | |
111 createLockFile("myapp", hosted: { | |
112 "barback": current("barback"), | |
113 "stack_trace": previous("stack_trace") | |
114 }); | |
115 | |
116 pubGet(); | |
117 | |
118 // It should be upgraded. | |
119 d.packagesDir({ | |
120 "stack_trace": current("stack_trace") | |
121 }).validate(); | |
122 }); | |
123 } | |
124 | |
125 String current(String packageName) => | |
126 barback.pubConstraints[packageName].min.toString(); | |
127 | |
128 String previous(String packageName) { | |
129 var constraint = barback.pubConstraints[packageName]; | |
130 return new Version( | |
131 constraint.min.major, | |
132 constraint.min.minor - 1, | |
133 0).toString(); | |
134 } | |
135 | |
136 String nextPatch(String packageName) => | |
137 barback.pubConstraints[packageName].min.nextPatch.toString(); | |
138 | |
139 String max(String packageName) => | |
140 barback.pubConstraints[packageName].max.toString(); | |
OLD | NEW |