コード例 #1
0
        private void LoadBlobsViaGit(ScalarFunctionalTestEnlistment enlistment)
        {
            // 'git rev-list --objects' will check for all objects' existence, which
            // triggers an object download on every missing blob.
            ProcessResult result = GitHelpers.InvokeGitAgainstScalarRepo(enlistment.RepoRoot, "rev-list --all --objects");

            result.ExitCode.ShouldEqual(0, result.Errors);
        }
コード例 #2
0
        public void NoReminderWhenUpgradeNotAvailable()
        {
            this.EmptyDownloadDirectory();

            for (int count = 0; count < 50; count++)
            {
                ProcessResult result = GitHelpers.InvokeGitAgainstScalarRepo(
                    this.Enlistment.RepoRoot,
                    "status");

                string.IsNullOrEmpty(result.Errors).ShouldBeTrue();
            }
        }
コード例 #3
0
        public void UpdateIndexRemoveAddFileOpenForWrite()
        {
            // TODO 940287: Remove this test and re-enable UpdateIndexRemoveFileOnDisk
            this.ValidateGitCommand("checkout " + GitRepoTests.ConflictTargetBranch);

            // git-status will not match because update-index --remove does not check what is on disk if the skip-worktree bit is set,
            // meaning it will always remove the file from the index
            GitProcess.InvokeProcess(this.ControlGitRepo.RootPath, "update-index --remove Test_ConflictTests/AddedFiles/AddedByBothDifferentContent.txt");
            GitHelpers.InvokeGitAgainstScalarRepo(this.Enlistment.RepoRoot, "update-index --remove Test_ConflictTests/AddedFiles/AddedByBothDifferentContent.txt");
            this.FilesShouldMatchCheckoutOfTargetBranch();

            // Add the files back to the index so the git-status that is run during teardown matches
            GitProcess.InvokeProcess(this.ControlGitRepo.RootPath, "update-index --add Test_ConflictTests/AddedFiles/AddedByBothDifferentContent.txt");
            GitHelpers.InvokeGitAgainstScalarRepo(this.Enlistment.RepoRoot, "update-index --add Test_ConflictTests/AddedFiles/AddedByBothDifferentContent.txt");
        }
コード例 #4
0
        public void GitFetchDownloadsPrefetchPacks()
        {
            this.fileSystem.DeleteDirectory(this.PackRoot);

            GitHelpers.InvokeGitAgainstScalarRepo(this.Enlistment.RepoRoot, "fetch origin");

            // Verify pack root has a prefetch pack
            this.PackRoot
            .ShouldBeADirectory(this.fileSystem)
            .WithItems()
            .Where(info => info.Name.StartsWith(PrefetchPackPrefix))
            .ShouldBeNonEmpty();

            // Verify tempPacks is empty
            this.TempPackRoot.ShouldBeADirectory(this.fileSystem).WithNoItems();
        }
コード例 #5
0
        public void GitWithEnvironmentVariables()
        {
            // The trace info is an error, so we can't use CheckGitCommand().
            // We just want to make sure this doesn't throw an exception.
            ProcessResult result = GitHelpers.InvokeGitAgainstScalarRepo(
                this.Enlistment.RepoRoot,
                "branch",
                new Dictionary <string, string>
            {
                { "GIT_TRACE_PERFORMANCE", "1" },
                { "git_trace", "1" },
            },
                removeWaitingMessages: false);

            result.Output.ShouldContain("* FunctionalTests");
            result.Errors.ShouldNotContain(ignoreCase: true, unexpectedSubstrings: "exception");
            result.Errors.ShouldContain("trace.c:", "git command:");
        }
