示例#1
0
        protected CalamariResult InvokeInProcess(CommandLine command, IVariables variables = null)
        {
            var args    = command.GetRawArgs();
            var program = new TestProgram(Log);
            int exitCode;

            try
            {
                exitCode = program.Run(args);
            }
            catch (Exception ex)
            {
                exitCode = ConsoleFormatter.PrintError(Log, ex);
            }

            variables = variables ?? new CalamariVariables();
            var capture = new CaptureCommandInvocationOutputSink();
            var sco     = new SplitCommandInvocationOutputSink(new ServiceMessageCommandInvocationOutputSink(variables), capture);

            foreach (var line in Log.StandardOut)
            {
                sco.WriteInfo(line);
            }

            foreach (var line in Log.StandardError)
            {
                sco.WriteError(line);
            }

            return(new CalamariResult(exitCode, capture));
        }
 public static string ToApprovalString(this CaptureCommandInvocationOutputSink output)
 {
     return output
         .AllMessages
         .RemoveIgnoredLines()
         .TrimRedactedLines()
         .Aggregate(new StringBuilder(), (builder, s) => builder.AppendLine(s), builder => builder.ToString())
         .ScrubGuids()
         .ScrubTimestampTempFolders();
 }
示例#3
0
 public CalamariResult(int exitCode, CaptureCommandInvocationOutputSink captured)
 {
     this.exitCode = exitCode;
     this.captured = captured;
 }
示例#4
0
 public TestCommandLineRunner(ILog log, IVariables variables) : base(log, variables)
 {
     this.variables = variables;
     Output         = new CaptureCommandInvocationOutputSink();
 }