示例#1
0
        public void DeleteObjectsCacheAndCacheMappingBeforeMount()
        {
            GSDFunctionalTestEnlistment enlistment1 = this.CloneAndMountEnlistment();
            GSDFunctionalTestEnlistment enlistment2 = this.CloneAndMountEnlistment();

            enlistment1.UnmountGSD();

            string objectsRoot = GSDHelpers.GetPersistedGitObjectsRoot(enlistment1.DotGSDRoot).ShouldNotBeNull();

            objectsRoot.ShouldBeADirectory(this.fileSystem);
            RepositoryHelpers.DeleteTestDirectory(objectsRoot);

            string metadataPath = Path.Combine(this.localCachePath, "mapping.dat");

            metadataPath.ShouldBeAFile(this.fileSystem);
            this.fileSystem.DeleteFile(metadataPath);

            enlistment1.MountGSD();

            Task task1 = Task.Run(() => this.HydrateRootFolder(enlistment1));
            Task task2 = Task.Run(() => this.HydrateRootFolder(enlistment2));

            task1.Wait();
            task2.Wait();
            task1.Exception.ShouldBeNull();
            task2.Exception.ShouldBeNull();

            enlistment1.Status().ShouldContain("Mount status: Ready");
            enlistment2.Status().ShouldContain("Mount status: Ready");

            this.AlternatesFileShouldHaveGitObjectsRoot(enlistment1);
            this.AlternatesFileShouldHaveGitObjectsRoot(enlistment2);
        }
示例#2
0
        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 LockToPreventDelete_SingleFile()
        {
            string testFile1Contents = "TestContentsLockToPreventDelete \r\n";
            string testFile1Name     = "test.txt";
            string testFile1Path     = this.Enlistment.GetVirtualPathTo(Path.Combine(TestParentFolderName, "LockToPreventDelete", testFile1Name));

            testFile1Path.ShouldBeAFile(this.fileSystem).WithContents(testFile1Contents);
            using (SafeFileHandle testFile1Handle = this.CreateFile(testFile1Path, FileShare.Read))
            {
                testFile1Handle.IsInvalid.ShouldEqual(false);

                ProcessResult result = this.InvokeGitAgainstGSDRepo("checkout " + OldCommitId);
                result.Errors.ShouldContain(
                    "GSD was unable to delete the following files. To recover, close all handles to the files and run these commands:",
                    "git clean -f " + TestParentFolderName + "/LockToPreventDelete/" + testFile1Name);

                GitHelpers.CheckGitCommandAgainstGSDRepo(
                    this.Enlistment.RepoRoot,
                    "status -u",
                    "HEAD detached at " + OldCommitId,
                    "Untracked files:",
                    TestParentFolderName + "/LockToPreventDelete/" + testFile1Name);
            }

            this.GitCleanFile(TestParentFolderName + "/LockToPreventDelete/" + testFile1Name);
            this.GitStatusShouldBeClean(OldCommitId);
            GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, TestParentFolderName + "/LockToPreventDelete/" + testFile1Name);
            testFile1Path.ShouldNotExistOnDisk(this.fileSystem);

            this.GitCheckoutCommitId(NewFilesAndChangesCommitId);

            this.GitStatusShouldBeClean(NewFilesAndChangesCommitId);
            testFile1Path.ShouldBeAFile(this.fileSystem).WithContents(testFile1Contents);
        }
示例#4
0
        public void MountFailsWhenNoGitObjectsRootInRepoMetadata()
        {
            this.Enlistment.UnmountGSD();

            string majorVersion;
            string minorVersion;

            GSDHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGSDRoot, out majorVersion, out minorVersion);
            majorVersion.ShouldNotBeNull();
            minorVersion.ShouldNotBeNull();

            string localCacheRoot = GSDHelpers.GetPersistedLocalCacheRoot(this.Enlistment.DotGSDRoot).ShouldNotBeNull();

            string metadataPath       = Path.Combine(this.Enlistment.DotGSDRoot, GSDHelpers.RepoMetadataName);
            string metadataBackupPath = metadataPath + ".backup";

            this.fileSystem.MoveFile(metadataPath, metadataBackupPath);

            this.fileSystem.CreateEmptyFile(metadataPath);
            GSDHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGSDRoot, majorVersion, minorVersion);
            GSDHelpers.SaveLocalCacheRoot(this.Enlistment.DotGSDRoot, localCacheRoot);

            this.MountShouldFail("Failed to determine git objects root from repo metadata");

            this.fileSystem.DeleteFile(metadataPath);
            this.fileSystem.MoveFile(metadataBackupPath, metadataPath);

            this.Enlistment.MountGSD();
        }
