OLD | NEW |
| 1 // Copyright (c) 2014, 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 library pub_tests; | 5 library pub_tests; |
| 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 'utils.dart'; | 9 import 'utils.dart'; |
| 10 |
5 void main() { | 11 void main() { |
6 initConfig(); | 12 initConfig(); |
| 13 |
7 integration( | 14 integration( |
8 "allows a package dependency cycle that's unrelated to " "transformers", | 15 "allows a package dependency cycle that's unrelated to " "transformers", |
9 () { | 16 () { |
10 d.dir(appPath, [d.pubspec({ | 17 d.dir(appPath, [d.pubspec({ |
11 "name": "myapp", | 18 "name": "myapp", |
12 "dependencies": { | 19 "dependencies": { |
13 "foo": { | 20 "foo": { |
14 "path": "../foo" | 21 "path": "../foo" |
15 } | 22 } |
16 }, | 23 }, |
17 "transformers": ["myapp/first", "myapp/second"] | 24 "transformers": ["myapp/first", "myapp/second"] |
18 }), | 25 }), |
19 d.dir( | 26 d.dir( |
20 'lib', | 27 'lib', |
21 [ | 28 [ |
22 d.file("first.dart", transformer()), | 29 d.file("first.dart", transformer()), |
23 d.file("second.dart", transformer())])]).create(); | 30 d.file("second.dart", transformer())])]).create(); |
| 31 |
24 d.dir("foo", [d.libPubspec("foo", "1.0.0", deps: { | 32 d.dir("foo", [d.libPubspec("foo", "1.0.0", deps: { |
25 "bar": { | 33 "bar": { |
26 "path": "../bar" | 34 "path": "../bar" |
27 } | 35 } |
28 })]).create(); | 36 })]).create(); |
| 37 |
29 d.dir("bar", [d.libPubspec("bar", "1.0.0", deps: { | 38 d.dir("bar", [d.libPubspec("bar", "1.0.0", deps: { |
30 "baz": { | 39 "baz": { |
31 "path": "../baz" | 40 "path": "../baz" |
32 } | 41 } |
33 })]).create(); | 42 })]).create(); |
| 43 |
34 d.dir("baz", [d.libPubspec("baz", "1.0.0", deps: { | 44 d.dir("baz", [d.libPubspec("baz", "1.0.0", deps: { |
35 "foo": { | 45 "foo": { |
36 "path": "../foo" | 46 "path": "../foo" |
37 } | 47 } |
38 })]).create(); | 48 })]).create(); |
| 49 |
39 expectDependencies({ | 50 expectDependencies({ |
40 'myapp/first': [], | 51 'myapp/first': [], |
41 'myapp/second': ['myapp/first'] | 52 'myapp/second': ['myapp/first'] |
42 }); | 53 }); |
43 }); | 54 }); |
| 55 |
44 integration( | 56 integration( |
45 "disallows a package dependency cycle that may be related to " "transforme
rs", | 57 "disallows a package dependency cycle that may be related to " "transforme
rs", |
46 () { | 58 () { |
| 59 // Two layers of myapp transformers are necessary here because otherwise pub |
| 60 // will figure out that the transformer doesn't import "foo" and thus |
| 61 // doesn't transitively import itself. Import loops are tested below. |
47 d.dir(appPath, [d.pubspec({ | 62 d.dir(appPath, [d.pubspec({ |
48 "name": "myapp", | 63 "name": "myapp", |
49 "dependencies": { | 64 "dependencies": { |
50 "foo": { | 65 "foo": { |
51 "path": "../foo" | 66 "path": "../foo" |
52 } | 67 } |
53 }, | 68 }, |
54 "transformers": ["myapp/first", "myapp/second"] | 69 "transformers": ["myapp/first", "myapp/second"] |
55 }), | 70 }), |
56 d.dir( | 71 d.dir( |
57 'lib', | 72 'lib', |
58 [ | 73 [ |
59 d.file("first.dart", transformer()), | 74 d.file("first.dart", transformer()), |
60 d.file("second.dart", transformer())])]).create(); | 75 d.file("second.dart", transformer())])]).create(); |
| 76 |
61 d.dir("foo", [d.libPubspec("foo", "1.0.0", deps: { | 77 d.dir("foo", [d.libPubspec("foo", "1.0.0", deps: { |
62 "bar": { | 78 "bar": { |
63 "path": "../bar" | 79 "path": "../bar" |
64 } | 80 } |
65 })]).create(); | 81 })]).create(); |
| 82 |
66 d.dir("bar", [d.libPubspec("bar", "1.0.0", deps: { | 83 d.dir("bar", [d.libPubspec("bar", "1.0.0", deps: { |
67 "myapp": { | 84 "myapp": { |
68 "path": "../myapp" | 85 "path": "../myapp" |
69 } | 86 } |
70 })]).create(); | 87 })]).create(); |
| 88 |
71 expectCycleException( | 89 expectCycleException( |
72 [ | 90 [ |
73 "myapp is transformed by myapp/second", | 91 "myapp is transformed by myapp/second", |
74 "myapp depends on foo", | 92 "myapp depends on foo", |
75 "foo depends on bar", | 93 "foo depends on bar", |
76 "bar depends on myapp", | 94 "bar depends on myapp", |
77 "myapp is transformed by myapp/first"]); | 95 "myapp is transformed by myapp/first"]); |
78 }); | 96 }); |
| 97 |
79 integration("disallows a transformation dependency cycle", () { | 98 integration("disallows a transformation dependency cycle", () { |
80 d.dir(appPath, [d.pubspec({ | 99 d.dir(appPath, [d.pubspec({ |
81 "name": "myapp", | 100 "name": "myapp", |
82 "dependencies": { | 101 "dependencies": { |
83 "foo": { | 102 "foo": { |
84 "path": "../foo" | 103 "path": "../foo" |
85 } | 104 } |
86 }, | 105 }, |
87 "transformers": ["foo"] | 106 "transformers": ["foo"] |
88 }), d.dir('lib', [d.file("myapp.dart", transformer())])]).create(); | 107 }), d.dir('lib', [d.file("myapp.dart", transformer())])]).create(); |
| 108 |
89 d.dir("foo", [d.pubspec({ | 109 d.dir("foo", [d.pubspec({ |
90 "name": "foo", | 110 "name": "foo", |
91 "dependencies": { | 111 "dependencies": { |
92 "bar": { | 112 "bar": { |
93 "path": "../bar" | 113 "path": "../bar" |
94 } | 114 } |
95 }, | 115 }, |
96 "transformers": ["bar"] | 116 "transformers": ["bar"] |
97 }), d.dir('lib', [d.file("foo.dart", transformer())])]).create(); | 117 }), d.dir('lib', [d.file("foo.dart", transformer())])]).create(); |
| 118 |
98 d.dir("bar", [d.pubspec({ | 119 d.dir("bar", [d.pubspec({ |
99 "name": "bar", | 120 "name": "bar", |
100 "dependencies": { | 121 "dependencies": { |
101 "myapp": { | 122 "myapp": { |
102 "path": "../myapp" | 123 "path": "../myapp" |
103 } | 124 } |
104 }, | 125 }, |
105 "transformers": ["myapp"] | 126 "transformers": ["myapp"] |
106 }), d.dir('lib', [d.file("bar.dart", transformer())])]).create(); | 127 }), d.dir('lib', [d.file("bar.dart", transformer())])]).create(); |
| 128 |
107 expectCycleException( | 129 expectCycleException( |
108 [ | 130 [ |
109 "bar is transformed by myapp", | 131 "bar is transformed by myapp", |
110 "myapp is transformed by foo", | 132 "myapp is transformed by foo", |
111 "foo is transformed by bar"]); | 133 "foo is transformed by bar"]); |
112 }); | 134 }); |
| 135 |
113 integration( | 136 integration( |
114 "allows a cross-package import cycle that's unrelated to " "transformers", | 137 "allows a cross-package import cycle that's unrelated to " "transformers", |
115 () { | 138 () { |
116 d.dir(appPath, [d.pubspec({ | 139 d.dir(appPath, [d.pubspec({ |
117 "name": "myapp", | 140 "name": "myapp", |
118 "dependencies": { | 141 "dependencies": { |
119 "foo": { | 142 "foo": { |
120 "path": "../foo" | 143 "path": "../foo" |
121 } | 144 } |
122 }, | 145 }, |
123 "transformers": ["myapp"] | 146 "transformers": ["myapp"] |
124 }), | 147 }), |
125 d.dir( | 148 d.dir( |
126 'lib', | 149 'lib', |
127 [d.file("myapp.dart", transformer(['package:foo/foo.dart']))])]).c
reate(); | 150 [d.file("myapp.dart", transformer(['package:foo/foo.dart']))])]).c
reate(); |
| 151 |
128 d.dir("foo", [d.libPubspec("foo", "1.0.0", deps: { | 152 d.dir("foo", [d.libPubspec("foo", "1.0.0", deps: { |
129 "bar": { | 153 "bar": { |
130 "path": "../bar" | 154 "path": "../bar" |
131 } | 155 } |
132 }), | 156 }), |
133 d.dir('lib', [d.file("foo.dart", "import 'package:bar/bar.dart';")])])
.create(); | 157 d.dir('lib', [d.file("foo.dart", "import 'package:bar/bar.dart';")])])
.create(); |
| 158 |
134 d.dir("bar", [d.libPubspec("bar", "1.0.0", deps: { | 159 d.dir("bar", [d.libPubspec("bar", "1.0.0", deps: { |
135 "baz": { | 160 "baz": { |
136 "path": "../baz" | 161 "path": "../baz" |
137 } | 162 } |
138 }), | 163 }), |
139 d.dir('lib', [d.file("bar.dart", "import 'package:baz/baz.dart';")])])
.create(); | 164 d.dir('lib', [d.file("bar.dart", "import 'package:baz/baz.dart';")])])
.create(); |
| 165 |
140 d.dir("baz", [d.libPubspec("baz", "1.0.0", deps: { | 166 d.dir("baz", [d.libPubspec("baz", "1.0.0", deps: { |
141 "foo": { | 167 "foo": { |
142 "path": "../foo" | 168 "path": "../foo" |
143 } | 169 } |
144 }), | 170 }), |
145 d.dir('lib', [d.file("baz.dart", "import 'package:foo/foo.dart';")])])
.create(); | 171 d.dir('lib', [d.file("baz.dart", "import 'package:foo/foo.dart';")])])
.create(); |
| 172 |
146 expectDependencies({ | 173 expectDependencies({ |
147 'myapp': [] | 174 'myapp': [] |
148 }); | 175 }); |
149 }); | 176 }); |
| 177 |
150 integration( | 178 integration( |
151 "disallows a cross-package import cycle that's related to " "transformers"
, | 179 "disallows a cross-package import cycle that's related to " "transformers"
, |
152 () { | 180 () { |
153 d.dir(appPath, [d.pubspec({ | 181 d.dir(appPath, [d.pubspec({ |
154 "name": "myapp", | 182 "name": "myapp", |
155 "dependencies": { | 183 "dependencies": { |
156 "foo": { | 184 "foo": { |
157 "path": "../foo" | 185 "path": "../foo" |
158 } | 186 } |
159 }, | 187 }, |
160 "transformers": ["myapp"] | 188 "transformers": ["myapp"] |
161 }), | 189 }), |
162 d.dir( | 190 d.dir( |
163 'lib', | 191 'lib', |
164 [d.file("myapp.dart", transformer(['package:foo/foo.dart']))])]).c
reate(); | 192 [d.file("myapp.dart", transformer(['package:foo/foo.dart']))])]).c
reate(); |
| 193 |
165 d.dir("foo", [d.libPubspec("foo", "1.0.0", deps: { | 194 d.dir("foo", [d.libPubspec("foo", "1.0.0", deps: { |
166 "bar": { | 195 "bar": { |
167 "path": "../bar" | 196 "path": "../bar" |
168 } | 197 } |
169 }), | 198 }), |
170 d.dir('lib', [d.file("foo.dart", "import 'package:bar/bar.dart';")])])
.create(); | 199 d.dir('lib', [d.file("foo.dart", "import 'package:bar/bar.dart';")])])
.create(); |
| 200 |
171 d.dir("bar", [d.libPubspec("bar", "1.0.0", deps: { | 201 d.dir("bar", [d.libPubspec("bar", "1.0.0", deps: { |
172 "myapp": { | 202 "myapp": { |
173 "path": "../myapp" | 203 "path": "../myapp" |
174 } | 204 } |
175 }), | 205 }), |
176 d.dir( | 206 d.dir( |
177 'lib', | 207 'lib', |
178 [d.file("bar.dart", "import 'package:myapp/myapp.dart';")])]).crea
te(); | 208 [d.file("bar.dart", "import 'package:myapp/myapp.dart';")])]).crea
te(); |
| 209 |
179 expectCycleException( | 210 expectCycleException( |
180 [ | 211 [ |
181 "myapp is transformed by myapp", | 212 "myapp is transformed by myapp", |
182 "myapp depends on foo", | 213 "myapp depends on foo", |
183 "foo depends on bar", | 214 "foo depends on bar", |
184 "bar depends on myapp"]); | 215 "bar depends on myapp"]); |
185 }); | 216 }); |
| 217 |
186 integration( | 218 integration( |
187 "allows a single-package import cycle that's unrelated to " "transformers"
, | 219 "allows a single-package import cycle that's unrelated to " "transformers"
, |
188 () { | 220 () { |
189 d.dir(appPath, [d.pubspec({ | 221 d.dir(appPath, [d.pubspec({ |
190 "name": "myapp", | 222 "name": "myapp", |
191 "dependencies": { | 223 "dependencies": { |
192 "foo": { | 224 "foo": { |
193 "path": "../foo" | 225 "path": "../foo" |
194 } | 226 } |
195 }, | 227 }, |
196 "transformers": ["myapp"] | 228 "transformers": ["myapp"] |
197 }), | 229 }), |
198 d.dir( | 230 d.dir( |
199 'lib', | 231 'lib', |
200 [ | 232 [ |
201 d.file("myapp.dart", transformer(['foo.dart'])), | 233 d.file("myapp.dart", transformer(['foo.dart'])), |
202 d.file("foo.dart", "import 'bar.dart';"), | 234 d.file("foo.dart", "import 'bar.dart';"), |
203 d.file("bar.dart", "import 'baz.dart';"), | 235 d.file("bar.dart", "import 'baz.dart';"), |
204 d.file("baz.dart", "import 'foo.dart';")])]).create(); | 236 d.file("baz.dart", "import 'foo.dart';")])]).create(); |
| 237 |
205 expectDependencies({ | 238 expectDependencies({ |
206 'myapp': [] | 239 'myapp': [] |
207 }); | 240 }); |
208 }); | 241 }); |
| 242 |
209 integration( | 243 integration( |
210 "allows a single-package import cycle that's related to " "transformers", | 244 "allows a single-package import cycle that's related to " "transformers", |
211 () { | 245 () { |
212 d.dir(appPath, [d.pubspec({ | 246 d.dir(appPath, [d.pubspec({ |
213 "name": "myapp", | 247 "name": "myapp", |
214 "dependencies": { | 248 "dependencies": { |
215 "foo": { | 249 "foo": { |
216 "path": "../foo" | 250 "path": "../foo" |
217 } | 251 } |
218 }, | 252 }, |
219 "transformers": ["myapp"] | 253 "transformers": ["myapp"] |
220 }), | 254 }), |
221 d.dir( | 255 d.dir( |
222 'lib', | 256 'lib', |
223 [ | 257 [ |
224 d.file("myapp.dart", transformer(['foo.dart'])), | 258 d.file("myapp.dart", transformer(['foo.dart'])), |
225 d.file("foo.dart", "import 'bar.dart';"), | 259 d.file("foo.dart", "import 'bar.dart';"), |
226 d.file("bar.dart", "import 'myapp.dart';")])]).create(); | 260 d.file("bar.dart", "import 'myapp.dart';"),])]).create(); |
| 261 |
227 expectDependencies({ | 262 expectDependencies({ |
228 'myapp': [] | 263 'myapp': [] |
229 }); | 264 }); |
230 }); | 265 }); |
231 } | 266 } |
OLD | NEW |