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