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