Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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");

            GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, gitFileToCheck);
        }
Ejemplo n.º 3
0
        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 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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        public void ReadingFileDoesNotUpdateIndexOrSparseCheckout()
        {
            string        gitFileToCheck = "GVFS/GVFS.FunctionalTests/Category/CategoryConstants.cs";
            string        virtualFile    = Path.Combine(this.Enlistment.RepoRoot, gitFileToCheck.Replace('/', '\\'));
            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().ShouldEqual(true, "Background operations did not complete.");

            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");

            GVFSHelpers.ModifiedPathsShouldNotContain(this.fileSystem, this.Enlistment.DotGVFSRoot, gitFileToCheck + Environment.NewLine);
        }
Ejemplo n.º 8
0
        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);

            GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.FileSystem, Path.GetFileName(readFilePath));
        }
Ejemplo n.º 9
0
        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");
        }
Ejemplo n.º 10
0
        public void FolderContentsProjectedAfterFolderCreateAndCheckout()
        {
            string folderName = "GVFlt_MultiThreadTest";

            // 54ea499de78eafb4dfd30b90e0bd4bcec26c4349 did not have the folder GVFlt_MultiThreadTest
            GitProcess.InvokeProcess(this.Enlistment.RepoRoot, "checkout 54ea499de78eafb4dfd30b90e0bd4bcec26c4349");

            // Confirm that no other test has created GVFlt_MultiThreadTest or put it in the modified files
            GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, folderName);

            string virtualFolderPath = this.Enlistment.GetVirtualPathTo(folderName);

            virtualFolderPath.ShouldNotExistOnDisk(this.fileSystem);
            this.fileSystem.CreateDirectory(virtualFolderPath);

            // b3ddcf43b997cba3fbf9d2341b297e22bf48601a was the commit prior to deleting GVFLT_MultiThreadTest
            // 692765: Note that test also validates case insensitivity as GVFlt_MultiThreadTest is named GVFLT_MultiThreadTest
            //         in this commit; on case-sensitive filesystems, case sensitivity is validated instead
            GitProcess.InvokeProcess(this.Enlistment.RepoRoot, "checkout b3ddcf43b997cba3fbf9d2341b297e22bf48601a");

            string testFolderName = FileSystemHelpers.CaseSensitiveFileSystem ? "GVFLT_MultiThreadTest" : folderName;

            this.Enlistment.GetVirtualPathTo(Path.Combine(testFolderName, "OpenForReadsSameTime", "test")).ShouldBeAFile(this.fileSystem).WithContents("123 \r\n");
            this.Enlistment.GetVirtualPathTo(Path.Combine(testFolderName, "OpenForWritesSameTime", "test")).ShouldBeAFile(this.fileSystem).WithContents("123 \r\n");
        }
