diff --git a/GVFS/GVFS.FunctionalTests/Tests/EnlistmentPerFixture/PrefetchVerbTests.cs b/GVFS/GVFS.FunctionalTests/Tests/EnlistmentPerFixture/PrefetchVerbTests.cs index cb0a2a4a6..bcfa9cbd3 100644 --- a/GVFS/GVFS.FunctionalTests/Tests/EnlistmentPerFixture/PrefetchVerbTests.cs +++ b/GVFS/GVFS.FunctionalTests/Tests/EnlistmentPerFixture/PrefetchVerbTests.cs @@ -131,10 +131,13 @@ private void PostFetchJobShouldComplete() string objectDir = this.Enlistment.GetObjectRoot(this.fileSystem); string postFetchLock = Path.Combine(objectDir, "post-fetch.lock"); - while (this.fileSystem.FileExists(postFetchLock)) + // Wait first, to hopefully ensure the background thread has + // started before we check for the lock file. + do { Thread.Sleep(500); } + while (this.fileSystem.FileExists(postFetchLock)); ProcessResult midxResult = GitProcess.InvokeProcess(this.Enlistment.RepoRoot, "midx --read --pack-dir=\"" + objectDir + "/pack\""); midxResult.ExitCode.ShouldEqual(0);