From 42a399121a47bb07862afcbd6acdbe1a58621ef4 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Wed, 26 Sep 2018 12:55:14 -0400 Subject: [PATCH] Fix a flaky test involving the background prefetch thread --- .../Tests/EnlistmentPerFixture/PrefetchVerbTests.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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);