Пример #1
0
        public static ProcessResult InvokeProcess(string executionWorkingDirectory, string command, Dictionary <string, string> environmentVariables = null)
        {
            ProcessStartInfo processInfo = new ProcessStartInfo(Properties.Settings.Default.PathToGit);

            processInfo.WorkingDirectory       = executionWorkingDirectory;
            processInfo.UseShellExecute        = false;
            processInfo.RedirectStandardOutput = true;
            processInfo.RedirectStandardError  = true;
            processInfo.Arguments = command;

            processInfo.EnvironmentVariables["GIT_TERMINAL_PROMPT"] = "0";

            if (environmentVariables != null)
            {
                foreach (string key in environmentVariables.Keys)
                {
                    processInfo.EnvironmentVariables[key] = environmentVariables[key];
                }
            }

            return(ProcessHelper.Run(processInfo));
        }
Пример #2
0
        private static string GetPathToService()
        {
            if (GVFSTestConfig.TestGVFSOnPath)
            {
                ProcessResult result = ProcessHelper.Run("where", Properties.Settings.Default.PathToGVFSService);
                result.ExitCode.ShouldEqual(0, $"{nameof(GetPathToService)}: where returned {result.ExitCode} when looking for {Properties.Settings.Default.PathToGVFSService}");

                string firstPath =
                    string.IsNullOrWhiteSpace(result.Output)
                    ? null
                    : result.Output.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault();

                firstPath.ShouldNotBeNull($"{nameof(GetPathToService)}: Failed to find {Properties.Settings.Default.PathToGVFSService}");
                return(firstPath);
            }
            else
            {
                return(Path.Combine(
                           Properties.Settings.Default.CurrentDirectory,
                           Properties.Settings.Default.PathToGVFSService));
            }
        }
Пример #3
0
        public static ProcessResult InvokeProcess(string executionWorkingDirectory, string command, Dictionary <string, string> environmentVariables = null, Stream inputStream = null)
        {
            ProcessStartInfo processInfo = new ProcessStartInfo(Properties.Settings.Default.PathToGit);

            processInfo.WorkingDirectory       = executionWorkingDirectory;
            processInfo.UseShellExecute        = false;
            processInfo.RedirectStandardOutput = true;
            processInfo.RedirectStandardError  = true;
            processInfo.Arguments = command;

            if (inputStream != null)
            {
                processInfo.RedirectStandardInput = true;
            }

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

            processInfo.EnvironmentVariables["GIT_TERMINAL_PROMPT"] = "0";

            if (environmentVariables != null)
            {
                foreach (string key in environmentVariables.Keys)
                {
                    TestContext.Progress.WriteLine($"Env: set {key}={environmentVariables[key]}");
                    processInfo.EnvironmentVariables[key] = environmentVariables[key];
                }
            }

            TestContext.Progress.WriteLine($"Invoking: {processInfo.FileName} {processInfo.Arguments}");
            ProcessResult result = ProcessHelper.Run(processInfo, inputStream: inputStream);

            ProcessHelper.WritePrefixedOutputLines("stdout> ", result.Output);
            ProcessHelper.WritePrefixedOutputLines("stderr> ", result.Errors);
            return(result);
        }
Пример #4
0
 private static ProcessResult CallPowershellCommand(string command)
 {
     return(ProcessHelper.Run("powershell.exe", "-NonInteractive -NoProfile -Command \"& { " + command + " }\""));
 }