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 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(); GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, fileToRenameEntry); GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, fileToRenameTargetEntry); // Verify skip-worktree cleared this.VerifyWorktreeBit(fileToRenameEntry, LsFilesStatus.Cached); }
public void FileMovedFromInsideRepoToOutside() { string fileName = "InsideRepoToOutside.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 fileMovedOutsideRepo = Path.Combine(this.Enlistment.EnlistmentRoot, fileName); this.fileSystem.MoveFile(fileInsideRepo, fileMovedOutsideRepo); fileInsideRepo.ShouldNotExistOnDisk(this.fileSystem); fileMovedOutsideRepo.ShouldBeAFile(this.fileSystem); this.Enlistment.WaitForBackgroundOperations(); GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, fileName); }
public void CreateHardLinkTest() { 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 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(); GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, gitFileToTest); this.VerifyWorktreeBit(gitFileToTest, LsFilesStatus.Cached); }
public void MountingARepositoryThatRequiresPlaceholderUpdatesWorks() { string placeholderRelativePath = Path.Combine("EnumerateAndReadTestFiles", "a.txt"); string placeholderPath = this.Enlistment.GetVirtualPathTo(placeholderRelativePath); // Ensure the placeholder is on disk and hydrated placeholderPath.ShouldBeAFile(this.fileSystem).WithContents(); this.Enlistment.UnmountGVFS(); File.Delete(placeholderPath); GVFSHelpers.DeletePlaceholder( Path.Combine(this.Enlistment.DotGVFSRoot, TestConstants.Databases.VFSForGit), placeholderRelativePath); GVFSHelpers.SetPlaceholderUpdatesRequired(this.Enlistment.DotGVFSRoot, true); this.Enlistment.MountGVFS(); }
public void MountSucceedsIfMinorVersionHasAdvancedButNotMajorVersion() { // Advance the minor version, mount should still work this.Enlistment.UnmountGVFS(); GVFSHelpers.SaveDiskLayoutVersion( this.Enlistment.DotGVFSRoot, GVFSHelpers.GetCurrentDiskLayoutMajorVersion().ToString(), (CurrentDiskLayoutMinorVersion + 1).ToString()); this.Enlistment.TryMountGVFS().ShouldBeTrue("Mount should succeed because only the minor version advanced"); // Advance the major version, mount should fail this.Enlistment.UnmountGVFS(); GVFSHelpers.SaveDiskLayoutVersion( this.Enlistment.DotGVFSRoot, (GVFSHelpers.GetCurrentDiskLayoutMajorVersion() + 1).ToString(), CurrentDiskLayoutMinorVersion.ToString()); this.Enlistment.TryMountGVFS().ShouldBeFalse("Mount should fail because the major version has advanced"); }
public void CheckoutCommitWhereFileDeletedAfterRead() { this.ControlGitRepo.Fetch(GitRepoTests.ConflictSourceBranch); string fileName = "DeleteInSource.txt"; string filePath = Path.Combine("Test_ConflictTests", "DeletedFiles", fileName); // In commit db95d631e379d366d26d899523f8136a77441914 the initial files for the FunctionalTests/20170206_Conflict_Source branch were created this.ValidateGitCommand("checkout db95d631e379d366d26d899523f8136a77441914"); this.FileContentsShouldMatch(filePath); // A read should not add the file to the modified paths GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.FileSystem, fileName); this.ValidateGitCommand("checkout FunctionalTests/20170206_Conflict_Source"); this.ShouldNotExistOnDisk(filePath); GVFSHelpers.ModifiedPathsShouldNotContain(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 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 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 + "/"); GVFSHelpers.ModifiedPathsShouldContain(this.fileSystem, this.Enlistment.DotGVFSRoot, folderName + "/" + fileName); }
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 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 GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.FileSystem, folderName); this.FolderShouldHaveCaseMatchingName(folderName, "GVFlt_MultiThreadTest"); 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(folderName, "GVFLT_MultiThreadTest"); }
public void MountWritesFolderPlaceholdersToPlaceholderDatabase() { // Create some placeholder data this.fileSystem.ReadAllText(Path.Combine(this.Enlistment.RepoRoot, "Readme.md")); this.fileSystem.ReadAllText(Path.Combine(this.Enlistment.RepoRoot, "Scripts\\RunUnitTests.bat")); this.fileSystem.ReadAllText(Path.Combine(this.Enlistment.RepoRoot, "GVFS\\GVFS.Common\\Git\\GitRefs.cs")); // Create a full folder this.fileSystem.CreateDirectory(Path.Combine(this.Enlistment.RepoRoot, "GVFS\\FullFolder")); this.fileSystem.WriteAllText(Path.Combine(this.Enlistment.RepoRoot, "GVFS\\FullFolder\\test.txt"), "Test contents"); // Create a tombstone this.fileSystem.DeleteDirectory(Path.Combine(this.Enlistment.RepoRoot, "GVFS\\GVFS.Tests\\Properties")); string junctionTarget = Path.Combine(this.Enlistment.EnlistmentRoot, "DirJunction"); string symlinkTarget = Path.Combine(this.Enlistment.EnlistmentRoot, "DirSymlink"); Directory.CreateDirectory(junctionTarget); Directory.CreateDirectory(symlinkTarget); string junctionLink = Path.Combine(this.Enlistment.RepoRoot, "DirJunction"); string symlink = Path.Combine(this.Enlistment.RepoRoot, "DirLink"); ProcessHelper.Run("CMD.exe", "/C mklink /J " + junctionLink + " " + junctionTarget); ProcessHelper.Run("CMD.exe", "/C mklink /D " + symlink + " " + symlinkTarget); this.Enlistment.UnmountGVFS(); // Delete the existing folder placeholder data string placeholderDatabasePath = Path.Combine(this.Enlistment.DotGVFSRoot, GVFSHelpers.PlaceholderListFile); string[] lines = this.GetPlaceholderDatabaseLinesBeforeUpgrade(placeholderDatabasePath); // Placeholder database file should only have file placeholders this.fileSystem.WriteAllText(placeholderDatabasePath, string.Join(Environment.NewLine, lines.Where(x => !x.EndsWith(TestConstants.AllZeroSha))) + Environment.NewLine); GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, "12", "1"); this.Enlistment.MountGVFS(); this.Enlistment.UnmountGVFS(); // Validate the folder placeholders are in the placeholder database now this.GetPlaceholderDatabaseLinesAfterUpgrade(placeholderDatabasePath); }
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 RenamedFileAndOverwrittenTargetAddedToModifiedPathsFile() { string fileToRenameEntry = "Test_EPF_MoveRenameFileTests_2/MoveUnhydratedFileToOverwriteUnhydratedFileAndWrite/RunUnitTests.bat"; string fileToRenameTargetEntry = "Test_EPF_MoveRenameFileTests_2/MoveUnhydratedFileToOverwriteUnhydratedFileAndWrite/RunFunctionalTests.bat"; this.VerifyWorktreeBit(fileToRenameEntry, LsFilesStatus.SkipWorktree); this.VerifyWorktreeBit(fileToRenameTargetEntry, LsFilesStatus.SkipWorktree); this.fileSystem.ReplaceFile( 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); this.VerifyWorktreeBit(fileToRenameTargetEntry, LsFilesStatus.Cached); }
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 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().ShouldEqual(true, "Background operations failed to complete."); GVFSHelpers.ModifiedPathsShouldContain(this.fileSystem, this.Enlistment.DotGVFSRoot, "Folder/"); 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, "folder/"); GVFSHelpers.ModifiedPathsShouldNotContain(this.fileSystem, this.Enlistment.DotGVFSRoot, "folder/testfile"); }
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); }
public void MountFailsToUpgradeFromEsentVersion6ToJsonRepoMetadata() { this.Enlistment.UnmountGVFS(); // Delete the existing repo metadata string versionJsonPath = Path.Combine(this.Enlistment.DotGVFSRoot, GVFSHelpers.RepoMetadataName); versionJsonPath.ShouldBeAFile(this.fileSystem); this.fileSystem.DeleteFile(versionJsonPath); GVFSHelpers.SaveDiskLayoutVersionAsEsentDatabase(this.Enlistment.DotGVFSRoot, "6"); string esentDatabasePath = Path.Combine(this.Enlistment.DotGVFSRoot, GVFSHelpers.EsentRepoMetadataFolder); esentDatabasePath.ShouldBeADirectory(this.fileSystem); this.Enlistment.TryMountGVFS().ShouldEqual(false, "Should not be able to upgrade from version 6"); esentDatabasePath.ShouldBeADirectory(this.fileSystem); }
public void MountFailsUpgradingFromInvalidUpgradePath(string mountSubfolder) { MountSubfolders.EnsureSubfoldersOnDisk(this.Enlistment, this.fileSystem); string headCommitId = GitProcess.Invoke(this.Enlistment.RepoRoot, "rev-parse HEAD"); this.Enlistment.UnmountGVFS(); string currentVersion = GVFSHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGVFSRoot).ShouldNotBeNull(); int currentVersionNum; int.TryParse(currentVersion, out currentVersionNum).ShouldEqual(true); // 1 will always be below the minumum support version number GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, "1"); this.MountShouldFail("Breaking change to GVFS disk layout has been made since cloning", this.Enlistment.GetVirtualPathTo(mountSubfolder)); GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, currentVersionNum.ToString()); this.Enlistment.MountGVFS(); }
public void RepairFixesCorruptBlobSizesDatabase() { GVFSFunctionalTestEnlistment enlistment = this.CloneAndMountEnlistment(); enlistment.UnmountGVFS(); // Repair on a healthy enlistment should succeed enlistment.Repair(); string blobSizesRoot = GVFSHelpers.GetPersistedBlobSizesRoot(enlistment.DotGVFSRoot).ShouldNotBeNull(); string blobSizesDbPath = Path.Combine(blobSizesRoot, "BlobSizes.sql"); blobSizesDbPath.ShouldBeAFile(this.fileSystem); this.fileSystem.WriteAllText(blobSizesDbPath, "0000"); enlistment.TryMountGVFS().ShouldEqual(false, "GVFS shouldn't mount when blob size db is corrupt"); enlistment.Repair(); enlistment.MountGVFS(); }
public void SupersededFileAddedToModifiedPathsAndSkipWorktreeBitCleared() { string fileToSupersedeEntry = "GVFlt_FileOperationTest/WriteAndVerify.txt"; string fileToSupersedePath = this.Enlistment.GetVirtualPathTo("GVFlt_FileOperationTest\\WriteAndVerify.txt"); this.VerifyWorktreeBit(fileToSupersedeEntry, LsFilesStatus.SkipWorktree); string newContent = $"{nameof(this.SupersededFileAddedToModifiedPathsAndSkipWorktreeBitCleared)} test new contents"; SupersedeFile(fileToSupersedePath, newContent).ShouldEqual(true); this.Enlistment.WaitForBackgroundOperations().ShouldEqual(true, "Background operations failed to complete."); GVFSHelpers.ModifiedPathsShouldContain(this.fileSystem, this.Enlistment.DotGVFSRoot, fileToSupersedeEntry); // Verify skip-worktree cleared this.VerifyWorktreeBit(fileToSupersedeEntry, LsFilesStatus.Cached); // Verify new content written fileToSupersedePath.ShouldBeAFile(this.fileSystem).WithContents(newContent); }
public void DehydrateShouldFailOnWrongDiskLayoutVersion() { this.Enlistment.UnmountGVFS(); string currentVersion = GVFSHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGVFSRoot).ShouldNotBeNull(); int currentVersionNum; int.TryParse(currentVersion, out currentVersionNum).ShouldEqual(true); GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, (currentVersionNum - 1).ToString()); this.DehydrateShouldFail("disk layout version doesn't match current version", noStatus: true); GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, (currentVersionNum + 1).ToString()); this.DehydrateShouldFail("Changes to GVFS disk layout do not allow mounting after downgrade.", noStatus: true); GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, currentVersionNum.ToString()); this.Enlistment.MountGVFS(); }
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 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(); GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, fileToRenameEntry); // Verify skip-worktree cleared this.VerifyWorktreeBit(fileToRenameEntry, LsFilesStatus.Cached); }
public void CheckoutBranchWhereSymLinksChangeContentsAndTransitionToFile() { GitHelpers.InvokeGitAgainstGVFSRepo(this.Enlistment.RepoRoot, "checkout FunctionalTests/20201014_SymLinksPart2"); GitHelpers.CheckGitCommandAgainstGVFSRepo( this.Enlistment.RepoRoot, "status", "On branch FunctionalTests/20201014_SymLinksPart2", "nothing to commit, working tree clean"); // testFilePath and testFile2Path are unchanged from FunctionalTests/20180925_SymLinksPart2 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); // In this branch childLinkPath has been changed to point to testFile2Path 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); // grandChildLinkPath should now be a file 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); // There should also be a new file in the child folder 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"); GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.bashRunner, TestFolderName + "/" + ChildFolderName + "/" + GrandChildFileName); }
public void AppendToHydratedFileAfterRemount() { string fileToAppendEntry = "Test_EPF_WorkingDirectoryTests/WriteToHydratedFileAfterRemount.cpp"; string virtualFilePath = this.Enlistment.GetVirtualPathTo(fileToAppendEntry); string fileContents = virtualFilePath.ShouldBeAFile(this.fileSystem).WithContents(); this.Enlistment.WaitForBackgroundOperations(); GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, fileToAppendEntry); // Remount this.Enlistment.UnmountGVFS(); this.Enlistment.MountGVFS(); string appendedText = "Text to append"; this.fileSystem.AppendAllText(virtualFilePath, appendedText); this.Enlistment.WaitForBackgroundOperations(); GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, fileToAppendEntry); virtualFilePath.ShouldBeAFile(this.fileSystem).WithContents(fileContents + appendedText); }
public void RenamedFileAddedToSparseCheckoutAndSkipWorktreeBitCleared() { string fileToRenameEntry = "Test_EPF_MoveRenameFileTests/ChangeUnhydratedFileName/Program.cs"; string fileToRenameTargetEntry = "Test_EPF_MoveRenameFileTests/ChangeUnhydratedFileName/Program2.cs"; string fileToRenameRelativePath = "Test_EPF_MoveRenameFileTests\\ChangeUnhydratedFileName\\Program.cs"; string fileToRenameTargetRelativePath = "Test_EPF_MoveRenameFileTests\\ChangeUnhydratedFileName\\Program2.cs"; this.VerifyWorktreeBit(fileToRenameEntry, LsFilesStatus.SkipWorktree); this.fileSystem.MoveFile( this.Enlistment.GetVirtualPathTo(fileToRenameRelativePath), this.Enlistment.GetVirtualPathTo(fileToRenameTargetRelativePath)); this.Enlistment.WaitForBackgroundOperations().ShouldEqual(true, "Background operations failed to complete."); GVFSHelpers.ModifiedPathsShouldContain(this.fileSystem, this.Enlistment.DotGVFSRoot, fileToRenameEntry + Environment.NewLine); GVFSHelpers.ModifiedPathsShouldContain(this.fileSystem, this.Enlistment.DotGVFSRoot, fileToRenameTargetEntry + Environment.NewLine); // Verify skip-worktree cleared this.VerifyWorktreeBit(fileToRenameEntry, LsFilesStatus.Cached); }
public void MountUsesNewLocalCacheKeyWhenLocalCacheDeleted() { GVFSFunctionalTestEnlistment enlistment = this.CloneAndMountEnlistment(); enlistment.UnmountGVFS(); // Find the current git objects root and ensure it's on disk string objectsRoot = GVFSHelpers.GetPersistedGitObjectsRoot(enlistment.DotGVFSRoot).ShouldNotBeNull(); objectsRoot.ShouldBeADirectory(this.fileSystem); string mappingFilePath = Path.Combine(enlistment.LocalCacheRoot, "mapping.dat"); string mappingFileContents = this.fileSystem.ReadAllText(mappingFilePath); mappingFileContents.Length.ShouldNotEqual(0, "mapping.dat should not be empty"); // Delete the local cache folder, mount should re-create it and generate a new mapping file and local cache key this.DeleteDirectoryWithUnlimitedRetries(enlistment.LocalCacheRoot); enlistment.MountGVFS(); // Mount should recreate the local cache root enlistment.LocalCacheRoot.ShouldBeADirectory(this.fileSystem); // Determine the new local cache key string newMappingFileContents = mappingFilePath.ShouldBeAFile(this.fileSystem).WithContents(); const int GuidStringLength = 32; string mappingFileKey = "A {\"Key\":\"https://gvfs.visualstudio.com/ci/_git/fortests\",\"Value\":\""; int localKeyIndex = newMappingFileContents.IndexOf(mappingFileKey); string newCacheKey = newMappingFileContents.Substring(localKeyIndex + mappingFileKey.Length, GuidStringLength); // Validate the new objects root is on disk and uses the new key objectsRoot.ShouldNotExistOnDisk(this.fileSystem); string newObjectsRoot = GVFSHelpers.GetPersistedGitObjectsRoot(enlistment.DotGVFSRoot); newObjectsRoot.ShouldNotEqual(objectsRoot); newObjectsRoot.ShouldContain(newCacheKey); newObjectsRoot.ShouldBeADirectory(this.fileSystem); this.AlternatesFileShouldHaveGitObjectsRoot(enlistment); }