public void OrphanedGVFSLockIsCleanedUp() { int pid; GitHelpers.AcquireGVFSLock(this.Enlistment, out pid, resetTimeout: 1000, skipReleaseLock: true); while (true) { try { using (Process.GetProcessById(pid)) { } Thread.Sleep(1000); } catch (ArgumentException) { break; } } ProcessResult statusWait = GitHelpers.InvokeGitAgainstGVFSRepo(this.Enlistment.RepoRoot, "status", removeWaitingMessages: false); // There should not be any errors - in particular, there should not be // an error about "Waiting for GVFS.FunctionalTests.LockHolder" statusWait.Errors.ShouldEqual(string.Empty); }
public void GitCommandWaitsWhileAnotherIsRunning() { GitHelpers.AcquireGVFSLock(this.Enlistment, resetTimeout: 3000); ProcessResult statusWait = GitHelpers.InvokeGitAgainstGVFSRepo(this.Enlistment.RepoRoot, "status", cleanErrors: false); statusWait.Errors.ShouldContain("Waiting for 'git hash-object --stdin"); }
private void GitCommandWaitsForLock(string gitWorkingDirectory) { ManualResetEventSlim resetEvent = GitHelpers.AcquireGVFSLock(this.Enlistment, out _, resetTimeout: 3000); ProcessResult statusWait = GitHelpers.InvokeGitAgainstGVFSRepo(gitWorkingDirectory, "status", removeWaitingMessages: false); statusWait.Errors.ShouldContain(ExpectedStatusWaitingText); resetEvent.Set(); this.Enlistment.WaitForBackgroundOperations(); }
public void GitAliasNamedAfterKnownCommandAcquiresLock() { string alias = nameof(this.GitAliasNamedAfterKnownCommandAcquiresLock); GitHelpers.AcquireGVFSLock(this.Enlistment, resetTimeout: 3000); GitHelpers.CheckGitCommandAgainstGVFSRepo(this.Enlistment.RepoRoot, "config --local alias." + alias + " status"); ProcessResult statusWait = GitHelpers.InvokeGitAgainstGVFSRepo(this.Enlistment.RepoRoot, alias, cleanErrors: false); statusWait.Errors.ShouldContain("Waiting for 'git hash-object --stdin"); }
public void GitCommandWaitsWhileAnotherIsRunning() { int pid; GitHelpers.AcquireGVFSLock(this.Enlistment, out pid, resetTimeout: 3000); ProcessResult statusWait = GitHelpers.InvokeGitAgainstGVFSRepo(this.Enlistment.RepoRoot, "status", removeWaitingMessages: false); statusWait.Errors.ShouldContain(ExpectedStatusWaitingText); }
public void GitStatusNoOptionalLocksDoesntHoldLock() { ManualResetEventSlim lockHolder = GitHelpers.AcquireGVFSLock(this.Enlistment, resetTimeout: 3000); ProcessResult statusWait = GitHelpers.InvokeGitAgainstGVFSRepo(this.Enlistment.RepoRoot, "--no-optional-locks status", cleanErrors: false); statusWait.Errors.ShouldBeEmpty(); // Release the lock lockHolder.Set(); }
public void UnmountSkipLock() { ManualResetEventSlim lockHolder = GitHelpers.AcquireGVFSLock(this.Enlistment, out _, Timeout.Infinite, true); using (Process unmountingProcess = this.StartUnmount("--skip-wait-for-lock")) { unmountingProcess.WaitForExit(10000).ShouldEqual(true, "Unmount didn't complete as expected."); } // Signal process holding lock to terminate and release lock. lockHolder.Set(); }
public void GitAliasNamedAfterKnownCommandAcquiresLock() { string alias = nameof(this.GitAliasNamedAfterKnownCommandAcquiresLock); int pid; GitHelpers.AcquireGVFSLock(this.Enlistment, out pid, resetTimeout: 3000); GitHelpers.CheckGitCommandAgainstGVFSRepo(this.Enlistment.RepoRoot, "config --local alias." + alias + " status"); ProcessResult statusWait = GitHelpers.InvokeGitAgainstGVFSRepo(this.Enlistment.RepoRoot, alias, removeWaitingMessages: false); statusWait.Errors.ShouldContain(ExpectedStatusWaitingText); }
public void GitAliasInSubfolderNamedAfterKnownCommandAcquiresLock() { string alias = nameof(this.GitAliasInSubfolderNamedAfterKnownCommandAcquiresLock); GitHelpers.AcquireGVFSLock(this.Enlistment, resetTimeout: 3000); GitHelpers.CheckGitCommandAgainstGVFSRepo(this.Enlistment.RepoRoot, "config --local alias." + alias + " rebase"); ProcessResult statusWait = GitHelpers.InvokeGitAgainstGVFSRepo( Path.Combine(this.Enlistment.RepoRoot, "GVFS"), alias + " origin/FunctionalTests/RebaseTestsSource_20170208", cleanErrors: false); statusWait.Errors.ShouldContain("Waiting for 'git hash-object --stdin"); GitHelpers.CheckGitCommandAgainstGVFSRepo(this.Enlistment.RepoRoot, "rebase --abort"); }
public void UnmountWaitsForLock() { ManualResetEventSlim lockHolder = GitHelpers.AcquireGVFSLock(this.Enlistment, out _); using (Process unmountingProcess = this.StartUnmount()) { unmountingProcess.WaitForExit(3000).ShouldEqual(false, "Unmount completed while lock was acquired."); // Release the lock. lockHolder.Set(); unmountingProcess.WaitForExit(10000).ShouldEqual(true, "Unmount didn't complete as expected."); } }
public void ExternalLockHolderReportedWhenBackgroundTasksArePending() { GitHelpers.AcquireGVFSLock(this.Enlistment, resetTimeout: 3000); // Creating a new file will queue a background task string newFilePath = this.Enlistment.GetVirtualPathTo("ExternalLockHolderReportedWhenBackgroundTasksArePending.txt"); newFilePath.ShouldNotExistOnDisk(this.fileSystem); this.fileSystem.WriteAllText(newFilePath, "New file contents"); ProcessResult statusWait = GitHelpers.InvokeGitAgainstGVFSRepo(this.Enlistment.RepoRoot, "status", cleanErrors: false); // Validate that GVFS still reports that the git command is holding the lock statusWait.Errors.ShouldContain("Waiting for 'git hash-object --stdin"); }
public void GitAliasInSubfolderNamedAfterKnownCommandAcquiresLock() { string alias = nameof(this.GitAliasInSubfolderNamedAfterKnownCommandAcquiresLock); int pid; GitHelpers.AcquireGVFSLock(this.Enlistment, out pid, resetTimeout: AcquireGVFSLockTimeout); GitHelpers.CheckGitCommandAgainstGVFSRepo(this.Enlistment.RepoRoot, "config --local alias." + alias + " rebase"); ProcessResult statusWait = GitHelpers.InvokeGitAgainstGVFSRepo( Path.Combine(this.Enlistment.RepoRoot, "GVFS"), alias + " origin/FunctionalTests/RebaseTestsSource_20170208", removeWaitingMessages: false); statusWait.Errors.ShouldContain(ExpectedStatusWaitingText); GitHelpers.CheckGitCommandAgainstGVFSRepo(this.Enlistment.RepoRoot, "rebase --abort"); }
public void ModifiedFileWillGetAddedToModifiedPathsFile() { string gitFileToTest = "GVFS/GVFS.Common/RetryWrapper.cs"; string fileToCreate = this.Enlistment.GetVirtualPathTo(gitFileToTest); this.VerifyWorktreeBit(gitFileToTest, LsFilesStatus.SkipWorktree); ManualResetEventSlim resetEvent = GitHelpers.AcquireGVFSLock(this.Enlistment, out _); this.fileSystem.WriteAllText(fileToCreate, "Anything can go here"); this.fileSystem.FileExists(fileToCreate).ShouldEqual(true); resetEvent.Set(); this.Enlistment.WaitForBackgroundOperations().ShouldEqual(true, "Background operations did not complete."); GVFSHelpers.ModifiedPathsShouldContain(this.fileSystem, this.Enlistment.DotGVFSRoot, gitFileToTest); this.VerifyWorktreeBit(gitFileToTest, LsFilesStatus.Cached); }
public void ModifiedFileWillGetSkipworktreeBitCleared() { string fileToTest = "GVFS\\GVFS.Common\\RetryWrapper.cs"; string fileToCreate = Path.Combine(this.Enlistment.RepoRoot, fileToTest); string gitFileToTest = fileToTest.Replace('\\', '/'); this.VerifyWorktreeBit(gitFileToTest, LsFilesStatus.SkipWorktree); ManualResetEventSlim resetEvent = GitHelpers.AcquireGVFSLock(this.Enlistment, out _); this.fileSystem.WriteAllText(fileToCreate, "Anything can go here"); this.fileSystem.FileExists(fileToCreate).ShouldEqual(true); resetEvent.Set(); this.Enlistment.WaitForBackgroundOperations().ShouldEqual(true, "Background operations did not complete."); GVFSHelpers.ModifiedPathsShouldContain(this.fileSystem, this.Enlistment.DotGVFSRoot, gitFileToTest + Environment.NewLine); this.VerifyWorktreeBit(gitFileToTest, LsFilesStatus.Cached); }
public void CreatedFileWillGetSkipworktreeBitCleared() { string fileToTest = "GVFS\\GVFS.Common\\RetryWrapper.cs"; string fileToCreate = Path.Combine(this.Enlistment.RepoRoot, fileToTest); string gitFileToTest = fileToTest.Replace('\\', '/'); this.VerifyWorktreeBit(gitFileToTest, LsFilesStatus.SkipWorktree); ManualResetEventSlim resetEvent = GitHelpers.AcquireGVFSLock(this.Enlistment); this.fileSystem.WriteAllText(fileToCreate, "Anything can go here"); this.fileSystem.FileExists(fileToCreate).ShouldEqual(true); resetEvent.Set(); this.Enlistment.WaitForBackgroundOperations().ShouldEqual(true, "Background operations did not complete."); string sparseCheckoutFile = Path.Combine(this.Enlistment.RepoRoot, TestConstants.DotGit.Info.SparseCheckout); sparseCheckoutFile.ShouldBeAFile(this.fileSystem).WithContents().ShouldContain(gitFileToTest); this.VerifyWorktreeBit(gitFileToTest, LsFilesStatus.Cached); }