示例#5
0
        public void DeletedFolderAndChildrenAddedToToModifiedPathsFile()
        {
            string folderToDelete = "Scripts";

            string[] filesToDelete = new string[]
            {
                "Scripts/CreateCommonAssemblyVersion.bat",
                "Scripts/CreateCommonCliAssemblyVersion.bat",
                "Scripts/CreateCommonVersionHeader.bat",
                "Scripts/RunFunctionalTests.bat",
                "Scripts/RunUnitTests.bat"
            };

            // Verify skip-worktree initial set for all files
            foreach (string file in filesToDelete)
            {
                this.VerifyWorktreeBit(file, LsFilesStatus.SkipWorktree);
            }

            this.fileSystem.DeleteDirectory(this.Enlistment.GetVirtualPathTo(folderToDelete));
            this.Enlistment.WaitForBackgroundOperations();

            GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, folderToDelete + "/");
            GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, filesToDelete);

            // Verify skip-worktree cleared
            foreach (string file in filesToDelete)
            {
                this.VerifyWorktreeBit(file, LsFilesStatus.Cached);
            }
        }
示例#6
0
        public void MountFailsUpgradingFromInvalidUpgradePath(string mountSubfolder)
        {
            MountSubfolders.EnsureSubfoldersOnDisk(this.Enlistment, this.fileSystem);
            string headCommitId = GitProcess.Invoke(this.Enlistment.RepoRoot, "rev-parse HEAD");

            this.Enlistment.UnmountGSD();

            string majorVersion;
            string minorVersion;

            GSDHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGSDRoot, out majorVersion, out minorVersion);

            int majorVersionNum;
            int minorVersionNum;

            int.TryParse(majorVersion.ShouldNotBeNull(), out majorVersionNum).ShouldEqual(true);
            int.TryParse(minorVersion.ShouldNotBeNull(), out minorVersionNum).ShouldEqual(true);

            // 1 will always be below the minumum support version number
            GSDHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGSDRoot, "1", "0");
            this.MountShouldFail("Breaking change to GSD disk layout has been made since cloning", this.Enlistment.GetVirtualPathTo(mountSubfolder));

            GSDHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGSDRoot, majorVersionNum.ToString(), minorVersionNum.ToString());
            this.Enlistment.MountGSD();
        }
示例#7
0
        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);
        }
示例#8
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");

            GSDHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.fileSystem, gitFileToCheck);
        }
示例#9
0
        private void MountGSD(string workingDirectory, string enlistmentPath = null)
        {
            string mountCommand;

            if (enlistmentPath != null)
            {
                mountCommand = $"mount \"{enlistmentPath}\" {TestConstants.InternalUseOnlyFlag} {GSDHelpers.GetInternalParameter()}";
            }
            else
            {
                mountCommand = $"mount {TestConstants.InternalUseOnlyFlag} {GSDHelpers.GetInternalParameter()}";
            }

            ProcessStartInfo startInfo = new ProcessStartInfo(GSDTestConfig.PathToGSD);

            startInfo.Arguments              = mountCommand;
            startInfo.UseShellExecute        = false;
            startInfo.RedirectStandardOutput = true;
            startInfo.RedirectStandardError  = true;
            startInfo.CreateNoWindow         = true;
            startInfo.WorkingDirectory       = workingDirectory;

            ProcessResult result = ProcessHelper.Run(startInfo);

            result.ExitCode.ShouldEqual(0, result.Errors);

            this.RepoStatusShouldBeMounted(workingDirectory, enlistmentPath);
        }
示例#10
0
        private void AlternatesFileShouldHaveGitObjectsRoot(GSDFunctionalTestEnlistment enlistment)
        {
            string objectsRoot            = GSDHelpers.GetPersistedGitObjectsRoot(enlistment.DotGSDRoot);
            string alternatesFileContents = Path.Combine(enlistment.RepoRoot, ".git", "objects", "info", "alternates").ShouldBeAFile(this.fileSystem).WithContents();

            alternatesFileContents.ShouldEqual(objectsRoot);
        }
示例#11
0
        public void MountReusesLocalCacheKeyWhenGitObjectsRootDeleted()
        {
            GSDFunctionalTestEnlistment enlistment = this.CloneAndMountEnlistment();

            enlistment.UnmountGSD();

            // Find the current git objects root and ensure it's on disk
            string objectsRoot = GSDHelpers.GetPersistedGitObjectsRoot(enlistment.DotGSDRoot).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 git objects root folder, mount should re-create it and the mapping.dat file should not change
            RepositoryHelpers.DeleteTestDirectory(objectsRoot);

            enlistment.MountGSD();

            GSDHelpers.GetPersistedGitObjectsRoot(enlistment.DotGSDRoot).ShouldEqual(objectsRoot);
            objectsRoot.ShouldBeADirectory(this.fileSystem);
            mappingFilePath.ShouldBeAFile(this.fileSystem).WithContents(mappingFileContents);

            this.AlternatesFileShouldHaveGitObjectsRoot(enlistment);
        }
