| Index: sdk/lib/_internal/pub_generated/test/get/git/check_out_unfetched_revision_of_cached_repo_test.dart
|
| diff --git a/sdk/lib/_internal/pub_generated/test/get/git/check_out_and_upgrade_test.dart b/sdk/lib/_internal/pub_generated/test/get/git/check_out_unfetched_revision_of_cached_repo_test.dart
|
| similarity index 55%
|
| copy from sdk/lib/_internal/pub_generated/test/get/git/check_out_and_upgrade_test.dart
|
| copy to sdk/lib/_internal/pub_generated/test/get/git/check_out_unfetched_revision_of_cached_repo_test.dart
|
| index 99366642bac835a7ea66c896beca5681eea36a59..277f2d189a60934f6ddb077085ed2314dce494be 100644
|
| --- a/sdk/lib/_internal/pub_generated/test/get/git/check_out_and_upgrade_test.dart
|
| +++ b/sdk/lib/_internal/pub_generated/test/get/git/check_out_unfetched_revision_of_cached_repo_test.dart
|
| @@ -4,16 +4,24 @@
|
|
|
| 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')]).create();
|
|
|
| d.appDir({
|
| @@ -24,27 +32,28 @@ 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')]).commit();
|
|
|
| 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,
|
| [
|
|
|