Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        ICombinedPackageExtractor CreatePackageExtractor()
        {
            var log               = new InMemoryLog();
            var variables         = new CalamariVariables();
            var commandLineRunner = new TestCommandLineRunner(log, variables);

            return(new CombinedPackageExtractor(log, variables, commandLineRunner));
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        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));
        }