Exemple #1
0
 public string LooseObjectStep()
 {
     return(this.CallGVFS(
                "dehydrate \"" + this.enlistmentRoot + "\"",
                expectedExitCode: SuccessExitCode,
                internalParameter: GVFSHelpers.GetInternalParameter("\\\"LooseObjects\\\"")));
 }
Exemple #2
0
 public string LooseObjectStep()
 {
     return(this.CallGVFS(
                "dehydrate \"" + this.enlistmentRoot + "\"",
                failOnError: true,
                internalParameter: GVFSHelpers.GetInternalParameter("\\\"LooseObjects\\\"")));
 }
Exemple #3
0
        public string PostFetchStep()
        {
            string internalParameter = GVFSHelpers.GetInternalParameter("\\\"PostFetch\\\"");

            return(this.CallGVFS(
                       "dehydrate \"" + this.enlistmentRoot + "\"",
                       expectedExitCode: SuccessExitCode,
                       internalParameter: internalParameter));
        }
        public string PostFetchStep()
        {
            string internalParameter = GVFSHelpers.GetInternalParameter("\\\"PostFetch\\\"");

            return(this.CallGVFS(
                       "dehydrate \"" + this.enlistmentRoot + "\"",
                       failOnError: true,
                       internalParameter: internalParameter));
        }
        /// <summary>
        /// Invokes a call to gvfs using the arguments specified
        /// </summary>
        /// <param name="args">The arguments to use when invoking gvfs</param>
        /// <param name="expectedExitCode">
        /// What the expected exit code should be.
        /// >= than 0 to check the exit code explicitly
        /// -1 = Fail if the exit code is 0
        /// -2 = Do not check the exit code (Default)
        /// </param>
        /// <param name="trace">What to set the GIT_TRACE environment variable to</param>
        /// <param name="standardInput">What to write to the standard input stream</param>
        /// <param name="internalParameter">The internal parameter to set in the arguments</param>
        /// <returns></returns>
        private string CallGVFS(string args, int expectedExitCode = DoNotCheckExitCode, string trace = null, string standardInput = null, string internalParameter = null)
        {
            ProcessStartInfo processInfo = null;

            processInfo = new ProcessStartInfo(this.pathToGVFS);

            if (internalParameter == null)
            {
                internalParameter = GVFSHelpers.GetInternalParameter();
            }

            processInfo.Arguments = args + " " + TestConstants.InternalUseOnlyFlag + " " + internalParameter;

            processInfo.WindowStyle            = ProcessWindowStyle.Hidden;
            processInfo.UseShellExecute        = false;
            processInfo.RedirectStandardOutput = true;
            if (standardInput != null)
            {
                processInfo.RedirectStandardInput = true;
            }

            if (processInfo.WorkingDirectory != null)
            {
                TestContext.Progress.WriteLine($"WorkingDir: cd {processInfo.WorkingDirectory}");
            }

            if (trace != null)
            {
                processInfo.EnvironmentVariables["GIT_TRACE"] = trace;
            }

            TestContext.Progress.WriteLine($"Invoking: {processInfo.FileName} {processInfo.Arguments}");
            using (Process process = Process.Start(processInfo))
            {
                if (standardInput != null)
                {
                    process.StandardInput.Write(standardInput);
                    process.StandardInput.Close();
                }

                string result = process.StandardOutput.ReadToEnd();
                process.WaitForExit();

                if (expectedExitCode >= SuccessExitCode)
                {
                    process.ExitCode.ShouldEqual(expectedExitCode, result);
                }
                else if (expectedExitCode == ExitCodeShouldNotBeZero)
                {
                    process.ExitCode.ShouldNotEqual(SuccessExitCode, "Exit code should not be zero");
                }

                ProcessHelper.WritePrefixedOutputLines("stdout> ", result);
                return(result);
            }
        }
