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 'package:path/path.dart' as p; | 7 import 'package:path/path.dart' as p; |
8 import 'package:scheduled_test/scheduled_test.dart'; | 8 import 'package:scheduled_test/scheduled_test.dart'; |
9 | 9 |
10 import '../../../lib/src/io.dart'; | 10 import '../../../lib/src/io.dart'; |
11 import '../../descriptor.dart' as d; | 11 import '../../descriptor.dart' as d; |
12 import '../../test_pub.dart'; | 12 import '../../test_pub.dart'; |
13 | 13 |
14 main() { | 14 main() { |
15 initConfig(); | 15 initConfig(); |
16 // Regression test for issue 20947. | 16 // Regression test for issue 20947. |
17 integration('checks out an unfetched and locked revision of a cached ' | 17 integration( |
18 'repository', () { | 18 'checks out an unfetched and locked revision of a cached ' 'repository', |
| 19 () { |
19 ensureGit(); | 20 ensureGit(); |
20 | 21 |
21 // In order to get a lockfile that refers to a newer revision than is in the | 22 // In order to get a lockfile that refers to a newer revision than is in the |
22 // cache, we'll switch between two caches. First we ensure that the repo is | 23 // cache, we'll switch between two caches. First we ensure that the repo is |
23 // in the first cache. | 24 // in the first cache. |
24 d.git('foo.git', [ | 25 d.git('foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create(); |
25 d.libDir('foo'), | |
26 d.libPubspec('foo', '1.0.0') | |
27 ]).create(); | |
28 | 26 |
29 d.appDir({"foo": {"git": "../foo.git"}}).create(); | 27 d.appDir({ |
| 28 "foo": { |
| 29 "git": "../foo.git" |
| 30 } |
| 31 }).create(); |
30 | 32 |
31 pubGet(); | 33 pubGet(); |
32 | 34 |
33 // Switch to a new cache. | 35 // Switch to a new cache. |
34 schedule(() => renameDir( | 36 schedule( |
35 p.join(sandboxDir, cachePath), p.join(sandboxDir, "$cachePath.old"))); | 37 () => |
| 38 renameDir(p.join(sandboxDir, cachePath), p.join(sandboxDir, "$cacheP
ath.old"))); |
36 | 39 |
37 // Make the lockfile point to a new revision of the git repository. | 40 // Make the lockfile point to a new revision of the git repository. |
38 d.git('foo.git', [ | 41 d.git( |
39 d.libDir('foo', 'foo 2'), | 42 'foo.git', |
40 d.libPubspec('foo', '1.0.0') | 43 [d.libDir('foo', 'foo 2'), d.libPubspec('foo', '1.0.0')]).commit(); |
41 ]).commit(); | |
42 | 44 |
43 pubUpgrade(output: contains("Changed 1 dependency!")); | 45 pubUpgrade(output: contains("Changed 1 dependency!")); |
44 | 46 |
45 // Switch back to the old cache. | 47 // Switch back to the old cache. |
46 schedule(() { | 48 schedule(() { |
47 var cacheDir = p.join(sandboxDir, cachePath); | 49 var cacheDir = p.join(sandboxDir, cachePath); |
48 deleteEntry(cacheDir); | 50 deleteEntry(cacheDir); |
49 renameDir(p.join(sandboxDir, "$cachePath.old"), cacheDir); | 51 renameDir(p.join(sandboxDir, "$cachePath.old"), cacheDir); |
50 }); | 52 }); |
51 | 53 |
52 // Get the updated version of the git dependency based on the lockfile. | 54 // Get the updated version of the git dependency based on the lockfile. |
53 pubGet(); | 55 pubGet(); |
54 | 56 |
55 d.dir(cachePath, [ | 57 d.dir( |
56 d.dir('git', [ | 58 cachePath, |
57 d.dir('cache', [d.gitPackageRepoCacheDir('foo')]), | 59 [ |
58 d.gitPackageRevisionCacheDir('foo'), | 60 d.dir( |
59 d.gitPackageRevisionCacheDir('foo', 2) | 61 'git', |
60 ]) | 62 [ |
61 ]).validate(); | 63 d.dir('cache', [d.gitPackageRepoCacheDir('foo')]), |
| 64 d.gitPackageRevisionCacheDir('foo'), |
| 65 d.gitPackageRevisionCacheDir('foo', 2)])]).validate(); |
62 | 66 |
63 d.dir(packagesPath, [ | 67 d.dir( |
64 d.dir('foo', [ | 68 packagesPath, |
65 d.file('foo.dart', 'main() => "foo 2";') | 69 [d.dir('foo', [d.file('foo.dart', 'main() => "foo 2";')])]).validate(); |
66 ]) | |
67 ]).validate(); | |
68 }); | 70 }); |
69 } | 71 } |
OLD | NEW |