Ejemplo n.º 11
0
        public void TruncatedObjectRedownloaded()
        {
            GitProcess.InvokeProcess(this.Enlistment.RepoRoot, "checkout " + this.Enlistment.Commitish);
            ProcessResult revParseResult = GitProcess.InvokeProcess(this.Enlistment.RepoRoot, "rev-parse :Test_EPF_WorkingDirectoryTests/TruncatedObjectRedownloaded.txt");
            string        sha            = revParseResult.Output.Trim();

            sha.Length.ShouldEqual(40);
            string objectPath = Path.Combine(this.Enlistment.GetObjectRoot(this.fileSystem), sha.Substring(0, 2), sha.Substring(2, 38));

            objectPath.ShouldNotExistOnDisk(this.fileSystem);

            string corruptObjectFolderPath   = Path.Combine(this.Enlistment.DotGVFSRoot, "CorruptObjects");
            int    initialCorruptObjectCount = 0;

            if (this.fileSystem.DirectoryExists(corruptObjectFolderPath))
            {
                initialCorruptObjectCount = new DirectoryInfo(corruptObjectFolderPath).EnumerateFileSystemInfos().Count();
            }

            // Read a copy of TruncatedObjectRedownloaded.txt to force the object to be downloaded
            GitProcess.InvokeProcess(this.Enlistment.RepoRoot, "rev-parse :Test_EPF_WorkingDirectoryTests/TruncatedObjectRedownloaded_copy.txt").Output.Trim().ShouldEqual(sha);
            string testFileContents = this.Enlistment.GetVirtualPathTo("Test_EPF_WorkingDirectoryTests", "TruncatedObjectRedownloaded_copy.txt").ShouldBeAFile(this.fileSystem).WithContents();

            objectPath.ShouldBeAFile(this.fileSystem);
            string modifedFile = "Test_EPF_WorkingDirectoryTests/TruncatedObjectRedownloaded.txt";

            GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, modifedFile);

            // Truncate the contents of objectPath
            string   tempTruncatedObjectPath = objectPath + "truncated";
            FileInfo objectFileInfo          = new FileInfo(objectPath);
            long     objectLength            = objectFileInfo.Length;

            using (FileStream objectStream = new FileStream(objectPath, FileMode.Open))
                using (FileStream truncatedObjectStream = new FileStream(tempTruncatedObjectPath, FileMode.CreateNew))
                {
                    for (int i = 0; i < (objectStream.Length - 16); ++i)
                    {
                        truncatedObjectStream.WriteByte((byte)objectStream.ReadByte());
                    }
                }

            this.fileSystem.DeleteFile(objectPath);
            this.fileSystem.MoveFile(tempTruncatedObjectPath, objectPath);
            tempTruncatedObjectPath.ShouldNotExistOnDisk(this.fileSystem);
            objectPath.ShouldBeAFile(this.fileSystem);
            new FileInfo(objectPath).Length.ShouldEqual(objectLength - 16);

            // Windows should correct a corrupt obect
            // Read the original path and verify its contents are correct
            this.Enlistment.GetVirtualPathTo("Test_EPF_WorkingDirectoryTests", "TruncatedObjectRedownloaded.txt").ShouldBeAFile(this.fileSystem).WithContents(testFileContents);

            // Confirm there's a new item in the corrupt objects folder
            corruptObjectFolderPath.ShouldBeADirectory(this.fileSystem).WithItems().Count().ShouldEqual(initialCorruptObjectCount + 1);

            // File should not be in ModifiedPaths.dat
            GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, "Test_EPF_WorkingDirectoryTests/TruncatedObjectRedownloaded.txt");
        }
        public void DeletedTempFolderIsRemovedFromModifiedFiles(FileSystemRunner fileSystem)
        {
            string tempFolder = this.CreateDirectory(fileSystem, "Temp");

            fileSystem.DeleteDirectory(tempFolder);
            tempFolder.ShouldNotExistOnDisk(fileSystem);

            GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, fileSystem, "Temp/");
        }
        public void DeletedTempFileIsRemovedFromModifiedFiles(FileSystemRunner fileSystem)
        {
            string tempFile = this.CreateFile(fileSystem, "temp.txt");

            fileSystem.DeleteFile(tempFile);
            tempFile.ShouldNotExistOnDisk(fileSystem);

            GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, fileSystem, "temp.txt");
        }
Ejemplo n.º 14
0
        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 DeletedTempFolderDeletesFilesFromModifiedFiles(FileSystemRunner fileSystem)
        {
            string tempFolder = this.CreateDirectory(fileSystem, "Temp");
            string tempFile1  = this.CreateFile(fileSystem, Path.Combine("Temp", "temp1.txt"));
            string tempFile2  = this.CreateFile(fileSystem, Path.Combine("Temp", "temp2.txt"));

            fileSystem.DeleteDirectory(tempFolder);
            tempFolder.ShouldNotExistOnDisk(fileSystem);
            tempFile1.ShouldNotExistOnDisk(fileSystem);
            tempFile2.ShouldNotExistOnDisk(fileSystem);

            GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, fileSystem, "Temp/", "Temp/temp1.txt", "Temp/temp2.txt");
        }