示例#12
0
        public void DeleteCacheDuringHydrations()
        {
            GSDFunctionalTestEnlistment enlistment1 = this.CloneAndMountEnlistment();

            string objectsRoot = GSDHelpers.GetPersistedGitObjectsRoot(enlistment1.DotGSDRoot).ShouldNotBeNull();

            objectsRoot.ShouldBeADirectory(this.fileSystem);

            Task task1 = Task.Run(() =>
            {
                this.HydrateEntireRepo(enlistment1);
            });

            while (!task1.IsCompleted)
            {
                try
                {
                    // Delete objectsRoot rather than this.localCachePath as the blob sizes database cannot be deleted while GSD is mounted
                    RepositoryHelpers.DeleteTestDirectory(objectsRoot);
                    Thread.Sleep(100);
                }
                catch (IOException)
                {
                    // Hydration may have handles into the cache, so failing this delete is expected.
                }
            }

            task1.Exception.ShouldBeNull();

            enlistment1.Status().ShouldContain("Mount status: Ready");
        }
示例#13
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);

            GSDHelpers.ModifiedPathsShouldNotContain(this.Enlistment, this.FileSystem, Path.GetFileName(readFilePath));
        }
示例#14
0
        public void CloneWithDefaultLocalCacheLocation()
        {
            FileSystemRunner fileSystem    = FileSystemRunner.DefaultRunner;
            string           homeDirectory = Environment.GetEnvironmentVariable("HOME");

            homeDirectory.ShouldBeADirectory(fileSystem);

            string newEnlistmentRoot = GSDFunctionalTestEnlistment.GetUniqueEnlistmentRoot();

            ProcessStartInfo processInfo = new ProcessStartInfo(GSDTestConfig.PathToGSD);

            processInfo.Arguments              = $"clone {Properties.Settings.Default.RepoToClone} {newEnlistmentRoot} --no-mount --no-prefetch";
            processInfo.WindowStyle            = ProcessWindowStyle.Hidden;
            processInfo.CreateNoWindow         = true;
            processInfo.UseShellExecute        = false;
            processInfo.RedirectStandardOutput = true;

            ProcessResult result = ProcessHelper.Run(processInfo);

            result.ExitCode.ShouldEqual(0, result.Errors);

            string dotGSDRoot = Path.Combine(newEnlistmentRoot, GSDTestConfig.DotGSDRoot);

            dotGSDRoot.ShouldBeADirectory(fileSystem);
            string localCacheRoot = GSDHelpers.GetPersistedLocalCacheRoot(dotGSDRoot);
            string gitObjectsRoot = GSDHelpers.GetPersistedGitObjectsRoot(dotGSDRoot);

            string defaultGSDCacheRoot = Path.Combine(homeDirectory, ".gvfsCache");

            localCacheRoot.StartsWith(defaultGSDCacheRoot, StringComparison.Ordinal).ShouldBeTrue($"Local cache root did not default to using {homeDirectory}");
            gitObjectsRoot.StartsWith(defaultGSDCacheRoot, StringComparison.Ordinal).ShouldBeTrue($"Git objects root did not default to using {homeDirectory}");

            RepositoryHelpers.DeleteTestDirectory(newEnlistmentRoot);
        }
示例#15
0
 public void MountFailsIfBeforeMinimumVersion()
 {
     // Mount should fail if on disk version is below minimum supported version
     this.Enlistment.UnmountGSD();
     GSDHelpers.SaveDiskLayoutVersion(
         this.Enlistment.DotGSDRoot,
         (this.currentDiskMinimumMajorVersion - 1).ToString(),
         CurrentDiskLayoutMinorVersion.ToString());
     this.Enlistment.TryMountGSD().ShouldBeFalse("Mount should fail because we are before minimum version");
 }
示例#16
0
        public void DeletedFileAddedToModifiedPathsFile()
        {
            string fileToDeleteEntry = "GVFlt_DeleteFileTest/GVFlt_DeleteFullFileWithoutFileContext_DeleteOnClose/a.txt";

            this.VerifyWorktreeBit(fileToDeleteEntry, LsFilesStatus.SkipWorktree);

            this.fileSystem.DeleteFile(this.Enlistment.GetVirtualPathTo(fileToDeleteEntry));
            this.Enlistment.WaitForBackgroundOperations();

            GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, fileToDeleteEntry);

            // Verify skip-worktree cleared
            this.VerifyWorktreeBit(fileToDeleteEntry, LsFilesStatus.Cached);
        }