Exemple #6
0
        public string PackfileMaintenanceStep(long?batchSize)
        {
            string sizeString        = batchSize.HasValue ? $"\\\"{batchSize.Value}\\\"" : "null";
            string internalParameter = GVFSHelpers.GetInternalParameter("\\\"PackfileMaintenance\\\"", sizeString);

            return(this.CallGVFS(
                       "dehydrate \"" + this.enlistmentRoot + "\"",
                       failOnError: true,
                       internalParameter: internalParameter));
        }
Exemple #7
0
        /// <summary>
        /// Invokes a call to gvfs using the arguments specified
        /// </summary>
        /// <param name="args">The arguments to use when invoking gvfs</param>
        /// <param name="expectedExitCode">
        /// What the expected exit code should be.
        /// >= than 0 to check the exit code explicitly
        /// -1 = Fail if the exit code is 0
        /// -2 = Do not check the exit code (Default)
        /// </param>
        /// <param name="trace">What to set the GIT_TRACE environment variable to</param>
        /// <param name="standardInput">What to write to the standard input stream</param>
        /// <param name="internalParameter">The internal parameter to set in the arguments</param>
        /// <returns></returns>
        private string CallGVFS(string args, int expectedExitCode = DoNotCheckExitCode, string trace = null, string standardInput = null, string internalParameter = null)
        {
            ProcessStartInfo processInfo = null;

            processInfo = new ProcessStartInfo(this.pathToGVFS);

            if (internalParameter == null)
            {
                internalParameter = GVFSHelpers.GetInternalParameter();
            }

            processInfo.Arguments = args + " " + TestConstants.InternalUseOnlyFlag + " " + internalParameter;

            processInfo.WindowStyle            = ProcessWindowStyle.Hidden;
            processInfo.UseShellExecute        = false;
            processInfo.RedirectStandardOutput = true;
            if (standardInput != null)
            {
                processInfo.RedirectStandardInput = true;
            }

            if (trace != null)
            {
                processInfo.EnvironmentVariables["GIT_TRACE"] = trace;
            }

            // TODO(Linux): remove when GVFS.Service process available; until then, do not output warning which confuses MountTests
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                processInfo.EnvironmentVariables["GVFS_UNATTENDED"] = "1";
            }

            using (Process process = Process.Start(processInfo))
            {
                if (standardInput != null)
                {
                    process.StandardInput.Write(standardInput);
                    process.StandardInput.Close();
                }

                string result = process.StandardOutput.ReadToEnd();
                process.WaitForExit();

                if (expectedExitCode >= SuccessExitCode)
                {
                    process.ExitCode.ShouldEqual(expectedExitCode, result);
                }
                else if (expectedExitCode == ExitCodeShouldNotBeZero)
                {
                    process.ExitCode.ShouldNotEqual(SuccessExitCode, "Exit code should not be zero");
                }

                return(result);
            }
        }
Exemple #8
0
        private string CallGVFS(string args, bool failOnError = false, string trace = null, string standardInput = null, string internalParameter = null)
        {
            ProcessStartInfo processInfo = null;

            processInfo = new ProcessStartInfo(this.pathToGVFS);

            if (internalParameter == null)
            {
                internalParameter = GVFSHelpers.GetInternalParameter();
            }

            processInfo.Arguments = args + " " + TestConstants.InternalUseOnlyFlag + " " + internalParameter;

            processInfo.WindowStyle            = ProcessWindowStyle.Hidden;
            processInfo.UseShellExecute        = false;
            processInfo.RedirectStandardOutput = true;
            if (standardInput != null)
            {
                processInfo.RedirectStandardInput = true;
            }

            if (trace != null)
            {
                processInfo.EnvironmentVariables["GIT_TRACE"] = trace;
            }

            using (Process process = Process.Start(processInfo))
            {
                if (standardInput != null)
                {
                    process.StandardInput.Write(standardInput);
                    process.StandardInput.Close();
                }

                string result = process.StandardOutput.ReadToEnd();
                process.WaitForExit();

                if (failOnError)
                {
                    process.ExitCode.ShouldEqual(0, result);
                }

                return(result);
            }
        }