Ejemplo n.º 1
0
        public void MountFailsUpgradingFromCommitProjectionVersionWhereProjectedCommitIdDoesNotMatchHEAD(string mountSubfolder)
        {
            MountSubfolders.EnsureSubfoldersOnDisk(this.Enlistment, this.fileSystem);
            string headCommitId = GitProcess.Invoke(this.Enlistment.RepoRoot, "rev-parse HEAD");

            this.Enlistment.UnmountGVFS();

            string currentVersion = this.GetPersistedDiskLayoutVersion().ShouldNotBeNull();
            int    currentVersionNum;

            int.TryParse(currentVersion, out currentVersionNum).ShouldEqual(true);

            this.SaveDiskLayoutVersion((ProjectGitIndexOnDiskVersion - 1).ToString());

            string gvfsHeadPath = Path.Combine(this.Enlistment.DotGVFSRoot, "GVFS_HEAD");

            gvfsHeadPath.ShouldNotExistOnDisk(this.fileSystem);

            // 575d597cf09b2cd1c0ddb4db21ce96979010bbcb is an earlier commit in the FunctionalTests/20170310 branch
            this.fileSystem.WriteAllText(gvfsHeadPath, "575d597cf09b2cd1c0ddb4db21ce96979010bbcb");

            this.MountShouldFail("Failed to mount", this.Enlistment.GetVirtualPathTo(mountSubfolder));

            this.fileSystem.DeleteFile(gvfsHeadPath);
            this.fileSystem.WriteAllText(gvfsHeadPath, headCommitId);
            this.SaveDiskLayoutVersion(currentVersionNum.ToString());
            this.Enlistment.MountGVFS();
            gvfsHeadPath.ShouldNotExistOnDisk(this.fileSystem);
        }
Ejemplo n.º 2
0
        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 majorVersion;
            string minorVersion;

            GVFSHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGVFSRoot, 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
            GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, "1", "0");
            this.MountShouldFail("Breaking change to GVFS disk layout has been made since cloning", this.Enlistment.GetVirtualPathTo(mountSubfolder));

            GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, majorVersionNum.ToString(), minorVersionNum.ToString());
            this.Enlistment.MountGVFS();
        }
Ejemplo n.º 3
0
        public void MountSucceedsWhenBadDataInGvfsHeadFile(string mountSubfolder)
        {
            MountSubfolders.EnsureSubfoldersOnDisk(this.Enlistment, this.fileSystem);
            this.Enlistment.UnmountGVFS();

            string gvfsHeadPath = Path.Combine(this.Enlistment.DotGVFSRoot, "GVFS_HEAD");

            gvfsHeadPath.ShouldNotExistOnDisk(this.fileSystem);
            this.fileSystem.WriteAllText(gvfsHeadPath, "This is a bad commit Id!");

            this.Enlistment.MountGVFS();
            gvfsHeadPath.ShouldNotExistOnDisk(this.fileSystem);
        }
Ejemplo n.º 4
0
        public void MountFailsAfterBreakingDowngrade(string mountSubfolder)
        {
            MountSubfolders.EnsureSubfoldersOnDisk(this.Enlistment, this.fileSystem);
            this.Enlistment.UnmountGVFS();

            string currentVersion = this.GetPersistedDiskLayoutVersion().ShouldNotBeNull();
            int    currentVersionNum;

            int.TryParse(currentVersion, out currentVersionNum).ShouldEqual(true);
            this.SaveDiskLayoutVersion((currentVersionNum + 1).ToString());

            this.MountShouldFail("do not allow mounting after downgrade", this.Enlistment.GetVirtualPathTo(mountSubfolder));

            this.SaveDiskLayoutVersion(currentVersionNum.ToString());
            this.Enlistment.MountGVFS();
        }
Ejemplo n.º 5
0
        public void MountSucceedsUpgradingFromCommitProjectionVersionWhereProjectedCommitIdMatchesHEAD(string mountSubfolder)
        {
            MountSubfolders.EnsureSubfoldersOnDisk(this.Enlistment, this.fileSystem);
            this.Enlistment.UnmountGVFS();

            string currentVersion = this.GetPersistedDiskLayoutVersion().ShouldNotBeNull();
            int    currentVersionNum;

            int.TryParse(currentVersion, out currentVersionNum).ShouldEqual(true);
            this.SaveDiskLayoutVersion((ProjectGitIndexOnDiskVersion - 1).ToString());

            this.Enlistment.MountGVFS();
            this.Enlistment.UnmountGVFS();

            this.SaveDiskLayoutVersion(currentVersionNum.ToString());
            this.Enlistment.MountGVFS();
        }
Ejemplo n.º 6
0
        public void MountSucceedsUpgradingFromCommitProjectionVersionWhereProjectedCommitIdMatchesHEAD(string mountSubfolder)
        {
            MountSubfolders.EnsureSubfoldersOnDisk(this.Enlistment, this.fileSystem);
            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, (ProjectGitIndexOnDiskVersion - 1).ToString());

            string alwaysExcludeVirtualPath = this.Enlistment.GetVirtualPathTo(AlwaysExcludePath);

            this.fileSystem.DeleteFile(alwaysExcludeVirtualPath);

            this.Enlistment.MountGVFS();
            this.Enlistment.UnmountGVFS();

            GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, currentVersionNum.ToString());
            this.Enlistment.MountGVFS();
        }
Ejemplo n.º 7
0
        public void MountFailsAfterBreakingDowngrade(string mountSubfolder)
        {
            MountSubfolders.EnsureSubfoldersOnDisk(this.Enlistment, this.fileSystem);
            this.Enlistment.UnmountGVFS();

            string majorVersion;
            string minorVersion;

            GVFSHelpers.GetPersistedDiskLayoutVersion(this.Enlistment.DotGVFSRoot, out majorVersion, out minorVersion);

            int majorVersionNum;
            int minorVersionNum;

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

            GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, (majorVersionNum + 1).ToString(), "0");

            this.MountShouldFail("do not allow mounting after downgrade", this.Enlistment.GetVirtualPathTo(mountSubfolder));

            GVFSHelpers.SaveDiskLayoutVersion(this.Enlistment.DotGVFSRoot, majorVersionNum.ToString(), minorVersionNum.ToString());
            this.Enlistment.MountGVFS();
        }