示例#17
0
        public void CheckoutBranchAfterReadingFileAndVerifyContentsCorrect()
        {
            this.ControlGitRepo.Fetch(GitRepoTests.ConflictSourceBranch);
            this.ControlGitRepo.Fetch(GitRepoTests.ConflictTargetBranch);

            this.ValidateGitCommand("checkout " + GitRepoTests.ConflictTargetBranch);
            this.FilesShouldMatchCheckoutOfTargetBranch();

            this.ValidateGitCommand("checkout " + GitRepoTests.ConflictSourceBranch);
            this.FilesShouldMatchCheckoutOfSourceBranch();

            // Verify modified paths contents
            GSDHelpers.ModifiedPathsContentsShouldEqual(this.Enlistment, this.FileSystem, "A .gitattributes" + GSDHelpers.ModifiedPathsNewLine);
        }
示例#18
0
        public void MountRegeneratesAlternatesFileWhenMissingFromDisk()
        {
            this.Enlistment.UnmountGSD();

            string objectsRoot = GSDHelpers.GetPersistedGitObjectsRoot(this.Enlistment.DotGSDRoot).ShouldNotBeNull();

            string alternatesFilePath = Path.Combine(this.Enlistment.RepoRoot, ".git", "objects", "info", "alternates");

            alternatesFilePath.ShouldBeAFile(this.fileSystem).WithContents(objectsRoot);
            this.fileSystem.DeleteFile(alternatesFilePath);

            this.Enlistment.MountGSD();

            alternatesFilePath.ShouldBeAFile(this.fileSystem).WithContents(objectsRoot);
        }
示例#19
0
 private void ValidGitStatusWithRetry(string srcPath)
 {
     this.Enlistment.WaitForBackgroundOperations();
     GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.FileSystem, srcPath);
     try
     {
         this.ValidateGitCommand("status");
     }
     catch (Exception ex)
     {
         Thread.Sleep(1000);
         this.ValidateGitCommand("status");
         Assert.Fail("{0} was succesful on the second try, but failed on first: {1}", nameof(this.ValidateGitCommand), ex.Message);
     }
 }
示例#20
0
        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);
        }
示例#21
0
        public void CheckoutBranchAfterReadingAllFilesAndVerifyContentsCorrect()
        {
            this.ControlGitRepo.Fetch(GitRepoTests.ConflictSourceBranch);
            this.ControlGitRepo.Fetch(GitRepoTests.ConflictTargetBranch);

            this.ValidateGitCommand("checkout " + GitRepoTests.ConflictTargetBranch);
            this.Enlistment.RepoRoot.ShouldBeADirectory(this.FileSystem)
            .WithDeepStructure(this.FileSystem, this.ControlGitRepo.RootPath, compareContent: true);

            this.ValidateGitCommand("checkout " + GitRepoTests.ConflictSourceBranch);
            this.Enlistment.RepoRoot.ShouldBeADirectory(this.FileSystem)
            .WithDeepStructure(this.FileSystem, this.ControlGitRepo.RootPath, compareContent: true);

            // Verify modified paths contents
            GSDHelpers.ModifiedPathsContentsShouldEqual(this.Enlistment, this.FileSystem, "A .gitattributes" + GSDHelpers.ModifiedPathsNewLine);
        }
示例#22
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
            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);
        }
示例#23
0
        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");
        }
示例#24
0
        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();

            GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, fileToRenameEntry);
            GSDHelpers.ModifiedPathsShouldContain(this.Enlistment, this.fileSystem, fileToRenameTargetEntry);

            // Verify skip-worktree cleared
            this.VerifyWorktreeBit(fileToRenameEntry, LsFilesStatus.Cached);
        }
示例#25
0
        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);
        }
示例#26
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();
            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);
        }
示例#27
0
        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);
        }
示例#28
0
        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);
        }
示例#29
0
        public void MountSucceedsIfMinorVersionHasAdvancedButNotMajorVersion()
        {
            // Advance the minor version, mount should still work
            this.Enlistment.UnmountGSD();
            GSDHelpers.SaveDiskLayoutVersion(
                this.Enlistment.DotGSDRoot,
                this.currentDiskMajorVersion.ToString(),
                (CurrentDiskLayoutMinorVersion + 1).ToString());
            this.Enlistment.TryMountGSD().ShouldBeTrue("Mount should succeed because only the minor version advanced");

            // Advance the major version, mount should fail
            this.Enlistment.UnmountGSD();
            GSDHelpers.SaveDiskLayoutVersion(
                this.Enlistment.DotGSDRoot,
                (this.currentDiskMajorVersion + 1).ToString(),
                CurrentDiskLayoutMinorVersion.ToString());
            this.Enlistment.TryMountGSD().ShouldBeFalse("Mount should fail because the major version has advanced");
        }
示例#30
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
            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");
        }