Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: utils/tests/pub/pub_install_git_test.dart

Issue 10916190: Support both new and old style package layouts. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Respond to review. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 file('foo.dart', 'main() => "foo";') 17 libDir('foo')
18 ]).scheduleCreate(); 18 ]).scheduleCreate();
19 19
20 appDir([{"git": "../foo.git"}]).scheduleCreate(); 20 appDir([{"git": "../foo.git"}]).scheduleCreate();
21 21
22 schedulePub(args: ['install'], 22 schedulePub(args: ['install'],
23 output: const RegExp(@"Dependencies installed!$")); 23 output: const RegExp(@"Dependencies installed!$"));
24 24
25 dir(cachePath, [ 25 dir(cachePath, [
26 dir('git', [ 26 dir('git', [
27 dir('cache', [gitPackageRepoCacheDir('foo')]), 27 dir('cache', [gitPackageRepoCacheDir('foo')]),
28 gitPackageRevisionCacheDir('foo') 28 gitPackageRevisionCacheDir('foo')
29 ]) 29 ])
30 ]).scheduleValidate(); 30 ]).scheduleValidate();
31 31
32 dir(packagesPath, [ 32 dir(packagesPath, [
33 dir('foo', [ 33 dir('foo', [
34 file('foo.dart', 'main() => "foo";') 34 file('foo.dart', 'main() => "foo";')
35 ]) 35 ])
36 ]).scheduleValidate(); 36 ]).scheduleValidate();
37 37
38 run(); 38 run();
39 }); 39 });
40 40
41 test('checks out packages transitively from Git', () { 41 test('checks out packages transitively from Git', () {
42 ensureGit(); 42 ensureGit();
43 43
44 git('foo.git', [ 44 git('foo.git', [
45 file('foo.dart', 'main() => "foo";'), 45 libDir('foo'),
46 appPubspec([{"git": "../bar.git"}]) 46 appPubspec([{"git": "../bar.git"}])
47 ]).scheduleCreate(); 47 ]).scheduleCreate();
48 48
49 git('bar.git', [ 49 git('bar.git', [
50 file('bar.dart', 'main() => "bar";') 50 libDir('bar')
51 ]).scheduleCreate(); 51 ]).scheduleCreate();
52 52
53 appDir([{"git": "../foo.git"}]).scheduleCreate(); 53 appDir([{"git": "../foo.git"}]).scheduleCreate();
54 54
55 schedulePub(args: ['install'], 55 schedulePub(args: ['install'],
56 output: const RegExp("Dependencies installed!\$")); 56 output: const RegExp("Dependencies installed!\$"));
57 57
58 dir(cachePath, [ 58 dir(cachePath, [
59 dir('git', [ 59 dir('git', [
60 dir('cache', [ 60 dir('cache', [
(...skipping 14 matching lines...) Expand all
75 ]) 75 ])
76 ]).scheduleValidate(); 76 ]).scheduleValidate();
77 77
78 run(); 78 run();
79 }); 79 });
80 80
81 test('requires the repository name to match the name in the pubspec', () { 81 test('requires the repository name to match the name in the pubspec', () {
82 ensureGit(); 82 ensureGit();
83 83
84 git('foo.git', [ 84 git('foo.git', [
85 file('foo.dart', 'main() => "foo";') 85 libDir('foo')
86 ]).scheduleCreate(); 86 ]).scheduleCreate();
87 87
88 dir(appPath, [ 88 dir(appPath, [
89 pubspec({ 89 pubspec({
90 "name": "myapp", 90 "name": "myapp",
91 "dependencies": { 91 "dependencies": {
92 "weird-name": {"git": "../foo.git"} 92 "weird-name": {"git": "../foo.git"}
93 } 93 }
94 }) 94 })
95 ]).scheduleCreate(); 95 ]).scheduleCreate();
96 96
97 // TODO(nweiz): clean up this RegExp when either issue 4706 or 4707 is 97 // TODO(nweiz): clean up this RegExp when either issue 4706 or 4707 is
98 // fixed. 98 // fixed.
99 schedulePub(args: ['install'], 99 schedulePub(args: ['install'],
100 error: const RegExp(@'^FormatException: The name you specified for ' 100 error: const RegExp(@'^FormatException: The name you specified for '
101 @'your dependency, "weird-name", doesn' @"'" @'t match the name ' 101 @'your dependency, "weird-name", doesn' @"'" @'t match the name '
102 @'"foo" \(from "\.\./foo\.git"\)\.'), 102 @'"foo" \(from "\.\./foo\.git"\)\.'),
103 exitCode: 1); 103 exitCode: 1);
104 104
105 run(); 105 run();
106 }); 106 });
107 107
108 test('checks out and updates a package from Git', () { 108 test('checks out and updates a package from Git', () {
109 ensureGit(); 109 ensureGit();
110 110
111 git('foo.git', [ 111 git('foo.git', [
112 file('foo.dart', 'main() => "foo";') 112 libDir('foo')
113 ]).scheduleCreate(); 113 ]).scheduleCreate();
114 114
115 appDir([{"git": "../foo.git"}]).scheduleCreate(); 115 appDir([{"git": "../foo.git"}]).scheduleCreate();
116 116
117 schedulePub(args: ['install'], 117 schedulePub(args: ['install'],
118 output: const RegExp(@"Dependencies installed!$")); 118 output: const RegExp(@"Dependencies installed!$"));
119 119
120 dir(cachePath, [ 120 dir(cachePath, [
121 dir('git', [ 121 dir('git', [
122 dir('cache', [gitPackageRepoCacheDir('foo')]), 122 dir('cache', [gitPackageRepoCacheDir('foo')]),
123 gitPackageRevisionCacheDir('foo') 123 gitPackageRevisionCacheDir('foo')
124 ]) 124 ])
125 ]).scheduleValidate(); 125 ]).scheduleValidate();
126 126
127 dir(packagesPath, [ 127 dir(packagesPath, [
128 dir('foo', [ 128 dir('foo', [
129 file('foo.dart', 'main() => "foo";') 129 file('foo.dart', 'main() => "foo";')
130 ]) 130 ])
131 ]).scheduleValidate(); 131 ]).scheduleValidate();
132 132
133 // TODO(nweiz): remove this once we support pub update 133 // TODO(nweiz): remove this once we support pub update
134 dir(packagesPath).scheduleDelete(); 134 dir(packagesPath).scheduleDelete();
135 file('$appPath/pubspec.lock', '').scheduleDelete(); 135 file('$appPath/pubspec.lock', '').scheduleDelete();
136 136
137 git('foo.git', [ 137 git('foo.git', [
138 file('foo.dart', 'main() => "foo 2";') 138 libDir('foo', 'foo 2')
139 ]).scheduleCommit(); 139 ]).scheduleCommit();
140 140
141 schedulePub(args: ['install'], 141 schedulePub(args: ['install'],
142 output: const RegExp(@"Dependencies installed!$")); 142 output: const RegExp(@"Dependencies installed!$"));
143 143
144 // When we download a new version of the git package, we should re-use the 144 // 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. 145 // git/cache directory but create a new git/ directory.
146 dir(cachePath, [ 146 dir(cachePath, [
147 dir('git', [ 147 dir('git', [
148 dir('cache', [gitPackageRepoCacheDir('foo')]), 148 dir('cache', [gitPackageRepoCacheDir('foo')]),
149 gitPackageRevisionCacheDir('foo'), 149 gitPackageRevisionCacheDir('foo'),
150 gitPackageRevisionCacheDir('foo', 2) 150 gitPackageRevisionCacheDir('foo', 2)
151 ]) 151 ])
152 ]).scheduleValidate(); 152 ]).scheduleValidate();
153 153
154 dir(packagesPath, [ 154 dir(packagesPath, [
155 dir('foo', [ 155 dir('foo', [
156 file('foo.dart', 'main() => "foo 2";') 156 file('foo.dart', 'main() => "foo 2";')
157 ]) 157 ])
158 ]).scheduleValidate(); 158 ]).scheduleValidate();
159 159
160 run(); 160 run();
161 }); 161 });
162 162
163 test('checks out a package from Git twice', () { 163 test('checks out a package from Git twice', () {
164 ensureGit(); 164 ensureGit();
165 165
166 git('foo.git', [ 166 git('foo.git', [
167 file('foo.dart', 'main() => "foo";') 167 libDir('foo')
168 ]).scheduleCreate(); 168 ]).scheduleCreate();
169 169
170 appDir([{"git": "../foo.git"}]).scheduleCreate(); 170 appDir([{"git": "../foo.git"}]).scheduleCreate();
171 171
172 schedulePub(args: ['install'], 172 schedulePub(args: ['install'],
173 output: const RegExp(@"Dependencies installed!$")); 173 output: const RegExp(@"Dependencies installed!$"));
174 174
175 dir(cachePath, [ 175 dir(cachePath, [
176 dir('git', [ 176 dir('git', [
177 dir('cache', [gitPackageRepoCacheDir('foo')]), 177 dir('cache', [gitPackageRepoCacheDir('foo')]),
(...skipping 15 matching lines...) Expand all
193 schedulePub(args: ['install'], 193 schedulePub(args: ['install'],
194 output: const RegExp(@"Dependencies installed!$")); 194 output: const RegExp(@"Dependencies installed!$"));
195 195
196 run(); 196 run();
197 }); 197 });
198 198
199 test('checks out a package at a specific revision from Git', () { 199 test('checks out a package at a specific revision from Git', () {
200 ensureGit(); 200 ensureGit();
201 201
202 var repo = git('foo.git', [ 202 var repo = git('foo.git', [
203 file('foo.dart', 'main() => "foo 1";') 203 libDir('foo', 'foo 1')
204 ]); 204 ]);
205 repo.scheduleCreate(); 205 repo.scheduleCreate();
206 var commit = repo.revParse('HEAD'); 206 var commit = repo.revParse('HEAD');
207 207
208 git('foo.git', [ 208 git('foo.git', [
209 file('foo.dart', 'main() => "foo 2";') 209 libDir('foo', 'foo 2')
210 ]).scheduleCommit(); 210 ]).scheduleCommit();
211 211
212 appDir([{"git": {"url": "../foo.git", "ref": commit}}]).scheduleCreate(); 212 appDir([{"git": {"url": "../foo.git", "ref": commit}}]).scheduleCreate();
213 213
214 schedulePub(args: ['install'], 214 schedulePub(args: ['install'],
215 output: const RegExp(@"Dependencies installed!$")); 215 output: const RegExp(@"Dependencies installed!$"));
216 216
217 dir(packagesPath, [ 217 dir(packagesPath, [
218 dir('foo', [ 218 dir('foo', [
219 file('foo.dart', 'main() => "foo 1";') 219 file('foo.dart', 'main() => "foo 1";')
220 ]) 220 ])
221 ]).scheduleValidate(); 221 ]).scheduleValidate();
222 222
223 run(); 223 run();
224 }); 224 });
225 225
226 test('checks out a package at a specific branch from Git', () { 226 test('checks out a package at a specific branch from Git', () {
227 ensureGit(); 227 ensureGit();
228 228
229 var repo = git('foo.git', [ 229 var repo = git('foo.git', [
230 file('foo.dart', 'main() => "foo 1";') 230 libDir('foo', 'foo 1')
231 ]); 231 ]);
232 repo.scheduleCreate(); 232 repo.scheduleCreate();
233 repo.scheduleGit(["branch", "old"]); 233 repo.scheduleGit(["branch", "old"]);
234 234
235 git('foo.git', [ 235 git('foo.git', [
236 file('foo.dart', 'main() => "foo 2";') 236 libDir('foo', 'foo 2')
237 ]).scheduleCommit(); 237 ]).scheduleCommit();
238 238
239 appDir([{"git": {"url": "../foo.git", "ref": "old"}}]).scheduleCreate(); 239 appDir([{"git": {"url": "../foo.git", "ref": "old"}}]).scheduleCreate();
240 240
241 schedulePub(args: ['install'], 241 schedulePub(args: ['install'],
242 output: const RegExp(@"Dependencies installed!$")); 242 output: const RegExp(@"Dependencies installed!$"));
243 243
244 dir(packagesPath, [ 244 dir(packagesPath, [
245 dir('foo', [ 245 dir('foo', [
246 file('foo.dart', 'main() => "foo 1";') 246 file('foo.dart', 'main() => "foo 1";')
247 ]) 247 ])
248 ]).scheduleValidate(); 248 ]).scheduleValidate();
249 249
250 run(); 250 run();
251 }); 251 });
252 252
253 test('keeps a Git package locked to the version in the lockfile', () { 253 test('keeps a Git package locked to the version in the lockfile', () {
254 ensureGit(); 254 ensureGit();
255 255
256 git('foo.git', [ 256 git('foo.git', [
257 file('foo.dart', 'main() => "foo";') 257 libDir('foo')
258 ]).scheduleCreate(); 258 ]).scheduleCreate();
259 259
260 appDir([{"git": "../foo.git"}]).scheduleCreate(); 260 appDir([{"git": "../foo.git"}]).scheduleCreate();
261 261
262 // This install should lock the foo.git dependency to the current revision. 262 // This install should lock the foo.git dependency to the current revision.
263 schedulePub(args: ['install'], 263 schedulePub(args: ['install'],
264 output: const RegExp(@"Dependencies installed!$")); 264 output: const RegExp(@"Dependencies installed!$"));
265 265
266 dir(packagesPath, [ 266 dir(packagesPath, [
267 dir('foo', [ 267 dir('foo', [
268 file('foo.dart', 'main() => "foo";') 268 file('foo.dart', 'main() => "foo";')
269 ]) 269 ])
270 ]).scheduleValidate(); 270 ]).scheduleValidate();
271 271
272 // Delete the packages path to simulate a new checkout of the application. 272 // Delete the packages path to simulate a new checkout of the application.
273 dir(packagesPath).scheduleDelete(); 273 dir(packagesPath).scheduleDelete();
274 274
275 git('foo.git', [ 275 git('foo.git', [
276 file('foo.dart', 'main() => "foo 2";') 276 libDir('foo', 'foo 2')
277 ]).scheduleCommit(); 277 ]).scheduleCommit();
278 278
279 // This install shouldn't update the foo.git dependency due to the lockfile. 279 // This install shouldn't update the foo.git dependency due to the lockfile.
280 schedulePub(args: ['install'], 280 schedulePub(args: ['install'],
281 output: const RegExp(@"Dependencies installed!$")); 281 output: const RegExp(@"Dependencies installed!$"));
282 282
283 dir(packagesPath, [ 283 dir(packagesPath, [
284 dir('foo', [ 284 dir('foo', [
285 file('foo.dart', 'main() => "foo";') 285 file('foo.dart', 'main() => "foo";')
286 ]) 286 ])
287 ]).scheduleValidate(); 287 ]).scheduleValidate();
288 288
289 run(); 289 run();
290 }); 290 });
291 291
292 test('updates a locked Git package with a new incompatible constraint', () { 292 test('updates a locked Git package with a new incompatible constraint', () {
293 ensureGit(); 293 ensureGit();
294 294
295 git('foo.git', [ 295 git('foo.git', [
296 file('foo.dart', 'main() => "foo";') 296 libDir('foo')
297 ]).scheduleCreate(); 297 ]).scheduleCreate();
298 298
299 appDir([{"git": "../foo.git"}]).scheduleCreate(); 299 appDir([{"git": "../foo.git"}]).scheduleCreate();
300 300
301 schedulePub(args: ['install'], 301 schedulePub(args: ['install'],
302 output: const RegExp(@"Dependencies installed!$")); 302 output: const RegExp(@"Dependencies installed!$"));
303 303
304 dir(packagesPath, [ 304 dir(packagesPath, [
305 dir('foo', [ 305 dir('foo', [
306 file('foo.dart', 'main() => "foo";') 306 file('foo.dart', 'main() => "foo";')
307 ]) 307 ])
308 ]).scheduleValidate(); 308 ]).scheduleValidate();
309 309
310 git('foo.git', [ 310 git('foo.git', [
311 file('foo.dart', 'main() => "foo 1.0.0";'), 311 libDir('foo', 'foo 1.0.0'),
312 libPubspec("foo", "1.0.0") 312 libPubspec("foo", "1.0.0")
313 ]).scheduleCommit(); 313 ]).scheduleCommit();
314 314
315 appDir([{"git": "../foo.git", "version": ">=1.0.0"}]).scheduleCreate(); 315 appDir([{"git": "../foo.git", "version": ">=1.0.0"}]).scheduleCreate();
316 316
317 schedulePub(args: ['install'], 317 schedulePub(args: ['install'],
318 output: const RegExp(@"Dependencies installed!$")); 318 output: const RegExp(@"Dependencies installed!$"));
319 319
320 dir(packagesPath, [ 320 dir(packagesPath, [
321 dir('foo', [ 321 dir('foo', [
322 file('foo.dart', 'main() => "foo 1.0.0";') 322 file('foo.dart', 'main() => "foo 1.0.0";')
323 ]) 323 ])
324 ]).scheduleValidate(); 324 ]).scheduleValidate();
325 325
326 run(); 326 run();
327 }); 327 });
328 328
329 test("doesn't update a locked Git package with a new compatible " 329 test("doesn't update a locked Git package with a new compatible "
330 "constraint", () { 330 "constraint", () {
331 ensureGit(); 331 ensureGit();
332 332
333 git('foo.git', [ 333 git('foo.git', [
334 file('foo.dart', 'main() => "foo 1.0.0";'), 334 libDir('foo', 'foo 1.0.0'),
335 libPubspec("foo", "1.0.0") 335 libPubspec("foo", "1.0.0")
336 ]).scheduleCreate(); 336 ]).scheduleCreate();
337 337
338 appDir([{"git": "../foo.git"}]).scheduleCreate(); 338 appDir([{"git": "../foo.git"}]).scheduleCreate();
339 339
340 schedulePub(args: ['install'], 340 schedulePub(args: ['install'],
341 output: const RegExp(@"Dependencies installed!$")); 341 output: const RegExp(@"Dependencies installed!$"));
342 342
343 dir(packagesPath, [ 343 dir(packagesPath, [
344 dir('foo', [ 344 dir('foo', [
345 file('foo.dart', 'main() => "foo 1.0.0";') 345 file('foo.dart', 'main() => "foo 1.0.0";')
346 ]) 346 ])
347 ]).scheduleValidate(); 347 ]).scheduleValidate();
348 348
349 git('foo.git', [ 349 git('foo.git', [
350 file('foo.dart', 'main() => "foo 1.0.1";'), 350 libDir('foo', 'foo 1.0.1'),
351 libPubspec("foo", "1.0.1") 351 libPubspec("foo", "1.0.1")
352 ]).scheduleCommit(); 352 ]).scheduleCommit();
353 353
354 appDir([{"git": "../foo.git", "version": ">=1.0.0"}]).scheduleCreate(); 354 appDir([{"git": "../foo.git", "version": ">=1.0.0"}]).scheduleCreate();
355 355
356 schedulePub(args: ['install'], 356 schedulePub(args: ['install'],
357 output: const RegExp(@"Dependencies installed!$")); 357 output: const RegExp(@"Dependencies installed!$"));
358 358
359 dir(packagesPath, [ 359 dir(packagesPath, [
360 dir('foo', [ 360 dir('foo', [
361 file('foo.dart', 'main() => "foo 1.0.0";') 361 file('foo.dart', 'main() => "foo 1.0.0";')
362 ]) 362 ])
363 ]).scheduleValidate(); 363 ]).scheduleValidate();
364 364
365 run(); 365 run();
366 }); 366 });
367 367
368 group("(regression)", () { 368 group("(regression)", () {
369 test('checks out a package from Git with a trailing slash', () { 369 test('checks out a package from Git with a trailing slash', () {
370 ensureGit(); 370 ensureGit();
371 371
372 git('foo.git', [ 372 git('foo.git', [
373 file('foo.dart', 'main() => "foo";') 373 libDir('foo')
374 ]).scheduleCreate(); 374 ]).scheduleCreate();
375 375
376 appDir([{"git": "../foo.git/"}]).scheduleCreate(); 376 appDir([{"git": "../foo.git/"}]).scheduleCreate();
377 377
378 schedulePub(args: ['install'], 378 schedulePub(args: ['install'],
379 output: const RegExp(@"Dependencies installed!$")); 379 output: const RegExp(@"Dependencies installed!$"));
380 380
381 dir(cachePath, [ 381 dir(cachePath, [
382 dir('git', [ 382 dir('git', [
383 dir('cache', [gitPackageRepoCacheDir('foo')]), 383 dir('cache', [gitPackageRepoCacheDir('foo')]),
384 gitPackageRevisionCacheDir('foo') 384 gitPackageRevisionCacheDir('foo')
385 ]) 385 ])
386 ]).scheduleValidate(); 386 ]).scheduleValidate();
387 387
388 dir(packagesPath, [ 388 dir(packagesPath, [
389 dir('foo', [ 389 dir('foo', [
390 file('foo.dart', 'main() => "foo";') 390 file('foo.dart', 'main() => "foo";')
391 ]) 391 ])
392 ]).scheduleValidate(); 392 ]).scheduleValidate();
393 393
394 run(); 394 run();
395 }); 395 });
396 }); 396 });
397 } 397 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698