コード例 #6
0
        /* We are using the following method for these scenarios
         * 1. Some commands compute a new commit sha, which is dependent on time and therefore
         *    won't match what is in the control repo.  For those commands, we just ensure that
         *    the errors match what we expect, but we skip comparing the output
         * 2. Using the sparse-checkout feature git will error out before checking the untracked files
         *    so the control repo will show the untracked files as being overwritten while the Scalar
         *    repo which is using the sparse-checkout will not.
         * 3. Scalar is returning not found for files that are outside the sparse-checkout and there
         *    are cases when git will delete these files during a merge outputting that it removed them
         *    which the Scalar repo did not have to remove so the message is missing that output.
         */
        protected void RunGitCommand(string command, bool ignoreErrors = false, bool checkStatus = true, string standardInput = null)
        {
            string controlRepoRoot = this.ControlGitRepo.RootPath;
            string scalarRepoRoot  = this.Enlistment.RepoRoot;

            ProcessResult expectedResult = GitProcess.InvokeProcess(controlRepoRoot, command, standardInput);
            ProcessResult actualResult   = GitHelpers.InvokeGitAgainstScalarRepo(scalarRepoRoot, command, input: standardInput);

            if (!ignoreErrors)
            {
                GitHelpers.LinesShouldMatch(command, expectedResult.Errors, actualResult.Errors);
            }

            if (command != "status" && checkStatus)
            {
                this.ValidateGitCommand("status");
            }
        }
コード例 #7
0
        public void MergeConflictEnsureStatusFailsDueToConfig()
        {
            // This is compared against the message emitted by Scalar.Hooks\Program.cs
            string expectedErrorMessagePart = "--no-renames";

            this.ValidateGitCommand("checkout " + GitRepoTests.ConflictTargetBranch);
            this.RunGitCommand("merge " + GitRepoTests.ConflictSourceBranch, checkStatus: false);

            ProcessResult result1 = GitHelpers.InvokeGitAgainstScalarRepo(this.Enlistment.RepoRoot, "status");

            result1.Errors.Contains(expectedErrorMessagePart);

            ProcessResult result2 = GitHelpers.InvokeGitAgainstScalarRepo(this.Enlistment.RepoRoot, "status --no-renames");

            result2.Errors.Contains(expectedErrorMessagePart);

            // Complete setup to ensure teardown succeeds
            GitHelpers.InvokeGitAgainstScalarRepo(this.Enlistment.RepoRoot, "config --local test.renames false");
        }
コード例 #8
0
        private bool ReminderMessagingEnabled()
        {
            Dictionary <string, string> environmentVariables = new Dictionary <string, string>();

            environmentVariables["Scalar_UPGRADE_DETERMINISTIC"] = "true";
            ProcessResult result = GitHelpers.InvokeGitAgainstScalarRepo(
                this.Enlistment.RepoRoot,
                "status",
                environmentVariables,
                removeWaitingMessages: true,
                removeUpgradeMessages: false);

            if (!string.IsNullOrEmpty(result.Errors) &&
                result.Errors.Contains("A new version of Scalar is available."))
            {
                return(true);
            }

            return(false);
        }
コード例 #9
0
        public void SecondCloneSucceedsWithMissingTrees()
        {
            string newCachePath = Path.Combine(this.localCacheParentPath, ".customScalarCache2");
            ScalarFunctionalTestEnlistment enlistment1 = this.CreateNewEnlistment(localCacheRoot: newCachePath, skipFetchCommitsAndTrees: true);

            File.ReadAllText(Path.Combine(enlistment1.RepoRoot, WellKnownFile));
            this.AlternatesFileShouldHaveGitObjectsRoot(enlistment1);

            // This Git command loads the commit and root tree for WellKnownCommitSha,
            // but does not download any more reachable objects.
            string        command = "cat-file -p origin/" + WellKnownBranch + "^{tree}";
            ProcessResult result  = GitHelpers.InvokeGitAgainstScalarRepo(enlistment1.RepoRoot, command);

            result.ExitCode.ShouldEqual(0, $"git {command} failed on {nameof(enlistment1)} with error: {result.Errors}");

            // If we did not properly check the failed checkout at this step, then clone will fail during checkout.
            ScalarFunctionalTestEnlistment enlistment2 = this.CreateNewEnlistment(localCacheRoot: newCachePath, branch: WellKnownBranch, skipFetchCommitsAndTrees: true);

            result = GitHelpers.InvokeGitAgainstScalarRepo(enlistment2.RepoRoot, command);
            result.ExitCode.ShouldEqual(0, $"git {command} failed on {nameof(enlistment2)} with error: {result.Errors}");
        }