public void RenameFolderTest() { string folderName = "folder4a"; string renamedFolderName = "folder4b"; string[] fileNames = { "a", "b", "c" }; string[] expectedModifiedEntries = { renamedFolderName + "/" + fileNames[0] + Environment.NewLine, renamedFolderName + "/" + fileNames[1] + Environment.NewLine, renamedFolderName + "/" + fileNames[2] + Environment.NewLine, folderName + "/" + fileNames[0] + Environment.NewLine, folderName + "/" + fileNames[1] + Environment.NewLine, folderName + "/" + fileNames[2] + Environment.NewLine, }; this.Enlistment.GetVirtualPathTo(folderName).ShouldNotExistOnDisk(this.fileSystem); this.fileSystem.CreateDirectory(this.Enlistment.GetVirtualPathTo(folderName)); foreach (string fileName in fileNames) { string filePath = folderName + "\\" + fileName; this.fileSystem.CreateEmptyFile(this.Enlistment.GetVirtualPathTo(filePath)); this.Enlistment.GetVirtualPathTo(filePath).ShouldBeAFile(this.fileSystem); } this.fileSystem.MoveDirectory(this.Enlistment.GetVirtualPathTo(folderName), this.Enlistment.GetVirtualPathTo(renamedFolderName)); this.Enlistment.WaitForBackgroundOperations().ShouldEqual(true, "Background operations failed to complete."); GVFSHelpers.ModifiedPathsShouldContain(this.fileSystem, this.Enlistment.DotGVFSRoot, expectedModifiedEntries); }
public void FolderContentsCorrectAfterCreateNewFolderRenameAndCheckoutCommitWithSameFolder() { // 3a55d3b760c87642424e834228a3408796501e7c is the commit prior to adding Test_EPF_MoveRenameFileTests GitProcess.InvokeProcess(this.Enlistment.RepoRoot, "checkout 3a55d3b760c87642424e834228a3408796501e7c"); // Confirm that no other test has created this folder or put it in the modified files string folderName = "Test_EPF_MoveRenameFileTests"; string folder = this.Enlistment.GetVirtualPathTo(folderName); folder.ShouldNotExistOnDisk(this.fileSystem); GVFSHelpers.ModifiedPathsShouldNotContain(this.fileSystem, this.Enlistment.DotGVFSRoot, folderName); // Confirm sparse-checkout picks up renamed folder string newFolder = this.Enlistment.GetVirtualPathTo("newFolder"); this.fileSystem.CreateDirectory(newFolder); this.fileSystem.MoveDirectory(newFolder, folder); this.Enlistment.WaitForBackgroundOperations().ShouldEqual(true, "Background operations failed to complete."); GVFSHelpers.ModifiedPathsShouldContain(this.fileSystem, this.Enlistment.DotGVFSRoot, folderName); // Switch back to this.ControlGitRepo.Commitish and confirm that folder contents are correct GitProcess.InvokeProcess(this.Enlistment.RepoRoot, "checkout " + Properties.Settings.Default.Commitish); folder.ShouldBeADirectory(this.fileSystem); (folder + @"\ChangeNestedUnhydratedFileNameCase\Program.cs").ShouldBeAFile(this.fileSystem).WithContents(MoveRenameFileTests.TestFileContents); (folder + @"\ChangeUnhydratedFileName\Program.cs").ShouldBeAFile(this.fileSystem).WithContents(MoveRenameFileTests.TestFileContents); (folder + @"\MoveUnhydratedFileToDotGitFolder\Program.cs").ShouldBeAFile(this.fileSystem).WithContents(MoveRenameFileTests.TestFileContents); }
public void DeletedFolderAndChildrenAddedToToModifiedPathsFile() { string folderToDelete = "Scripts"; string[] filesToDelete = new string[] { "Scripts/CreateCommonAssemblyVersion.bat", "Scripts/CreateCommonCliAssemblyVersion.bat", "Scripts/CreateCommonVersionHeader.bat", "Scripts/RunFunctionalTests.bat", "Scripts/RunUnitTests.bat" }; // Verify skip-worktree initial set for all files foreach (string file in filesToDelete) { this.VerifyWorktreeBit(file, LsFilesStatus.SkipWorktree); } this.fileSystem.DeleteDirectory(this.Enlistment.GetVirtualPathTo(folderToDelete)); this.Enlistment.WaitForBackgroundOperations(); GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, folderToDelete + "/"); GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, filesToDelete); // Verify skip-worktree cleared foreach (string file in filesToDelete) { this.VerifyWorktreeBit(file, LsFilesStatus.Cached); } }
public void CheckoutBranchWithSymLinks() { GitHelpers.InvokeGitAgainstGVFSRepo(this.Enlistment.RepoRoot, "checkout FunctionalTests/20201014_SymLinksPart1"); GitHelpers.CheckGitCommandAgainstGVFSRepo( this.Enlistment.RepoRoot, "status", "On branch FunctionalTests/20201014_SymLinksPart1", "nothing to commit, working tree clean"); string testFilePath = this.Enlistment.GetVirtualPathTo(Path.Combine(TestFolderName, TestFileName)); testFilePath.ShouldBeAFile(this.bashRunner).WithContents(TestFileContents); this.bashRunner.IsSymbolicLink(testFilePath).ShouldBeFalse($"{testFilePath} should not be a symlink"); GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.bashRunner, TestFolderName + "/" + TestFileName); string testFile2Path = this.Enlistment.GetVirtualPathTo(Path.Combine(TestFolderName, TestFile2Name)); testFile2Path.ShouldBeAFile(this.bashRunner).WithContents(TestFile2Contents); this.bashRunner.IsSymbolicLink(testFile2Path).ShouldBeFalse($"{testFile2Path} should not be a symlink"); GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.bashRunner, TestFolderName + "/" + TestFile2Name); string childLinkPath = this.Enlistment.GetVirtualPathTo(Path.Combine(TestFolderName, ChildLinkName)); this.bashRunner.IsSymbolicLink(childLinkPath).ShouldBeTrue($"{childLinkPath} should be a symlink"); childLinkPath.ShouldBeAFile(this.bashRunner).WithContents(TestFileContents); GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.bashRunner, TestFolderName + "/" + ChildLinkName); string grandChildLinkPath = this.Enlistment.GetVirtualPathTo(Path.Combine(TestFolderName, ChildFolderName, GrandChildLinkName)); this.bashRunner.IsSymbolicLink(grandChildLinkPath).ShouldBeTrue($"{grandChildLinkPath} should be a symlink"); grandChildLinkPath.ShouldBeAFile(this.bashRunner).WithContents(TestFile2Contents); GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.bashRunner, TestFolderName + "/" + ChildFolderName + "/" + GrandChildLinkName); }
public void FolderDehydrateFolderThatIsSubstringOfExistingFolder() { string folderToDehydrate = Path.Combine("GVFS", "GVFS"); string fileToRead = this.Enlistment.GetVirtualPathTo(Path.Combine(folderToDehydrate, "Program.cs")); string fileToWrite = this.Enlistment.GetVirtualPathTo(Path.Combine(folderToDehydrate, "App.config")); this.fileSystem.ReadAllText(fileToRead); this.fileSystem.AppendAllText(this.Enlistment.GetVirtualPathTo(fileToWrite), "Append content"); string folderNotDehydrated = Path.Combine("GVFS", "GVFS.Common"); string fileNotDehydrated = this.Enlistment.GetVirtualPathTo(Path.Combine(folderNotDehydrated, "GVFSLock.cs")); string fileNotDehydrated2 = this.Enlistment.GetVirtualPathTo(Path.Combine(folderNotDehydrated, "Enlistment.cs")); this.fileSystem.ReadAllText(fileNotDehydrated); this.fileSystem.AppendAllText(fileNotDehydrated2, "Append content"); GitProcess.Invoke(this.Enlistment.RepoRoot, $"reset --hard"); this.DehydrateShouldSucceed(new[] { $"{folderToDehydrate} {FolderDehydrateSuccessfulMessage}" }, confirm: true, noStatus: false, foldersToDehydrate: folderToDehydrate); this.PlaceholdersShouldNotContain(folderToDehydrate, Path.Combine(folderToDehydrate, "Program.cs")); GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, Path.Combine(folderToDehydrate, "App.config").Replace(Path.DirectorySeparatorChar, TestConstants.GitPathSeparator)); this.PlaceholdersShouldContain(folderNotDehydrated, Path.Combine(folderNotDehydrated, "GVFSLock.cs")); GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, Path.Combine(folderNotDehydrated, "Enlistment.cs").Replace(Path.DirectorySeparatorChar, TestConstants.GitPathSeparator)); this.Enlistment.UnmountGVFS(); fileToRead.ShouldNotExistOnDisk(this.fileSystem); fileToWrite.ShouldNotExistOnDisk(this.fileSystem); fileNotDehydrated.ShouldBeAFile(this.fileSystem); fileNotDehydrated2.ShouldBeAFile(this.fileSystem); }
public void CreateHardLinkTest() { if (!this.fileSystem.SupportsHardlinkCreation) { return; } string existingFileName = "fileToLinkTo.txt"; string existingFilePath = this.Enlistment.GetVirtualPathTo(existingFileName); GVFSHelpers.ModifiedPathsShouldNotContain(this.fileSystem, this.Enlistment.DotGVFSRoot, existingFileName); this.fileSystem.WriteAllText(existingFilePath, "Some content here"); this.Enlistment.WaitForBackgroundOperations().ShouldEqual(true, "Background operations failed to complete."); GVFSHelpers.ModifiedPathsShouldContain(this.fileSystem, this.Enlistment.DotGVFSRoot, existingFileName); existingFilePath.ShouldBeAFile(this.fileSystem).WithContents("Some content here"); string newLinkFileName = "newHardLink.txt"; string newLinkFilePath = this.Enlistment.GetVirtualPathTo(newLinkFileName); GVFSHelpers.ModifiedPathsShouldNotContain(this.fileSystem, this.Enlistment.DotGVFSRoot, newLinkFileName); this.fileSystem.CreateHardLink(newLinkFilePath, existingFilePath); this.Enlistment.WaitForBackgroundOperations().ShouldEqual(true, "Background operations failed to complete."); GVFSHelpers.ModifiedPathsShouldContain(this.fileSystem, this.Enlistment.DotGVFSRoot, newLinkFileName); newLinkFilePath.ShouldBeAFile(this.fileSystem).WithContents("Some content here"); }
public void FolderDehydrateFolderThatIsSubstringOfExistingFolder() { string folderToDehydrate = Path.Combine("GVFS", "GVFS"); TestPath fileToReadThenDehydrate = new TestPath(this.Enlistment, Path.Combine(folderToDehydrate, "Program.cs")); TestPath fileToWriteThenDehydrate = new TestPath(this.Enlistment, Path.Combine(folderToDehydrate, "App.config")); this.fileSystem.ReadAllText(fileToReadThenDehydrate.VirtualPath); this.fileSystem.AppendAllText(fileToWriteThenDehydrate.VirtualPath, "Append content"); string folderToNotDehydrate = Path.Combine("GVFS", "GVFS.Common"); TestPath fileToReadThenNotDehydrate = new TestPath(this.Enlistment, Path.Combine(folderToNotDehydrate, "GVFSLock.cs")); TestPath fileToWriteThenNotDehydrate = new TestPath(this.Enlistment, Path.Combine(folderToNotDehydrate, "Enlistment.cs")); this.fileSystem.ReadAllText(fileToReadThenNotDehydrate.VirtualPath); this.fileSystem.AppendAllText(fileToWriteThenNotDehydrate.VirtualPath, "Append content"); GitProcess.Invoke(this.Enlistment.RepoRoot, $"reset --hard"); this.DehydrateShouldSucceed(new[] { $"{folderToDehydrate} {FolderDehydrateSuccessfulMessage}" }, confirm: true, noStatus: false, foldersToDehydrate: folderToDehydrate); this.PlaceholdersShouldNotContain(folderToDehydrate, fileToReadThenDehydrate.BasePath); GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, fileToWriteThenDehydrate.BasePath.Replace(Path.DirectorySeparatorChar, TestConstants.GitPathSeparator)); this.PlaceholdersShouldContain(folderToNotDehydrate, fileToReadThenNotDehydrate.BasePath); GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, fileToWriteThenNotDehydrate.BasePath.Replace(Path.DirectorySeparatorChar, TestConstants.GitPathSeparator)); this.Enlistment.UnmountGVFS(); // Use the backing path because on some platforms // the virtual path is no longer accessible after unmounting. fileToReadThenDehydrate.BackingPath.ShouldNotExistOnDisk(this.fileSystem); fileToWriteThenDehydrate.BackingPath.ShouldNotExistOnDisk(this.fileSystem); fileToReadThenNotDehydrate.BackingPath.ShouldBeAFile(this.fileSystem); fileToWriteThenNotDehydrate.BackingPath.ShouldBeAFile(this.fileSystem); }
public void MountCanProcessSavedBackgroundQueueTasks() { string deletedFileEntry = "Test_EPF_WorkingDirectoryTests/1/2/3/4/ReadDeepProjectedFile.cpp"; string deletedDirEntry = "Test_EPF_WorkingDirectoryTests/1/2/3/4/"; GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, deletedFileEntry); GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, deletedDirEntry); this.Enlistment.UnmountGVFS(); // Prime the background queue with delete messages string deleteFilePath = Path.Combine("Test_EPF_WorkingDirectoryTests", "1", "2", "3", "4", "ReadDeepProjectedFile.cpp"); string deleteDirPath = Path.Combine("Test_EPF_WorkingDirectoryTests", "1", "2", "3", "4"); string persistedDeleteFileTask = $"A 1\0{this.fileDeletedBackgroundOperationCode}\0{deleteFilePath}\0"; string persistedDeleteDirectoryTask = $"A 2\0{this.directoryDeletedBackgroundOperationCode}\0{deleteDirPath}\0"; this.fileSystem.WriteAllText( Path.Combine(this.Enlistment.EnlistmentRoot, GVFSTestConfig.DotGVFSRoot, "databases", "BackgroundGitOperations.dat"), $"{persistedDeleteFileTask}\r\n{persistedDeleteDirectoryTask}\r\n"); // Background queue should process the delete messages and modifiedPaths should show the change this.Enlistment.MountGVFS(); this.Enlistment.WaitForBackgroundOperations(); GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, deletedFileEntry); GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, deletedDirEntry); }
public void CaseOnlyRenameOfNewFolderKeepsModifiedPathsEntries() { if (this.fileSystem is PowerShellRunner) { Assert.Ignore("Powershell does not support case only renames."); } string[] expectedModifiedPathsEntriesAfterCreate = { "A Folder/", "A Folder/testfile", }; string[] expectedModifiedPathsEntriesAfterRename = { "A folder/", }; this.fileSystem.CreateDirectory(Path.Combine(this.Enlistment.RepoRoot, "Folder")); this.fileSystem.CreateEmptyFile(Path.Combine(this.Enlistment.RepoRoot, "Folder", "testfile")); this.Enlistment.WaitForBackgroundOperations().ShouldEqual(true, "Background operations failed to complete."); GVFSHelpers.ModifiedPathsShouldContain(this.fileSystem, this.Enlistment.DotGVFSRoot, expectedModifiedPathsEntriesAfterCreate); this.fileSystem.RenameDirectory(this.Enlistment.RepoRoot, "Folder", "folder"); this.Enlistment.WaitForBackgroundOperations().ShouldEqual(true, "Background operations failed to complete."); GVFSHelpers.ModifiedPathsShouldContain(this.fileSystem, this.Enlistment.DotGVFSRoot, expectedModifiedPathsEntriesAfterRename); }
public void LockToPreventUpdate_SingleFile() { string testFile1Contents = "Commit2LockToPreventUpdate \r\n"; string testFile1OldContents = "TestFileLockToPreventUpdate \r\n"; string testFile1Name = "test.txt"; string testFile1Path = this.Enlistment.GetVirtualPathTo(Path.Combine(TestParentFolderName, "LockToPreventUpdate", testFile1Name)); testFile1Path.ShouldBeAFile(this.fileSystem).WithContents(testFile1Contents); using (SafeFileHandle testFile1Handle = this.CreateFile(testFile1Path, FileShare.Read)) { testFile1Handle.IsInvalid.ShouldEqual(false); ProcessResult result = this.InvokeGitAgainstGVFSRepo("checkout " + OldCommitId); result.Errors.ShouldContain( "GVFS was unable to update the following files. To recover, close all handles to the files and run these commands:", "git checkout -- " + TestParentFolderName + "/LockToPreventUpdate/" + testFile1Name); GitHelpers.CheckGitCommandAgainstGVFSRepo( this.Enlistment.RepoRoot, "status", "HEAD detached at " + OldCommitId, "Changes not staged for commit:", TestParentFolderName + "/LockToPreventUpdate/" + testFile1Name); } this.GitCheckoutToDiscardChanges(TestParentFolderName + "/LockToPreventUpdate/" + testFile1Name); this.GitStatusShouldBeClean(OldCommitId); GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, TestParentFolderName + "/LockToPreventUpdate/" + testFile1Name); testFile1Path.ShouldBeAFile(this.fileSystem).WithContents(testFile1OldContents); this.GitCheckoutCommitId(NewFilesAndChangesCommitId); this.GitStatusShouldBeClean(NewFilesAndChangesCommitId); testFile1Path.ShouldBeAFile(this.fileSystem).WithContents(testFile1Contents); }
public void LockWithFullShareUpdateAndDelete() { string testFileUpdate4Contents = "Commit2LockToPreventUpdateAndDelete4 \r\n"; string testFileDelete4Contents = "PreventDelete4 \r\n"; string testFileUpdate4OldContents = "TestFileLockToPreventUpdateAndDelete4 \r\n"; string testFileUpdate4Name = "test4.txt"; string testFileDelete4Name = "test_delete4.txt"; string testFileUpdate4Path = this.Enlistment.GetVirtualPathTo(Path.Combine(TestParentFolderName, "LockToPreventUpdateAndDelete", testFileUpdate4Name)); string testFileDelete4Path = this.Enlistment.GetVirtualPathTo(Path.Combine(TestParentFolderName, "LockToPreventUpdateAndDelete", testFileDelete4Name)); testFileUpdate4Path.ShouldBeAFile(this.fileSystem).WithContents(testFileUpdate4Contents); testFileDelete4Path.ShouldBeAFile(this.fileSystem).WithContents(testFileDelete4Contents); if (this.CanUpdateAndDeletePlaceholdersWithOpenHandles()) { using (FileStream testFileUpdate4 = File.Open(testFileUpdate4Path, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete)) using (FileStream testFileDelete4 = File.Open(testFileDelete4Path, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete)) { this.GitCheckoutCommitId(OldCommitId); this.GitStatusShouldBeClean(OldCommitId); } } else { using (FileStream testFileUpdate4Handle = File.Open(testFileUpdate4Path, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete)) using (FileStream testFileDelete4Handle = File.Open(testFileDelete4Path, FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete)) { ProcessResult checkoutResult = GitProcess.InvokeProcess(this.Enlistment.RepoRoot, "checkout " + OldCommitId); checkoutResult.Errors.ShouldContain( "HEAD is now at " + OldCommitId, "GVFS was unable to update the following files. To recover, close all handles to the files and run these commands:", "git checkout -- Test_EPF_UpdatePlaceholderTests/LockToPreventUpdateAndDelete/test4.txt"); GitHelpers.CheckGitCommandAgainstGVFSRepo( this.Enlistment.RepoRoot, "status", "HEAD detached at " + OldCommitId, "modified: Test_EPF_UpdatePlaceholderTests/LockToPreventUpdateAndDelete/test4.txt", "no changes added to commit (use \"git add\" and/or \"git commit -a\")\n"); } this.GitCheckoutToDiscardChanges(TestParentFolderName + "/LockToPreventUpdateAndDelete/" + testFileUpdate4Name); this.GitStatusShouldBeClean(OldCommitId); GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, TestParentFolderName + "/LockToPreventUpdateAndDelete/" + testFileUpdate4Name); } testFileUpdate4Path.ShouldBeAFile(this.fileSystem).WithContents(testFileUpdate4OldContents); testFileDelete4Path.ShouldNotExistOnDisk(this.fileSystem); this.GitCheckoutCommitId(NewFilesAndChangesCommitId); this.GitStatusShouldBeClean(NewFilesAndChangesCommitId); testFileUpdate4Path.ShouldBeAFile(this.fileSystem).WithContents(testFileUpdate4Contents); testFileDelete4Path.ShouldBeAFile(this.fileSystem).WithContents(testFileDelete4Contents); }
public void CreateFileTest() { string fileName = "file1.txt"; GVFSHelpers.ModifiedPathsShouldNotContain(this.fileSystem, this.Enlistment.DotGVFSRoot, fileName); this.fileSystem.WriteAllText(this.Enlistment.GetVirtualPathTo(fileName), "Some content here"); this.Enlistment.WaitForBackgroundOperations().ShouldEqual(true, "Background operations failed to complete."); this.Enlistment.GetVirtualPathTo(fileName).ShouldBeAFile(this.fileSystem).WithContents("Some content here"); GVFSHelpers.ModifiedPathsShouldContain(this.fileSystem, this.Enlistment.DotGVFSRoot, fileName + Environment.NewLine); }
public void DeletedFileAddedToModifiedPathsFile() { string fileToDeleteEntry = "GVFlt_DeleteFileTest/GVFlt_DeleteFullFileWithoutFileContext_DeleteOnClose/a.txt"; this.VerifyWorktreeBit(fileToDeleteEntry, LsFilesStatus.SkipWorktree); this.fileSystem.DeleteFile(this.Enlistment.GetVirtualPathTo(fileToDeleteEntry)); this.Enlistment.WaitForBackgroundOperations().ShouldEqual(true, "Background operations failed to complete."); GVFSHelpers.ModifiedPathsShouldContain(this.fileSystem, this.Enlistment.DotGVFSRoot, fileToDeleteEntry); // Verify skip-worktree cleared this.VerifyWorktreeBit(fileToDeleteEntry, LsFilesStatus.Cached); }
private void ValidGitStatusWithRetry(string srcPath) { this.Enlistment.WaitForBackgroundOperations(); GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.FileSystem, srcPath); try { this.ValidateGitCommand("status"); } catch (Exception ex) { Thread.Sleep(1000); this.ValidateGitCommand("status"); Assert.Fail("{0} was succesful on the second try, but failed on first: {1}", nameof(this.ValidateGitCommand), ex.Message); } }
public void HardlinkFromInsideRepoToOutside() { string fileName = "Readme.md"; string fileInsideRepo = this.Enlistment.GetVirtualPathTo(fileName); GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, fileName); string fileNameLink = "InsideRepoToOutside_RepoLink.txt"; string fileLinkOutsideRepo = Path.Combine(this.Enlistment.EnlistmentRoot, fileNameLink); this.fileSystem.CreateHardLink(fileLinkOutsideRepo, fileInsideRepo); fileLinkOutsideRepo.ShouldBeAFile(this.fileSystem); this.Enlistment.WaitForBackgroundOperations(); GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, fileName); GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, fileNameLink); }
public void FileRenamedOutOfRepoAddedToModifiedPathsAndSkipWorktreeBitCleared() { string fileToRenameEntry = "GVFlt_MoveFileTest/PartialToOutside/from/lessInFrom.txt"; string fileToRenameVirtualPath = this.Enlistment.GetVirtualPathTo(fileToRenameEntry); this.VerifyWorktreeBit(fileToRenameEntry, LsFilesStatus.SkipWorktree); string fileOutsideRepoPath = Path.Combine(this.Enlistment.EnlistmentRoot, $"{nameof(this.FileRenamedOutOfRepoAddedToModifiedPathsAndSkipWorktreeBitCleared)}.txt"); this.fileSystem.MoveFile(fileToRenameVirtualPath, fileOutsideRepoPath); fileOutsideRepoPath.ShouldBeAFile(this.fileSystem).WithContents("lessData"); this.Enlistment.WaitForBackgroundOperations().ShouldEqual(true, "Background operations failed to complete."); GVFSHelpers.ModifiedPathsShouldContain(this.fileSystem, this.Enlistment.DotGVFSRoot, fileToRenameEntry); // Verify skip-worktree cleared this.VerifyWorktreeBit(fileToRenameEntry, LsFilesStatus.Cached); }
public void RenamedFileAddedToModifiedPathsFile() { string fileToRenameEntry = "Test_EPF_MoveRenameFileTests/ChangeUnhydratedFileName/Program.cs"; string fileToRenameTargetEntry = "Test_EPF_MoveRenameFileTests/ChangeUnhydratedFileName/Program2.cs"; this.VerifyWorktreeBit(fileToRenameEntry, LsFilesStatus.SkipWorktree); this.fileSystem.MoveFile( this.Enlistment.GetVirtualPathTo(fileToRenameEntry), this.Enlistment.GetVirtualPathTo(fileToRenameTargetEntry)); this.Enlistment.WaitForBackgroundOperations().ShouldEqual(true, "Background operations failed to complete."); GVFSHelpers.ModifiedPathsShouldContain(this.fileSystem, this.Enlistment.DotGVFSRoot, fileToRenameEntry); GVFSHelpers.ModifiedPathsShouldContain(this.fileSystem, this.Enlistment.DotGVFSRoot, fileToRenameTargetEntry); // Verify skip-worktree cleared this.VerifyWorktreeBit(fileToRenameEntry, LsFilesStatus.Cached); }
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 CheckoutBranchWhereFilesTransitionToSymLinks() { GitHelpers.InvokeGitAgainstGVFSRepo(this.Enlistment.RepoRoot, "checkout FunctionalTests/20201014_SymLinksPart3"); GitHelpers.CheckGitCommandAgainstGVFSRepo( this.Enlistment.RepoRoot, "status", "On branch FunctionalTests/20201014_SymLinksPart3", "nothing to commit, working tree clean"); // In this branch testFilePath has been changed to point to newGrandChildFilePath string testFilePath = this.Enlistment.GetVirtualPathTo(Path.Combine(TestFolderName, TestFileName)); testFilePath.ShouldBeAFile(this.bashRunner).WithContents(GrandChildFileContents); this.bashRunner.IsSymbolicLink(testFilePath).ShouldBeTrue($"{testFilePath} should be a symlink"); GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.bashRunner, TestFolderName + "/" + TestFileName); // There should be a new ChildFolder2Name directory string childFolder2Path = this.Enlistment.GetVirtualPathTo(Path.Combine(TestFolderName, ChildFolder2Name)); this.bashRunner.IsSymbolicLink(childFolder2Path).ShouldBeFalse($"{childFolder2Path} should not be a symlink"); childFolder2Path.ShouldBeADirectory(this.bashRunner); GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.bashRunner, TestFolderName + "/" + ChildFolder2Name); // The rest of the files are unchanged from FunctionalTests/20180925_SymLinksPart2 string testFile2Path = this.Enlistment.GetVirtualPathTo(Path.Combine(TestFolderName, TestFile2Name)); testFile2Path.ShouldBeAFile(this.bashRunner).WithContents(TestFile2Contents); this.bashRunner.IsSymbolicLink(testFile2Path).ShouldBeFalse($"{testFile2Path} should not be a symlink"); string childLinkPath = this.Enlistment.GetVirtualPathTo(Path.Combine(TestFolderName, ChildLinkName)); this.bashRunner.IsSymbolicLink(childLinkPath).ShouldBeTrue($"{childLinkPath} should be a symlink"); childLinkPath.ShouldBeAFile(this.bashRunner).WithContents(TestFile2Contents); GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.bashRunner, TestFolderName + "/" + ChildLinkName); string grandChildLinkPath = this.Enlistment.GetVirtualPathTo(Path.Combine(TestFolderName, ChildFolderName, GrandChildLinkName)); this.bashRunner.IsSymbolicLink(grandChildLinkPath).ShouldBeFalse($"{grandChildLinkPath} should not be a symlink"); grandChildLinkPath.ShouldBeAFile(this.bashRunner).WithContents(GrandChildLinkNowAFileContents); string newGrandChildFilePath = this.Enlistment.GetVirtualPathTo(Path.Combine(TestFolderName, ChildFolderName, GrandChildFileName)); newGrandChildFilePath.ShouldBeAFile(this.bashRunner).WithContents(GrandChildFileContents); this.bashRunner.IsSymbolicLink(newGrandChildFilePath).ShouldBeFalse($"{newGrandChildFilePath} should not be a symlink"); }
public void CreateFileInFolderTest() { string folderName = "folder2"; string fileName = "file2.txt"; string filePath = Path.Combine(folderName, fileName); this.Enlistment.GetVirtualPathTo(filePath).ShouldNotExistOnDisk(this.fileSystem); GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, filePath); this.fileSystem.CreateDirectory(this.Enlistment.GetVirtualPathTo(folderName)); this.fileSystem.CreateEmptyFile(this.Enlistment.GetVirtualPathTo(filePath)); this.Enlistment.GetVirtualPathTo(filePath).ShouldBeAFile(this.fileSystem); this.Enlistment.WaitForBackgroundOperations(); GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, folderName + "/"); GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, folderName + "/" + fileName); }
public void HardlinkExistingFileInRepo() { string fileName = "GVFS/GVFS.Mount/Program.cs"; string fileNameLink = "HardLinkToReadme"; GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, fileName); GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, fileNameLink); string fileInsideRepo = this.Enlistment.GetVirtualPathTo(fileName); string fileLinkInsideRepo = this.Enlistment.GetVirtualPathTo(fileNameLink); this.fileSystem.CreateHardLink(fileLinkInsideRepo, fileInsideRepo); this.Enlistment.WaitForBackgroundOperations(); GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, fileName); GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, fileNameLink); fileInsideRepo.ShouldBeAFile(this.fileSystem); fileLinkInsideRepo.ShouldBeAFile(this.fileSystem); }
public void CreateFileInFolderTest() { string folderName = "folder2"; string fileName = "file2.txt"; string filePath = folderName + "\\" + fileName; this.Enlistment.GetVirtualPathTo(filePath).ShouldNotExistOnDisk(this.fileSystem); GVFSHelpers.ModifiedPathsShouldNotContain(this.fileSystem, this.Enlistment.DotGVFSRoot, filePath); this.fileSystem.CreateDirectory(this.Enlistment.GetVirtualPathTo(folderName)); this.fileSystem.CreateEmptyFile(this.Enlistment.GetVirtualPathTo(filePath)); this.Enlistment.GetVirtualPathTo(filePath).ShouldBeAFile(this.fileSystem); this.Enlistment.WaitForBackgroundOperations().ShouldEqual(true, "Background operations failed to complete."); GVFSHelpers.ModifiedPathsShouldContain(this.fileSystem, this.Enlistment.DotGVFSRoot, folderName + "/" + Environment.NewLine); GVFSHelpers.ModifiedPathsShouldContain(this.fileSystem, this.Enlistment.DotGVFSRoot, folderName + "/" + fileName + Environment.NewLine); }
public void FileMovedFromOutsideRepoToInside() { string fileName = "OutsideRepoToInside.txt"; string fileOutsideRepo = Path.Combine(this.Enlistment.EnlistmentRoot, fileName); this.fileSystem.WriteAllText(fileOutsideRepo, "Contents for the new file"); fileOutsideRepo.ShouldBeAFile(this.fileSystem); this.Enlistment.WaitForBackgroundOperations(); GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, fileName); string fileMovedInsideRepo = this.Enlistment.GetVirtualPathTo(fileName); this.fileSystem.MoveFile(fileOutsideRepo, fileMovedInsideRepo); fileMovedInsideRepo.ShouldBeAFile(this.fileSystem); fileOutsideRepo.ShouldNotExistOnDisk(this.fileSystem); this.Enlistment.WaitForBackgroundOperations(); GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, fileName); }
public void CreateFileTest() { string fileName = "file1.txt"; GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, fileName); this.fileSystem.WriteAllText(this.Enlistment.GetVirtualPathTo(fileName), "Some content here"); this.Enlistment.WaitForBackgroundOperations(); GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, fileName); this.Enlistment.GetVirtualPathTo(fileName).ShouldBeAFile(this.fileSystem).WithContents("Some content here"); string emptyFileName = "file1empty.txt"; GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, emptyFileName); this.fileSystem.CreateEmptyFile(this.Enlistment.GetVirtualPathTo(emptyFileName)); this.Enlistment.WaitForBackgroundOperations(); GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, emptyFileName); this.Enlistment.GetVirtualPathTo(emptyFileName).ShouldBeAFile(this.fileSystem); }
public void FileRenamedOutOfRepoAddedToSparseCheckoutAndSkipWorktreeBitCleared() { string fileToRenameEntry = "GVFlt_MoveFileTest/PartialToOutside/from/lessInFrom.txt"; string fileToRenameVirtualPath = this.Enlistment.GetVirtualPathTo("GVFlt_MoveFileTest\\PartialToOutside\\from\\lessInFrom.txt"); this.VerifyWorktreeBit(fileToRenameEntry, LsFilesStatus.SkipWorktree); string fileOutsideRepoPath = Path.Combine(this.Enlistment.EnlistmentRoot, "FileRenamedOutOfRepoAddedToSparseCheckoutAndSkipWorktreeBitCleared.txt"); this.fileSystem.MoveFile(fileToRenameVirtualPath, fileOutsideRepoPath); this.Enlistment.WaitForBackgroundOperations().ShouldEqual(true, "Background operations failed to complete."); GVFSHelpers.ModifiedPathsShouldContain(this.fileSystem, this.Enlistment.DotGVFSRoot, fileToRenameEntry + Environment.NewLine); // Verify skip-worktree cleared this.VerifyWorktreeBit(fileToRenameEntry, LsFilesStatus.Cached); }
public void OverwrittenFileAddedToModifiedPathsAndSkipWorktreeBitCleared() { string fileToOverwriteEntry = "Test_EPF_WorkingDirectoryTests/1/2/3/4/ReadDeepProjectedFile.cpp"; string fileToOverwriteVirtualPath = this.Enlistment.GetVirtualPathTo(fileToOverwriteEntry); this.VerifyWorktreeBit(fileToOverwriteEntry, LsFilesStatus.SkipWorktree); string testContents = $"Test contents for {nameof(this.OverwrittenFileAddedToModifiedPathsAndSkipWorktreeBitCleared)}"; this.fileSystem.WriteAllText(fileToOverwriteVirtualPath, testContents); this.Enlistment.WaitForBackgroundOperations().ShouldEqual(true, "Background operations failed to complete."); fileToOverwriteVirtualPath.ShouldBeAFile(this.fileSystem).WithContents(testContents); GVFSHelpers.ModifiedPathsShouldContain(this.fileSystem, this.Enlistment.DotGVFSRoot, fileToOverwriteEntry); // Verify skip-worktree cleared this.VerifyWorktreeBit(fileToOverwriteEntry, LsFilesStatus.Cached); }
public void RenameEmptyFolderTest() { string folderName = "folder3a"; string renamedFolderName = "folder3b"; string[] expectedModifiedEntries = { renamedFolderName + "/", }; this.Enlistment.GetVirtualPathTo(folderName).ShouldNotExistOnDisk(this.fileSystem); this.fileSystem.CreateDirectory(this.Enlistment.GetVirtualPathTo(folderName)); this.fileSystem.MoveDirectory(this.Enlistment.GetVirtualPathTo(folderName), this.Enlistment.GetVirtualPathTo(renamedFolderName)); this.Enlistment.WaitForBackgroundOperations().ShouldEqual(true, "Background operations failed to complete."); GVFSHelpers.ModifiedPathsShouldContain(this.fileSystem, this.Enlistment.DotGVFSRoot, expectedModifiedEntries); }
public void HardlinkInsideRepo() { string fileName = "InsideRepo_FileForHardlink.txt"; string fileInsideRepo = this.Enlistment.GetVirtualPathTo(fileName); this.fileSystem.WriteAllText(fileInsideRepo, "Contents for the new file"); fileInsideRepo.ShouldBeAFile(this.fileSystem); this.Enlistment.WaitForBackgroundOperations(); GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, fileName); string fileNameLink = "InsideRepo_RepoLink.txt"; string fileLinkInsideRepo = this.Enlistment.GetVirtualPathTo(fileNameLink); this.fileSystem.CreateHardLink(fileLinkInsideRepo, fileInsideRepo); this.Enlistment.WaitForBackgroundOperations(); GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, fileName); GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, fileNameLink); fileLinkInsideRepo.ShouldBeAFile(this.fileSystem); }
public void CaseOnlyRenameOfNewFolderKeepsExcludeEntries() { string[] expectedModifiedPathsEntries = { "Folder/", "Folder/testfile", }; this.fileSystem.CreateDirectory(Path.Combine(this.Enlistment.RepoRoot, "Folder")); this.fileSystem.CreateEmptyFile(Path.Combine(this.Enlistment.RepoRoot, "Folder", "testfile")); this.Enlistment.WaitForBackgroundOperations().ShouldEqual(true, "Background operations failed to complete."); GVFSHelpers.ModifiedPathsShouldContain(this.fileSystem, this.Enlistment.DotGVFSRoot, expectedModifiedPathsEntries); this.fileSystem.RenameDirectory(this.Enlistment.RepoRoot, "Folder", "folder"); this.Enlistment.WaitForBackgroundOperations().ShouldEqual(true, "Background operations failed to complete."); GVFSHelpers.ModifiedPathsShouldContain(this.fileSystem, this.Enlistment.DotGVFSRoot, expectedModifiedPathsEntries); }
public void OverwrittenFileAddedToSparseCheckoutAndSkipWorktreeBitCleared() { string fileToOverwriteEntry = "Test_EPF_WorkingDirectoryTests/1/2/3/4/ReadDeepProjectedFile.cpp"; string fileToOverwriteVirtualPath = this.Enlistment.GetVirtualPathTo("Test_EPF_WorkingDirectoryTests\\1\\2\\3\\4\\ReadDeepProjectedFile.cpp"); this.VerifyWorktreeBit(fileToOverwriteEntry, LsFilesStatus.SkipWorktree); string testContents = "Test contents for FileRenamedOutOfRepoWillBeAddedToSparseCheckoutAndHaveSkipWorktreeBitCleared"; this.fileSystem.WriteAllText(fileToOverwriteVirtualPath, testContents); this.Enlistment.WaitForBackgroundOperations().ShouldEqual(true, "Background operations failed to complete."); fileToOverwriteVirtualPath.ShouldBeAFile(this.fileSystem).WithContents(testContents); GVFSHelpers.ModifiedPathsShouldContain(this.fileSystem, this.Enlistment.DotGVFSRoot, fileToOverwriteEntry + Environment.NewLine); // Verify skip-worktree cleared this.VerifyWorktreeBit(fileToOverwriteEntry, LsFilesStatus.Cached); }