OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #library('pub_tests'); | 5 #library('pub_tests'); |
6 | 6 |
7 #import('dart:io'); | 7 #import('dart:io'); |
8 | 8 |
9 #import('test_pub.dart'); | 9 #import('test_pub.dart'); |
10 #import('../../../pkg/unittest/unittest.dart'); | 10 #import('../../../pkg/unittest/unittest.dart'); |
11 | 11 |
12 main() { | 12 main() { |
13 test('checks out a package from Git', () { | 13 test('checks out a package from Git', () { |
14 ensureGit(); | 14 ensureGit(); |
15 | 15 |
16 git('foo.git', [ | 16 git('foo.git', [ |
17 libDir('foo') | 17 libDir('foo'), |
| 18 libPubspec('foo', '1.0.0') |
18 ]).scheduleCreate(); | 19 ]).scheduleCreate(); |
19 | 20 |
20 appDir([{"git": "../foo.git"}]).scheduleCreate(); | 21 appDir([{"git": "../foo.git"}]).scheduleCreate(); |
21 | 22 |
22 schedulePub(args: ['install'], | 23 schedulePub(args: ['install'], |
23 output: const RegExp(@"Dependencies installed!$")); | 24 output: const RegExp(@"Dependencies installed!$")); |
24 | 25 |
25 dir(cachePath, [ | 26 dir(cachePath, [ |
26 dir('git', [ | 27 dir('git', [ |
27 dir('cache', [gitPackageRepoCacheDir('foo')]), | 28 dir('cache', [gitPackageRepoCacheDir('foo')]), |
28 gitPackageRevisionCacheDir('foo') | 29 gitPackageRevisionCacheDir('foo') |
29 ]) | 30 ]) |
30 ]).scheduleValidate(); | 31 ]).scheduleValidate(); |
31 | 32 |
32 dir(packagesPath, [ | 33 dir(packagesPath, [ |
33 dir('foo', [ | 34 dir('foo', [ |
34 file('foo.dart', 'main() => "foo";') | 35 file('foo.dart', 'main() => "foo";') |
35 ]) | 36 ]) |
36 ]).scheduleValidate(); | 37 ]).scheduleValidate(); |
37 | 38 |
38 run(); | 39 run(); |
39 }); | 40 }); |
40 | 41 |
41 test('checks out packages transitively from Git', () { | 42 test('checks out packages transitively from Git', () { |
42 ensureGit(); | 43 ensureGit(); |
43 | 44 |
44 git('foo.git', [ | 45 git('foo.git', [ |
45 libDir('foo'), | 46 libDir('foo'), |
46 appPubspec([{"git": "../bar.git"}]) | 47 libPubspec('foo', '1.0.0', [{"git": "../bar.git"}]) |
47 ]).scheduleCreate(); | 48 ]).scheduleCreate(); |
48 | 49 |
49 git('bar.git', [ | 50 git('bar.git', [ |
50 libDir('bar') | 51 libDir('bar'), |
| 52 libPubspec('bar', '1.0.0') |
51 ]).scheduleCreate(); | 53 ]).scheduleCreate(); |
52 | 54 |
53 appDir([{"git": "../foo.git"}]).scheduleCreate(); | 55 appDir([{"git": "../foo.git"}]).scheduleCreate(); |
54 | 56 |
55 schedulePub(args: ['install'], | 57 schedulePub(args: ['install'], |
56 output: const RegExp("Dependencies installed!\$")); | 58 output: const RegExp("Dependencies installed!\$")); |
57 | 59 |
58 dir(cachePath, [ | 60 dir(cachePath, [ |
59 dir('git', [ | 61 dir('git', [ |
60 dir('cache', [ | 62 dir('cache', [ |
(...skipping 10 matching lines...) Expand all Loading... |
71 file('foo.dart', 'main() => "foo";') | 73 file('foo.dart', 'main() => "foo";') |
72 ]), | 74 ]), |
73 dir('bar', [ | 75 dir('bar', [ |
74 file('bar.dart', 'main() => "bar";') | 76 file('bar.dart', 'main() => "bar";') |
75 ]) | 77 ]) |
76 ]).scheduleValidate(); | 78 ]).scheduleValidate(); |
77 | 79 |
78 run(); | 80 run(); |
79 }); | 81 }); |
80 | 82 |
81 test('requires the repository name to match the name in the pubspec', () { | 83 test('doesn\'t require the repository name to match the name in the ' |
| 84 'pubspec', () { |
| 85 ensureGit(); |
| 86 |
| 87 git('foo.git', [ |
| 88 libDir('weirdname'), |
| 89 libPubspec('weirdname', '1.0.0') |
| 90 ]).scheduleCreate(); |
| 91 |
| 92 dir(appPath, [ |
| 93 pubspec({ |
| 94 "name": "myapp", |
| 95 "dependencies": { |
| 96 "weirdname": {"git": "../foo.git"} |
| 97 } |
| 98 }) |
| 99 ]).scheduleCreate(); |
| 100 |
| 101 schedulePub(args: ['install'], |
| 102 output: const RegExp(@"Dependencies installed!$")); |
| 103 |
| 104 dir(packagesPath, [ |
| 105 dir('weirdname', [ |
| 106 file('weirdname.dart', 'main() => "weirdname";') |
| 107 ]) |
| 108 ]).scheduleValidate(); |
| 109 |
| 110 run(); |
| 111 }); |
| 112 |
| 113 test('requires the dependency to have a pubspec', () { |
82 ensureGit(); | 114 ensureGit(); |
83 | 115 |
84 git('foo.git', [ | 116 git('foo.git', [ |
85 libDir('foo') | 117 libDir('foo') |
86 ]).scheduleCreate(); | 118 ]).scheduleCreate(); |
87 | 119 |
| 120 appDir([{"git": "../foo.git"}]).scheduleCreate(); |
| 121 |
| 122 // TODO(nweiz): clean up this RegExp when either issue 4706 or 4707 is |
| 123 // fixed. |
| 124 schedulePub(args: ['install'], |
| 125 error: const RegExp(@'^Package "foo" doesn' @"'" 't have a ' |
| 126 'pubspec.yaml file.'), |
| 127 exitCode: 1); |
| 128 |
| 129 run(); |
| 130 }); |
| 131 |
| 132 test('requires the dependency to have a pubspec with a name field', () { |
| 133 ensureGit(); |
| 134 |
| 135 git('foo.git', [ |
| 136 libDir('foo'), |
| 137 pubspec({}) |
| 138 ]).scheduleCreate(); |
| 139 |
| 140 appDir([{"git": "../foo.git"}]).scheduleCreate(); |
| 141 |
| 142 // TODO(nweiz): clean up this RegExp when either issue 4706 or 4707 is |
| 143 // fixed. |
| 144 schedulePub(args: ['install'], |
| 145 error: const RegExp(@'^Package "foo"' @"'" 's pubspec.yaml file is ' |
| 146 @'missing the required "name" field \(e\.g\. "name: foo"\)\.'), |
| 147 exitCode: 1); |
| 148 |
| 149 run(); |
| 150 }); |
| 151 |
| 152 test('requires the dependency name to match the remote pubspec name', () { |
| 153 ensureGit(); |
| 154 |
| 155 git('foo.git', [ |
| 156 libDir('foo'), |
| 157 libPubspec('foo', '1.0.0') |
| 158 ]).scheduleCreate(); |
| 159 |
88 dir(appPath, [ | 160 dir(appPath, [ |
89 pubspec({ | 161 pubspec({ |
90 "name": "myapp", | 162 "name": "myapp", |
91 "dependencies": { | 163 "dependencies": { |
92 "weird-name": {"git": "../foo.git"} | 164 "weirdname": {"git": "../foo.git"} |
93 } | 165 } |
94 }) | 166 }) |
95 ]).scheduleCreate(); | 167 ]).scheduleCreate(); |
96 | 168 |
97 // TODO(nweiz): clean up this RegExp when either issue 4706 or 4707 is | 169 // TODO(nweiz): clean up this RegExp when either issue 4706 or 4707 is |
98 // fixed. | 170 // fixed. |
99 schedulePub(args: ['install'], | 171 schedulePub(args: ['install'], |
100 error: const RegExp(@'^FormatException: The name you specified for ' | 172 error: const RegExp(@'^The name you specified for your dependency, ' |
101 @'your dependency, "weird-name", doesn' @"'" @'t match the name ' | 173 @'"weirdname", doesn' @"'" @'t match the name "foo" in its ' |
102 @'"foo" \(from "\.\./foo\.git"\)\.'), | 174 @'pubspec\.'), |
103 exitCode: 1); | 175 exitCode: 1); |
104 | 176 |
105 run(); | 177 run(); |
106 }); | 178 }); |
107 | 179 |
108 test('checks out and updates a package from Git', () { | 180 test('checks out and updates a package from Git', () { |
109 ensureGit(); | 181 ensureGit(); |
110 | 182 |
111 git('foo.git', [ | 183 git('foo.git', [ |
112 libDir('foo') | 184 libDir('foo'), |
| 185 libPubspec('foo', '1.0.0') |
113 ]).scheduleCreate(); | 186 ]).scheduleCreate(); |
114 | 187 |
115 appDir([{"git": "../foo.git"}]).scheduleCreate(); | 188 appDir([{"git": "../foo.git"}]).scheduleCreate(); |
116 | 189 |
117 schedulePub(args: ['install'], | 190 schedulePub(args: ['install'], |
118 output: const RegExp(@"Dependencies installed!$")); | 191 output: const RegExp(@"Dependencies installed!$")); |
119 | 192 |
120 dir(cachePath, [ | 193 dir(cachePath, [ |
121 dir('git', [ | 194 dir('git', [ |
122 dir('cache', [gitPackageRepoCacheDir('foo')]), | 195 dir('cache', [gitPackageRepoCacheDir('foo')]), |
123 gitPackageRevisionCacheDir('foo') | 196 gitPackageRevisionCacheDir('foo') |
124 ]) | 197 ]) |
125 ]).scheduleValidate(); | 198 ]).scheduleValidate(); |
126 | 199 |
127 dir(packagesPath, [ | 200 dir(packagesPath, [ |
128 dir('foo', [ | 201 dir('foo', [ |
129 file('foo.dart', 'main() => "foo";') | 202 file('foo.dart', 'main() => "foo";') |
130 ]) | 203 ]) |
131 ]).scheduleValidate(); | 204 ]).scheduleValidate(); |
132 | 205 |
133 // TODO(nweiz): remove this once we support pub update | 206 // TODO(nweiz): remove this once we support pub update |
134 dir(packagesPath).scheduleDelete(); | 207 dir(packagesPath).scheduleDelete(); |
135 file('$appPath/pubspec.lock', '').scheduleDelete(); | 208 file('$appPath/pubspec.lock', '').scheduleDelete(); |
136 | 209 |
137 git('foo.git', [ | 210 git('foo.git', [ |
138 libDir('foo', 'foo 2') | 211 libDir('foo', 'foo 2'), |
| 212 libPubspec('foo', '1.0.0') |
139 ]).scheduleCommit(); | 213 ]).scheduleCommit(); |
140 | 214 |
141 schedulePub(args: ['install'], | 215 schedulePub(args: ['install'], |
142 output: const RegExp(@"Dependencies installed!$")); | 216 output: const RegExp(@"Dependencies installed!$")); |
143 | 217 |
144 // When we download a new version of the git package, we should re-use the | 218 // When we download a new version of the git package, we should re-use the |
145 // git/cache directory but create a new git/ directory. | 219 // git/cache directory but create a new git/ directory. |
146 dir(cachePath, [ | 220 dir(cachePath, [ |
147 dir('git', [ | 221 dir('git', [ |
148 dir('cache', [gitPackageRepoCacheDir('foo')]), | 222 dir('cache', [gitPackageRepoCacheDir('foo')]), |
149 gitPackageRevisionCacheDir('foo'), | 223 gitPackageRevisionCacheDir('foo'), |
150 gitPackageRevisionCacheDir('foo', 2) | 224 gitPackageRevisionCacheDir('foo', 2) |
151 ]) | 225 ]) |
152 ]).scheduleValidate(); | 226 ]).scheduleValidate(); |
153 | 227 |
154 dir(packagesPath, [ | 228 dir(packagesPath, [ |
155 dir('foo', [ | 229 dir('foo', [ |
156 file('foo.dart', 'main() => "foo 2";') | 230 file('foo.dart', 'main() => "foo 2";') |
157 ]) | 231 ]) |
158 ]).scheduleValidate(); | 232 ]).scheduleValidate(); |
159 | 233 |
160 run(); | 234 run(); |
161 }); | 235 }); |
162 | 236 |
163 test('checks out a package from Git twice', () { | 237 test('checks out a package from Git twice', () { |
164 ensureGit(); | 238 ensureGit(); |
165 | 239 |
166 git('foo.git', [ | 240 git('foo.git', [ |
167 libDir('foo') | 241 libDir('foo'), |
| 242 libPubspec('foo', '1.0.0') |
168 ]).scheduleCreate(); | 243 ]).scheduleCreate(); |
169 | 244 |
170 appDir([{"git": "../foo.git"}]).scheduleCreate(); | 245 appDir([{"git": "../foo.git"}]).scheduleCreate(); |
171 | 246 |
172 schedulePub(args: ['install'], | 247 schedulePub(args: ['install'], |
173 output: const RegExp(@"Dependencies installed!$")); | 248 output: const RegExp(@"Dependencies installed!$")); |
174 | 249 |
175 dir(cachePath, [ | 250 dir(cachePath, [ |
176 dir('git', [ | 251 dir('git', [ |
177 dir('cache', [gitPackageRepoCacheDir('foo')]), | 252 dir('cache', [gitPackageRepoCacheDir('foo')]), |
(...skipping 15 matching lines...) Expand all Loading... |
193 schedulePub(args: ['install'], | 268 schedulePub(args: ['install'], |
194 output: const RegExp(@"Dependencies installed!$")); | 269 output: const RegExp(@"Dependencies installed!$")); |
195 | 270 |
196 run(); | 271 run(); |
197 }); | 272 }); |
198 | 273 |
199 test('checks out a package at a specific revision from Git', () { | 274 test('checks out a package at a specific revision from Git', () { |
200 ensureGit(); | 275 ensureGit(); |
201 | 276 |
202 var repo = git('foo.git', [ | 277 var repo = git('foo.git', [ |
203 libDir('foo', 'foo 1') | 278 libDir('foo', 'foo 1'), |
| 279 libPubspec('foo', '1.0.0') |
204 ]); | 280 ]); |
205 repo.scheduleCreate(); | 281 repo.scheduleCreate(); |
206 var commit = repo.revParse('HEAD'); | 282 var commit = repo.revParse('HEAD'); |
207 | 283 |
208 git('foo.git', [ | 284 git('foo.git', [ |
209 libDir('foo', 'foo 2') | 285 libDir('foo', 'foo 2'), |
| 286 libPubspec('foo', '1.0.0') |
210 ]).scheduleCommit(); | 287 ]).scheduleCommit(); |
211 | 288 |
212 appDir([{"git": {"url": "../foo.git", "ref": commit}}]).scheduleCreate(); | 289 appDir([{"git": {"url": "../foo.git", "ref": commit}}]).scheduleCreate(); |
213 | 290 |
214 schedulePub(args: ['install'], | 291 schedulePub(args: ['install'], |
215 output: const RegExp(@"Dependencies installed!$")); | 292 output: const RegExp(@"Dependencies installed!$")); |
216 | 293 |
217 dir(packagesPath, [ | 294 dir(packagesPath, [ |
218 dir('foo', [ | 295 dir('foo', [ |
219 file('foo.dart', 'main() => "foo 1";') | 296 file('foo.dart', 'main() => "foo 1";') |
220 ]) | 297 ]) |
221 ]).scheduleValidate(); | 298 ]).scheduleValidate(); |
222 | 299 |
223 run(); | 300 run(); |
224 }); | 301 }); |
225 | 302 |
226 test('checks out a package at a specific branch from Git', () { | 303 test('checks out a package at a specific branch from Git', () { |
227 ensureGit(); | 304 ensureGit(); |
228 | 305 |
229 var repo = git('foo.git', [ | 306 var repo = git('foo.git', [ |
230 libDir('foo', 'foo 1') | 307 libDir('foo', 'foo 1'), |
| 308 libPubspec('foo', '1.0.0') |
231 ]); | 309 ]); |
232 repo.scheduleCreate(); | 310 repo.scheduleCreate(); |
233 repo.scheduleGit(["branch", "old"]); | 311 repo.scheduleGit(["branch", "old"]); |
234 | 312 |
235 git('foo.git', [ | 313 git('foo.git', [ |
236 libDir('foo', 'foo 2') | 314 libDir('foo', 'foo 2'), |
| 315 libPubspec('foo', '1.0.0') |
237 ]).scheduleCommit(); | 316 ]).scheduleCommit(); |
238 | 317 |
239 appDir([{"git": {"url": "../foo.git", "ref": "old"}}]).scheduleCreate(); | 318 appDir([{"git": {"url": "../foo.git", "ref": "old"}}]).scheduleCreate(); |
240 | 319 |
241 schedulePub(args: ['install'], | 320 schedulePub(args: ['install'], |
242 output: const RegExp(@"Dependencies installed!$")); | 321 output: const RegExp(@"Dependencies installed!$")); |
243 | 322 |
244 dir(packagesPath, [ | 323 dir(packagesPath, [ |
245 dir('foo', [ | 324 dir('foo', [ |
246 file('foo.dart', 'main() => "foo 1";') | 325 file('foo.dart', 'main() => "foo 1";') |
247 ]) | 326 ]) |
248 ]).scheduleValidate(); | 327 ]).scheduleValidate(); |
249 | 328 |
250 run(); | 329 run(); |
251 }); | 330 }); |
252 | 331 |
253 test('keeps a Git package locked to the version in the lockfile', () { | 332 test('keeps a Git package locked to the version in the lockfile', () { |
254 ensureGit(); | 333 ensureGit(); |
255 | 334 |
256 git('foo.git', [ | 335 git('foo.git', [ |
257 libDir('foo') | 336 libDir('foo'), |
| 337 libPubspec('foo', '1.0.0') |
258 ]).scheduleCreate(); | 338 ]).scheduleCreate(); |
259 | 339 |
260 appDir([{"git": "../foo.git"}]).scheduleCreate(); | 340 appDir([{"git": "../foo.git"}]).scheduleCreate(); |
261 | 341 |
262 // This install should lock the foo.git dependency to the current revision. | 342 // This install should lock the foo.git dependency to the current revision. |
263 schedulePub(args: ['install'], | 343 schedulePub(args: ['install'], |
264 output: const RegExp(@"Dependencies installed!$")); | 344 output: const RegExp(@"Dependencies installed!$")); |
265 | 345 |
266 dir(packagesPath, [ | 346 dir(packagesPath, [ |
267 dir('foo', [ | 347 dir('foo', [ |
268 file('foo.dart', 'main() => "foo";') | 348 file('foo.dart', 'main() => "foo";') |
269 ]) | 349 ]) |
270 ]).scheduleValidate(); | 350 ]).scheduleValidate(); |
271 | 351 |
272 // Delete the packages path to simulate a new checkout of the application. | 352 // Delete the packages path to simulate a new checkout of the application. |
273 dir(packagesPath).scheduleDelete(); | 353 dir(packagesPath).scheduleDelete(); |
274 | 354 |
275 git('foo.git', [ | 355 git('foo.git', [ |
276 libDir('foo', 'foo 2') | 356 libDir('foo', 'foo 2'), |
| 357 libPubspec('foo', '1.0.0') |
277 ]).scheduleCommit(); | 358 ]).scheduleCommit(); |
278 | 359 |
279 // This install shouldn't update the foo.git dependency due to the lockfile. | 360 // This install shouldn't update the foo.git dependency due to the lockfile. |
280 schedulePub(args: ['install'], | 361 schedulePub(args: ['install'], |
281 output: const RegExp(@"Dependencies installed!$")); | 362 output: const RegExp(@"Dependencies installed!$")); |
282 | 363 |
283 dir(packagesPath, [ | 364 dir(packagesPath, [ |
284 dir('foo', [ | 365 dir('foo', [ |
285 file('foo.dart', 'main() => "foo";') | 366 file('foo.dart', 'main() => "foo";') |
286 ]) | 367 ]) |
287 ]).scheduleValidate(); | 368 ]).scheduleValidate(); |
288 | 369 |
289 run(); | 370 run(); |
290 }); | 371 }); |
291 | 372 |
292 test('updates a locked Git package with a new incompatible constraint', () { | 373 test('updates a locked Git package with a new incompatible constraint', () { |
293 ensureGit(); | 374 ensureGit(); |
294 | 375 |
295 git('foo.git', [ | 376 git('foo.git', [ |
296 libDir('foo') | 377 libDir('foo'), |
| 378 libPubspec('foo', '0.5.0') |
297 ]).scheduleCreate(); | 379 ]).scheduleCreate(); |
298 | 380 |
299 appDir([{"git": "../foo.git"}]).scheduleCreate(); | 381 appDir([{"git": "../foo.git"}]).scheduleCreate(); |
300 | 382 |
301 schedulePub(args: ['install'], | 383 schedulePub(args: ['install'], |
302 output: const RegExp(@"Dependencies installed!$")); | 384 output: const RegExp(@"Dependencies installed!$")); |
303 | 385 |
304 dir(packagesPath, [ | 386 dir(packagesPath, [ |
305 dir('foo', [ | 387 dir('foo', [ |
306 file('foo.dart', 'main() => "foo";') | 388 file('foo.dart', 'main() => "foo";') |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 ]).scheduleValidate(); | 445 ]).scheduleValidate(); |
364 | 446 |
365 run(); | 447 run(); |
366 }); | 448 }); |
367 | 449 |
368 group("(regression)", () { | 450 group("(regression)", () { |
369 test('checks out a package from Git with a trailing slash', () { | 451 test('checks out a package from Git with a trailing slash', () { |
370 ensureGit(); | 452 ensureGit(); |
371 | 453 |
372 git('foo.git', [ | 454 git('foo.git', [ |
373 libDir('foo') | 455 libDir('foo'), |
| 456 libPubspec('foo', '1.0.0') |
374 ]).scheduleCreate(); | 457 ]).scheduleCreate(); |
375 | 458 |
376 appDir([{"git": "../foo.git/"}]).scheduleCreate(); | 459 appDir([{"git": "../foo.git/"}]).scheduleCreate(); |
377 | 460 |
378 schedulePub(args: ['install'], | 461 schedulePub(args: ['install'], |
379 output: const RegExp(@"Dependencies installed!$")); | 462 output: const RegExp(@"Dependencies installed!$")); |
380 | 463 |
381 dir(cachePath, [ | 464 dir(cachePath, [ |
382 dir('git', [ | 465 dir('git', [ |
383 dir('cache', [gitPackageRepoCacheDir('foo')]), | 466 dir('cache', [gitPackageRepoCacheDir('foo')]), |
384 gitPackageRevisionCacheDir('foo') | 467 gitPackageRevisionCacheDir('foo') |
385 ]) | 468 ]) |
386 ]).scheduleValidate(); | 469 ]).scheduleValidate(); |
387 | 470 |
388 dir(packagesPath, [ | 471 dir(packagesPath, [ |
389 dir('foo', [ | 472 dir('foo', [ |
390 file('foo.dart', 'main() => "foo";') | 473 file('foo.dart', 'main() => "foo";') |
391 ]) | 474 ]) |
392 ]).scheduleValidate(); | 475 ]).scheduleValidate(); |
393 | 476 |
394 run(); | 477 run(); |
395 }); | 478 }); |
396 }); | 479 }); |
397 } | 480 } |
OLD | NEW |