public ICommand CaptureStdErr() { ThrowIfRunning(); EnsureStdErr(); _stdErr.Capture(); return(this); }
public ICommand CaptureStdErr() { ThrowIfRunning(); EnsureStdErr(); _stdErr.Capture(_trimTrailingNewlines); return(this); }
public virtual CommandResult ExecuteWithCapturedOutput(string args = "") { Console.WriteLine($"Executing (Captured Output) - {_command} {args}"); var commandPath = Env.GetCommandPath(_command, ".exe", ".cmd", "") ?? Env.GetCommandPathFromAppBase(AppContext.BaseDirectory, _command, ".exe", ".cmd", ""); var stdOut = new StreamForwarder(); var stdErr = new StreamForwarder(); stdOut.Capture(); stdErr.Capture(); return RunProcess(commandPath, args, stdOut, stdErr); }
public virtual CommandResult ExecuteWithCapturedOutput(string args = "") { var command = _command; ResolveCommand(ref command, ref args); var commandPath = Env.GetCommandPath(command, ".exe", ".cmd", "") ?? Env.GetCommandPathFromRootPath(_baseDirectory, command, ".exe", ".cmd", ""); Console.WriteLine($"Executing (Captured Output) - {commandPath} {args}"); var stdOut = new StreamForwarder(); var stdErr = new StreamForwarder(); stdOut.Capture(); stdErr.Capture(); return RunProcess(commandPath, args, stdOut, stdErr); }
public Command CaptureStdOut() { ThrowIfRunning(); _stdOut.Capture(); return(this); }
public ICommand CaptureStdOut() { _stdOut.Capture(); return(this); }
public ICommand CaptureStdErr() { _stdErr.Capture(); return(this); }
private static void Forward(int bufferSize, ForwardOptions options, string str, string expectedCaptured, string[] expectedWrites) { var forwarder = new StreamForwarder(bufferSize); var writes = new List<string>(); if ((options & ForwardOptions.WriteLine) != 0) { forwarder.ForwardTo( write: (options & ForwardOptions.Write) == 0 ? (Action<string>)null : writes.Add, writeLine: s => writes.Add(s + "\n")); } if ((options & ForwardOptions.Capture) != 0) { forwarder.Capture(); } forwarder.Read(new StringReader(str)); Assert.Equal(expectedWrites, writes); var captured = forwarder.GetCapturedOutput(); Assert.Equal(expectedCaptured, captured); }
private void TestCapturingAndForwardingHelper(ForwardOptions options, string str, string expectedCaptured, string[] expectedWrites) { var forwarder = new StreamForwarder(); var writes = new List<string>(); if ((options & ForwardOptions.WriteLine) != 0) { forwarder.ForwardTo(writeLine: s => writes.Add(s + Environment.NewLine)); } if ((options & ForwardOptions.Capture) != 0) { forwarder.Capture(); } forwarder.Read(new StringReader(str)); Assert.Equal(expectedWrites, writes); var captured = forwarder.CapturedOutput; Assert.Equal(expectedCaptured, captured); }