Index: sdk/lib/_internal/pub/test/get/git/check_out_unfetched_revision_of_cached_repo_test.dart |
diff --git a/sdk/lib/_internal/pub/test/get/git/check_out_and_upgrade_test.dart b/sdk/lib/_internal/pub/test/get/git/check_out_unfetched_revision_of_cached_repo_test.dart |
similarity index 54% |
copy from sdk/lib/_internal/pub/test/get/git/check_out_and_upgrade_test.dart |
copy to sdk/lib/_internal/pub/test/get/git/check_out_unfetched_revision_of_cached_repo_test.dart |
index f2ff3bfeb545c967d8838a4b01996e88cd1972ab..3ebc04cd0dfa0cbb12a4311ebbd0345fe9002622 100644 |
--- a/sdk/lib/_internal/pub/test/get/git/check_out_and_upgrade_test.dart |
+++ b/sdk/lib/_internal/pub/test/get/git/check_out_unfetched_revision_of_cached_repo_test.dart |
@@ -4,16 +4,23 @@ |
library pub_tests; |
+import 'package:path/path.dart' as p; |
import 'package:scheduled_test/scheduled_test.dart'; |
+import '../../../lib/src/io.dart'; |
import '../../descriptor.dart' as d; |
import '../../test_pub.dart'; |
main() { |
initConfig(); |
- integration('checks out and upgrades a package from Git', () { |
+ // Regression test for issue 20947. |
+ integration('checks out an unfetched and locked revision of a cached ' |
+ 'repository', () { |
ensureGit(); |
+ // In order to get a lockfile that refers to a newer revision than is in the |
+ // cache, we'll switch between two caches. First we ensure that the repo is |
+ // in the first cache. |
d.git('foo.git', [ |
d.libDir('foo'), |
d.libPubspec('foo', '1.0.0') |
@@ -23,19 +30,11 @@ main() { |
pubGet(); |
- d.dir(cachePath, [ |
- d.dir('git', [ |
- d.dir('cache', [d.gitPackageRepoCacheDir('foo')]), |
- d.gitPackageRevisionCacheDir('foo') |
- ]) |
- ]).validate(); |
- |
- d.dir(packagesPath, [ |
- d.dir('foo', [ |
- d.file('foo.dart', 'main() => "foo";') |
- ]) |
- ]).validate(); |
+ // Switch to a new cache. |
+ schedule(() => renameDir( |
+ p.join(sandboxDir, cachePath), p.join(sandboxDir, "$cachePath.old"))); |
+ // Make the lockfile point to a new revision of the git repository. |
d.git('foo.git', [ |
d.libDir('foo', 'foo 2'), |
d.libPubspec('foo', '1.0.0') |
@@ -43,8 +42,16 @@ main() { |
pubUpgrade(output: contains("Changed 1 dependency!")); |
- // When we download a new version of the git package, we should re-use the |
- // git/cache directory but create a new git/ directory. |
+ // Switch back to the old cache. |
+ schedule(() { |
+ var cacheDir = p.join(sandboxDir, cachePath); |
+ deleteEntry(cacheDir); |
+ renameDir(p.join(sandboxDir, "$cachePath.old"), cacheDir); |
+ }); |
+ |
+ // Get the updated version of the git dependency based on the lockfile. |
+ pubGet(); |
+ |
d.dir(cachePath, [ |
d.dir('git', [ |
d.dir('cache', [d.gitPackageRepoCacheDir('foo')]), |