pub trait WithStdout {
    // Required methods
    fn with_stdout<S: AsRef<str>>(&self, stdout: S);
    fn with_stderr<S: AsRef<str>>(&self, stderr: S);
    fn with_stdout_regex<S: AsRef<str>>(&self, stdout: S);
    fn with_stderr_regex<S: AsRef<str>>(&self, stderr: S);
    fn stdout_warns(&self) -> bool;
    fn stderr_warns(&self) -> bool;
    fn empty_stderr(&self) -> bool;
    fn empty_stdout(&self) -> bool;
}

Required Methods§

source

fn with_stdout<S: AsRef<str>>(&self, stdout: S)

Checks that the standard output of a command is what’s expected. If they aren’t the same, it will show the differences if the pretty_asssertions feature is enabled

Example
let proj = project()?;
let cmd = proj.command(["my", "cool", "--args"])?;
cmd.with_stdout("Expected stdout");
source

fn with_stderr<S: AsRef<str>>(&self, stderr: S)

Checks that the standard error of a command is what’s expected. If they aren’t the same, it will show the differences if the pretty_asssertions feature is enabled

Example
let proj = project()?;
let cmd = proj.command(["my", "cool", "--args"])?;
cmd.with_stderr("Expected stderr");
source

fn with_stdout_regex<S: AsRef<str>>(&self, stdout: S)

Checks that the standard output of a command is what’s expected (Using regex). If they aren’t the same, it will show the differences if the pretty_asssertions feature is enabled

Example
let proj = project()?;
let cmd = proj.command(["my", "cool", "--args"])?;
cmd.with_stdout_regex("<Regex that matches expected stdout>");
source

fn with_stderr_regex<S: AsRef<str>>(&self, stderr: S)

Checks that the standard error of a command is what’s expected (Using regex). If they aren’t the same, it will show the differences if the pretty_asssertions feature is enabled

Example
let proj = project()?;
let cmd = proj.command(["my", "cool", "--args"])?;
cmd.with_stderr("<Regex that matches expected stderr>");
source

fn stdout_warns(&self) -> bool

Returns how many times the program contains the word “warning:” in the stderr. Useful for checking compile-time warnings.

Example
let proj = project()?;
let cmd = proj.command(["my", "cool", "--args"])?;
if cmd.stderr_warns() {
    // Maybe there's something to check with that code...
}
}
source

fn stderr_warns(&self) -> bool

Returns how many times the program contains the word “warning:” in the stderr. Useful for checking compile-time warnings.

Example
let proj = project()?;
let cmd = proj.command(["my", "cool", "--args"])?;
if cmd.stderr_warns() {
    // Maybe there's something to check with that code...
}
}
source

fn empty_stderr(&self) -> bool

Checks that the stderr is empty. It’s different from .with_stderr("") in that this won’t print a whole diff. Useful for when ANY presence of a stderr would mean that there were errors, and the output is invalid.

Example
let proj = project()?;
let cmd = proj.command(["my", "cool", "--args"])?;
if !cmd.empty_stderr() {
    panic!("HELP!!! THE OUTPUT IS INVALID!!");
}
}
source

fn empty_stdout(&self) -> bool

Checks that the stdout is empty. It’s different from .with_stdout("") in that this won’t print a whole diff. Useful for when ANY presence of a stdout, would mean that there were errors, and the output is invalid.

Example
let proj = project()?;
let cmd = proj.command(["my", "cool", "--args"])?;
if !cmd.empty_stdout() {
    panic!("HELP!!! THE OUTPUT IS INVALID!!");
}
}

Implementations on Foreign Types§

source§

impl WithStdout for Output

source§

fn with_stdout<S: AsRef<str>>(&self, stdout: S)

source§

fn with_stderr<S: AsRef<str>>(&self, stderr: S)

source§

fn with_stderr_regex<S: AsRef<str>>(&self, regex: S)

source§

fn with_stdout_regex<S: AsRef<str>>(&self, regex: S)

source§

fn stdout_warns(&self) -> bool

source§

fn stderr_warns(&self) -> bool

source§

fn empty_stderr(&self) -> bool

source§

fn empty_stdout(&self) -> bool

Implementors§