Created
August 28, 2014 08:35
-
-
Save jbialobr/3148d90ff556dba603cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void CanConcurrentlyDeleteFilesWhileStatusIsBeingCalculated() | |
{ | |
string repoPath = InitNewRepository(); | |
using (var repo = new Repository(repoPath)) | |
{ | |
var paths = new List<string>(); | |
const int numberOfFiles = 3000; | |
for (var i = 0; i < numberOfFiles; i++) | |
{ | |
string s = i.ToString(CultureInfo.InvariantCulture); | |
string path = Path.Combine(repo.Info.WorkingDirectory, s + ".txt"); | |
File.AppendAllText(path, s); | |
repo.Index.Stage(path); | |
paths.Add(path); | |
} | |
bool deletionDone = false; | |
Assert.Equal(0, repo.Index.RetrieveStatus().Missing.Count()); | |
Task task = Task.Factory.StartNew(() => | |
{ | |
var loops = 0; | |
while (!deletionDone) | |
{ | |
var filePaths = repo.Index.RetrieveStatus().Where(entry => entry.State != FileStatus.Ignored).ToArray(); | |
Assert.NotNull(filePaths); | |
loops++; | |
} | |
}); | |
foreach (var path in paths) | |
{ | |
File.Delete(path); | |
} | |
deletionDone = true; | |
task.Wait(); | |
Assert.True(loops > 0); | |
Assert.Equal(numberOfFiles, repo.Index.RetrieveStatus().Missing.Count()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment