static Maybe <Version> GetPython3Version() { var executable = PythonBootstrapper.FindPythonExecutable(); var command = new CommandLine(executable).Argument("--version"); var runner = new TestCommandLineRunner(new InMemoryLog(), new CalamariVariables()); var result = runner.Execute(command.Build()); if (result.ExitCode != 0) { return(Maybe <Version> .None); } var allCapturedMessages = runner.Output.AllMessages.Aggregate((a, b) => $"{a}, {b}"); var pythonVersionMatch = PythonVersionFinder.Match(allCapturedMessages); if (!pythonVersionMatch.Success) { return(Maybe <Version> .None); } var major = pythonVersionMatch.Groups[1].Value; var minor = pythonVersionMatch.Groups[2].Value; return(new Version(int.Parse(major), int.Parse(minor)).AsSome()); }
protected CalamariResult ExecuteScript(IScriptExecutor psse, string scriptName, IVariables variables) { var runner = new TestCommandLineRunner(new InMemoryLog(), variables); var result = psse.Execute(new Script(scriptName), variables, runner); return(new CalamariResult(result.ExitCode, runner.Output)); }
private static CalamariResult ExecuteScript(IScriptExecutor psse, string scriptName, IVariables variables) { var runner = new TestCommandLineRunner(ConsoleLog.Instance, variables); var result = psse.Execute(new Script(scriptName), variables, runner); return(new CalamariResult(result.ExitCode, runner.Output)); }
ICombinedPackageExtractor CreatePackageExtractor() { var log = new InMemoryLog(); var variables = new CalamariVariables(); var commandLineRunner = new TestCommandLineRunner(log, variables); return(new CombinedPackageExtractor(log, variables, commandLineRunner)); }
public void ScriptShouldFailIfExecutableDoesNotExist() { const string executable = "TestingCalamariThisExecutableShouldNeverExist"; var subject = new TestCommandLineRunner(new InMemoryLog(), new CalamariVariables()); var result = subject.Execute(new CommandLineInvocation(executable, "--version")); result.HasErrors.Should().BeTrue(); subject.Output.Errors.Should().Contain(CommandLineRunner.ConstructWin32ExceptionMessage(executable)); }
CalamariResult ExecuteScript(IScriptWrapper wrapper, string scriptName, IVariables variables) { var runner = new TestCommandLineRunner(ConsoleLog.Instance, variables); wrapper.NextWrapper = new TerminalScriptWrapper(new PowerShellScriptExecutor(), variables); var result = wrapper.ExecuteScript(new Script(scriptName), ScriptSyntax.PowerShell, runner, new Dictionary <string, string>()); return(new CalamariResult(result.ExitCode, runner.Output)); }