Ejemplo n.º 16
0
        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);
        }
Ejemplo n.º 17
0
        public void CheckoutCommitWhereFileContentsChangeAfterRead()
        {
            this.ControlGitRepo.Fetch(GitRepoTests.ConflictSourceBranch);

            string fileName = "SameChange.txt";

            // In commit 170b13ce1990c53944403a70e93c257061598ae0 the initial files for the FunctionalTests/20170206_Conflict_Source branch were created
            this.ValidateGitCommand("checkout 170b13ce1990c53944403a70e93c257061598ae0");
            this.FileContentsShouldMatch(@"Test_ConflictTests\ModifiedFiles\" + fileName);

            // A read should not add the file to the modified paths
            GVFSHelpers.ModifiedPathsShouldNotContain(this.FileSystem, this.Enlistment.DotGVFSRoot, fileName);

            this.ValidateGitCommand("checkout FunctionalTests/20170206_Conflict_Source");
            this.FileContentsShouldMatch(@"Test_ConflictTests\ModifiedFiles\" + fileName);
            GVFSHelpers.ModifiedPathsShouldNotContain(this.FileSystem, this.Enlistment.DotGVFSRoot, fileName);
        }
Ejemplo n.º 18
0
        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
            GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.FileSystem, fileName);

            this.ValidateGitCommand("checkout FunctionalTests/20170206_Conflict_Source");
            this.FileContentsShouldMatch("Test_ConflictTests", "ModifiedFiles", fileName);
            GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.FileSystem, fileName);
        }
Ejemplo n.º 19
0
        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");
        }
Ejemplo n.º 20
0
        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.FileSystem, this.Enlistment.DotGVFSRoot, folderName);

            this.FolderShouldHaveCaseMatchingName(folderName, "GVFlt_MultiThreadTest");
            this.DeleteFolder(folderName);

            // b5fd7d23706a18cff3e2b8225588d479f7e51138 is the commit prior to deleting GVFLT_MultiThreadTest
            // and re-adding it as as GVFlt_MultiThreadTest
            this.ValidateGitCommand("checkout b5fd7d23706a18cff3e2b8225588d479f7e51138");
            this.FolderShouldHaveCaseMatchingName(folderName, "GVFLT_MultiThreadTest");
        }
Ejemplo n.º 21
0
        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);
        }
Ejemplo n.º 22
0
        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);
        }
Ejemplo n.º 23
0
        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);
        }
Ejemplo n.º 24
0
        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);
        }
Ejemplo n.º 25
0
        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);
        }
Ejemplo n.º 26
0
        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);
            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");
        }
Ejemplo n.º 27
0
        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");
        }
Ejemplo n.º 28
0
        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();
            GVFSHelpers.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();
            GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, fileNameLink);
            GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, fileName);
            fileLinkInsideRepo.ShouldBeAFile(this.fileSystem);
        }
Ejemplo n.º 29
0
        public void CheckoutCommitWhereFileDeletedAfterRead()
        {
            this.ControlGitRepo.Fetch(GitRepoTests.ConflictSourceBranch);
            this.ControlGitRepo.Fetch("FunctionalTests/20201014_CheckoutTests4");

            string fileName = "DeleteInSource.txt";
            string filePath = Path.Combine("Test_ConflictTests", "DeletedFiles", fileName);

            // In commit db95d631e379d366d26d899523f8136a77441914 the initial files for the FunctionalTests/20201014_Conflict_Source_2 branch were created
            this.ValidateGitCommand("checkout FunctionalTests/20201014_CheckoutTests4");
            this.FileContentsShouldMatch(filePath);

            // A read should not add the file to the modified paths
            GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.FileSystem, fileName);

            this.ValidateGitCommand($"checkout {GitRepoTests.ConflictSourceBranch}");
            this.ShouldNotExistOnDisk(filePath);
            GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.FileSystem, fileName);
        }
Ejemplo n.º 30
0
        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();

            GVFSHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, expectedModifiedEntries);
            GVFSHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, folderName + "/");
        }