public void EditFileReadFileAndCheckoutConflict() { // editFilePath was changed on ConflictTargetBranch string editFilePath = Path.Combine("Test_ConflictTests", "ModifiedFiles", "ChangeInTarget.txt"); // readFilePath has different contents on ConflictSourceBranch and ConflictTargetBranch string readFilePath = Path.Combine("Test_ConflictTests", "ModifiedFiles", "ChangeInSource.txt"); this.ControlGitRepo.Fetch(GitRepoTests.ConflictSourceBranch); this.ControlGitRepo.Fetch(GitRepoTests.ConflictTargetBranch); this.ValidateGitCommand("checkout " + GitRepoTests.ConflictSourceBranch); this.EditFile("New content", editFilePath); this.FileContentsShouldMatch(readFilePath); string originalReadFileContents = this.Enlistment.GetVirtualPathTo(readFilePath).ShouldBeAFile(this.FileSystem).WithContents(); // This checkout will hit a conflict due to the changes in editFilePath this.ValidateGitCommand("checkout " + GitRepoTests.ConflictTargetBranch); this.FileContentsShouldMatch(readFilePath); this.FileContentsShouldMatch(editFilePath); // The contents of originalReadFileContents should not have changed this.Enlistment.GetVirtualPathTo(readFilePath).ShouldBeAFile(this.FileSystem).WithContents(originalReadFileContents); this.ValidateGitCommand("checkout -- " + editFilePath.Replace('\\', '/')); this.ValidateGitCommand("checkout " + GitRepoTests.ConflictTargetBranch); this.FileContentsShouldMatch(readFilePath); this.FileContentsShouldMatch(editFilePath); this.Enlistment.GetVirtualPathTo(readFilePath).ShouldBeAFile(this.FileSystem).WithContents().ShouldNotEqual(originalReadFileContents); GSDHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.FileSystem, Path.GetFileName(readFilePath)); }
public void ReadingFileDoesNotUpdateIndexOrModifiedPaths() { string gitFileToCheck = "GVFS/GVFS.FunctionalTests/Category/CategoryConstants.cs"; string virtualFile = this.Enlistment.GetVirtualPathTo(gitFileToCheck); ProcessResult initialResult = GitProcess.InvokeProcess(this.Enlistment.RepoRoot, "ls-files --debug -svmodc " + gitFileToCheck); initialResult.ShouldNotBeNull(); initialResult.Output.ShouldNotBeNull(); initialResult.Output.StartsWith("S ").ShouldEqual(true); initialResult.Output.ShouldContain("ctime: 0:0", "mtime: 0:0", "size: 0\t"); using (FileStream fileStreamToRead = File.OpenRead(virtualFile)) { fileStreamToRead.ReadByte(); } this.Enlistment.WaitForBackgroundOperations(); ProcessResult afterUpdateResult = GitProcess.InvokeProcess(this.Enlistment.RepoRoot, "ls-files --debug -svmodc " + gitFileToCheck); afterUpdateResult.ShouldNotBeNull(); afterUpdateResult.Output.ShouldNotBeNull(); afterUpdateResult.Output.StartsWith("S ").ShouldEqual(true); afterUpdateResult.Output.ShouldContain("ctime: 0:0", "mtime: 0:0", "size: 0\t"); GSDHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, gitFileToCheck); }
public void MountCanProcessSavedBackgroundQueueTasks() { string deletedFileEntry = "Test_EPF_WorkingDirectoryTests/1/2/3/4/ReadDeepProjectedFile.cpp"; string deletedDirEntry = "Test_EPF_WorkingDirectoryTests/1/2/3/4/"; GSDHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, deletedFileEntry); GSDHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, deletedDirEntry); this.Enlistment.UnmountGSD(); // 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, GSDTestConfig.DotGSDRoot, "databases", "BackgroundGitOperations.dat"), $"{persistedDeleteFileTask}\r\n{persistedDeleteDirectoryTask}\r\n"); // Background queue should process the delete messages and modifiedPaths should show the change this.Enlistment.MountGSD(); this.Enlistment.WaitForBackgroundOperations(); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, deletedFileEntry); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, deletedDirEntry); }
public void CheckoutBranchWithSymLinks() { GitHelpers.InvokeGitAgainstGSDRepo(this.Enlistment.RepoRoot, "checkout FunctionalTests/20180925_SymLinksPart1"); GitHelpers.CheckGitCommandAgainstGSDRepo( this.Enlistment.RepoRoot, "status", "On branch FunctionalTests/20180925_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"); GSDHelpers.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"); GSDHelpers.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); GSDHelpers.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); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.bashRunner, TestFolderName + "/" + ChildFolderName + "/" + GrandChildLinkName); }
public void HardlinkFromInsideRepoToOutside() { string fileName = "Readme.md"; string fileInsideRepo = this.Enlistment.GetVirtualPathTo(fileName); GSDHelpers.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(); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, fileName); GSDHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, fileNameLink); }
public void CheckoutCommitWhereFileContentsChangeAfterRead() { this.ControlGitRepo.Fetch(GitRepoTests.ConflictSourceBranch); string fileName = "SameChange.txt"; // In commit db95d631e379d366d26d899523f8136a77441914 the initial files for the FunctionalTests/20170206_Conflict_Source branch were created this.ValidateGitCommand("checkout db95d631e379d366d26d899523f8136a77441914"); this.FileContentsShouldMatch("Test_ConflictTests", "ModifiedFiles", fileName); // A read should not add the file to the modified paths GSDHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.FileSystem, fileName); this.ValidateGitCommand("checkout FunctionalTests/20170206_Conflict_Source"); this.FileContentsShouldMatch("Test_ConflictTests", "ModifiedFiles", fileName); GSDHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.FileSystem, fileName); }
public void CheckoutBranchWhereFilesTransitionToSymLinks() { GitHelpers.InvokeGitAgainstGSDRepo(this.Enlistment.RepoRoot, "checkout FunctionalTests/20180925_SymLinksPart3"); GitHelpers.CheckGitCommandAgainstGSDRepo( this.Enlistment.RepoRoot, "status", "On branch FunctionalTests/20180925_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"); GSDHelpers.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); GSDHelpers.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); GSDHelpers.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 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(); GSDHelpers.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(); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, fileName); }
public void CreateFileTest() { string fileName = "file1.txt"; GSDHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, fileName); this.fileSystem.WriteAllText(this.Enlistment.GetVirtualPathTo(fileName), "Some content here"); this.Enlistment.WaitForBackgroundOperations(); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, fileName); this.Enlistment.GetVirtualPathTo(fileName).ShouldBeAFile(this.fileSystem).WithContents("Some content here"); string emptyFileName = "file1empty.txt"; GSDHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, emptyFileName); this.fileSystem.CreateEmptyFile(this.Enlistment.GetVirtualPathTo(emptyFileName)); this.Enlistment.WaitForBackgroundOperations(); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, emptyFileName); this.Enlistment.GetVirtualPathTo(emptyFileName).ShouldBeAFile(this.fileSystem); }
public void CreateFileInFolderTest() { string folderName = "folder2"; string fileName = "file2.txt"; string filePath = Path.Combine(folderName, fileName); this.Enlistment.GetVirtualPathTo(filePath).ShouldNotExistOnDisk(this.fileSystem); GSDHelpers.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(); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, folderName + "/"); GSDHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, folderName + "/" + fileName); }
public void HardlinkExistingFileInRepo() { string fileName = "GVFS/GVFS.Mount/Program.cs"; string fileNameLink = "HardLinkToReadme"; GSDHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, fileName); GSDHelpers.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(); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, fileName); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, fileNameLink); fileInsideRepo.ShouldBeAFile(this.fileSystem); fileLinkInsideRepo.ShouldBeAFile(this.fileSystem); }
public void DeleteFolderAndChangeBranchToFolderWithDifferentCase() { // 692765 - Recursive modified paths entries for folders should be case insensitive when // changing branches string folderName = "GVFlt_MultiThreadTest"; // Confirm that no other test has caused "GVFlt_MultiThreadTest" to be added to the modified paths database GSDHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.FileSystem, folderName); this.FolderShouldHaveCaseMatchingName(folderName); this.DeleteFolder(folderName); // 4141dc6023b853740795db41a06b278ebdee0192 is the commit prior to deleting GVFLT_MultiThreadTest // and re-adding it as as GVFlt_MultiThreadTest this.ValidateGitCommand("checkout 4141dc6023b853740795db41a06b278ebdee0192"); this.FolderShouldHaveCaseMatchingName("GVFLT_MultiThreadTest"); }
public void HardlinkFromOutsideRepoToInside() { string fileName = "OutsideRepoToInside_FileForHardlink.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(); GSDHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, fileName); string fileNameLink = "OutsideRepoToInside_RepoLink.txt"; string fileLinkInsideRepo = this.Enlistment.GetVirtualPathTo(fileNameLink); this.fileSystem.CreateHardLink(fileLinkInsideRepo, fileOutsideRepo); this.Enlistment.WaitForBackgroundOperations(); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, fileNameLink); GSDHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, fileName); fileLinkInsideRepo.ShouldBeAFile(this.fileSystem); }
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(); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, expectedModifiedEntries); GSDHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, folderName + "/"); }
public void CreateHardLinkTest() { string existingFileName = "fileToLinkTo.txt"; string existingFilePath = this.Enlistment.GetVirtualPathTo(existingFileName); GSDHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, existingFileName); this.fileSystem.WriteAllText(existingFilePath, "Some content here"); this.Enlistment.WaitForBackgroundOperations(); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, existingFileName); existingFilePath.ShouldBeAFile(this.fileSystem).WithContents("Some content here"); string newLinkFileName = "newHardLink.txt"; string newLinkFilePath = this.Enlistment.GetVirtualPathTo(newLinkFileName); GSDHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, newLinkFileName); this.fileSystem.CreateHardLink(newLinkFilePath, existingFilePath); this.Enlistment.WaitForBackgroundOperations(); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, newLinkFileName); newLinkFilePath.ShouldBeAFile(this.fileSystem).WithContents("Some content here"); }
public void CaseOnlyRenameOfNewFolderKeepsModifiedPathsEntries() { if (this.fileSystem is PowerShellRunner) { Assert.Ignore("Powershell does not support case only renames."); } this.fileSystem.CreateDirectory(Path.Combine(this.Enlistment.RepoRoot, "Folder")); this.fileSystem.CreateEmptyFile(Path.Combine(this.Enlistment.RepoRoot, "Folder", "testfile")); this.Enlistment.WaitForBackgroundOperations(); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, "Folder/"); GSDHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, "Folder/testfile"); this.fileSystem.RenameDirectory(this.Enlistment.RepoRoot, "Folder", "folder"); this.Enlistment.WaitForBackgroundOperations(); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, "folder/"); GSDHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, "folder/testfile"); }
public void FileMovedFromInsideRepoToOutside() { string fileInsideRepoEntry = "GitCommandsTests/RenameFileTests/1/#test"; string fileNameFullPath = Path.Combine("GitCommandsTests", "RenameFileTests", "1", "#test"); string fileInsideRepo = this.Enlistment.GetVirtualPathTo(fileNameFullPath); GSDHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, fileInsideRepoEntry); string fileNameOutsideRepo = "FileNameOutSideRepo"; string fileMovedOutsideRepo = Path.Combine(this.Enlistment.EnlistmentRoot, fileNameOutsideRepo); GSDHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, fileNameOutsideRepo); this.fileSystem.MoveFile(fileInsideRepo, fileMovedOutsideRepo); fileInsideRepo.ShouldNotExistOnDisk(this.fileSystem); fileMovedOutsideRepo.ShouldBeAFile(this.fileSystem); this.fileSystem.ReadAllText(fileMovedOutsideRepo).ShouldContain("test"); this.Enlistment.WaitForBackgroundOperations(); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, fileInsideRepoEntry); GSDHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, fileNameOutsideRepo); }
public void RenameFolderTest() { string folderName = "folder4a"; string renamedFolderName = "folder4b"; string[] fileNames = { "a", "b", "c" }; string[] expectedModifiedEntries = { renamedFolderName + "/", }; string[] unexpectedModifiedEntries = { renamedFolderName + "/" + fileNames[0], renamedFolderName + "/" + fileNames[1], renamedFolderName + "/" + fileNames[2], folderName + "/", folderName + "/" + fileNames[0], folderName + "/" + fileNames[1], folderName + "/" + fileNames[2], }; this.Enlistment.GetVirtualPathTo(folderName).ShouldNotExistOnDisk(this.fileSystem); this.fileSystem.CreateDirectory(this.Enlistment.GetVirtualPathTo(folderName)); foreach (string fileName in fileNames) { string filePath = Path.Combine(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(); GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, expectedModifiedEntries); GSDHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, unexpectedModifiedEntries); }