Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SecondCloneSucceedsWithMissingTrees: Attempt 2 #336

Merged
merged 2 commits into from
Oct 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class SharedCacheTests : TestsWithMultiEnlistment

// This branch and commit sha should point to the same place.
private const string WellKnownBranch = "FunctionalTests/20170602";
private const string WellKnownCommitSha = "79dc4233df4d9a7e053662bff95df498f640022e";
private const string WellKnownCommitSha = "42eb6632beffae26893a3d6e1a9f48d652327c6f";

private string localCachePath;
private string localCacheParentPath;
Expand Down Expand Up @@ -268,6 +268,25 @@ public void MountUsesNewLocalCacheKeyWhenLocalCacheDeleted()
this.AlternatesFileShouldHaveGitObjectsRoot(enlistment);
}

[TestCase]
public void SecondCloneSucceedsWithMissingTrees()
{
string newCachePath = Path.Combine(this.localCacheParentPath, ".customGvfsCache2");
GVFSFunctionalTestEnlistment enlistment1 = this.CreateNewEnlistment(localCacheRoot: newCachePath, skipPrefetch: true);
File.ReadAllText(Path.Combine(enlistment1.RepoRoot, WellKnownFile));
this.AlternatesFileShouldHaveGitObjectsRoot(enlistment1);

// This Git command loads the commit and root tree for WellKnownCommitSha,
// but does not download any more reachable objects.
string command = "cat-file -p origin/" + WellKnownBranch + "^{tree}";
ProcessResult result = GitHelpers.InvokeGitAgainstGVFSRepo(enlistment1.RepoRoot, command);
result.ExitCode.ShouldEqual(0, $"git {command} failed with error: " + result.Errors);

// If we did not properly check the failed checkout at this step, then clone will fail during checkout.
GVFSFunctionalTestEnlistment enlistment2 = this.CreateNewEnlistment(localCacheRoot: newCachePath, branch: WellKnownBranch, skipPrefetch: true);
File.ReadAllText(Path.Combine(enlistment2.RepoRoot, WellKnownFile));
}

// Override OnTearDownEnlistmentsDeleted rathern than using [TearDown] as the enlistments need to be unmounted before
// localCacheParentPath can be deleted (as the SQLite blob sizes database cannot be deleted while GVFS is mounted)
protected override void OnTearDownEnlistmentsDeleted()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,16 @@ protected virtual void OnTearDownEnlistmentsDeleted()
{
}

protected GVFSFunctionalTestEnlistment CreateNewEnlistment(string localCacheRoot = null, string branch = null)
protected GVFSFunctionalTestEnlistment CreateNewEnlistment(
string localCacheRoot = null,
string branch = null,
bool skipPrefetch = false)
{
GVFSFunctionalTestEnlistment output = GVFSFunctionalTestEnlistment.CloneAndMount(GVFSTestConfig.PathToGVFS, branch, localCacheRoot);
GVFSFunctionalTestEnlistment output = GVFSFunctionalTestEnlistment.CloneAndMount(
GVFSTestConfig.PathToGVFS,
branch,
localCacheRoot,
skipPrefetch);
this.enlistmentsToDelete.Add(output);
return output;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,14 @@ public static GVFSFunctionalTestEnlistment CloneAndMountWithPerRepoCache(string
return CloneAndMount(pathToGvfs, enlistmentRoot, null, localCache, skipPrefetch);
}

public static GVFSFunctionalTestEnlistment CloneAndMount(string pathToGvfs, string commitish = null, string localCacheRoot = null)
public static GVFSFunctionalTestEnlistment CloneAndMount(
string pathToGvfs,
string commitish = null,
string localCacheRoot = null,
bool skipPrefetch = false)
{
string enlistmentRoot = GVFSFunctionalTestEnlistment.GetUniqueEnlistmentRoot();
return CloneAndMount(pathToGvfs, enlistmentRoot, commitish, localCacheRoot);
return CloneAndMount(pathToGvfs, enlistmentRoot, commitish, localCacheRoot, skipPrefetch);
}

public static GVFSFunctionalTestEnlistment CloneAndMountEnlistmentWithSpacesInPath(string pathToGvfs, string commitish = null)
Expand Down