Skip to main content

TestOutputSink

Trait TestOutputSink 

Source
pub trait TestOutputSink {
    // Required methods
    fn write_stdout(
        &mut self,
        executable: &TestExecutable,
        bytes: &[u8],
    ) -> Result<()>;
    fn write_stderr(
        &mut self,
        executable: &TestExecutable,
        bytes: &[u8],
    ) -> Result<()>;

    // Provided method
    fn test_finished(&mut self, result: &TestRunResult) -> Result<()> { ... }
}
Expand description

Sink for test executable output. The runner forwards stdout / stderr chunks to this sink while each process is still running, and also keeps a full captured copy in TestRunResult. Tests in this crate use null_sink to discard output.

Required Methods§

Source

fn write_stdout( &mut self, executable: &TestExecutable, bytes: &[u8], ) -> Result<()>

Called zero or more times per executable with stdout bytes.

§Errors

Returns the implementor’s io::Error if the sink fails to write the supplied stdout bytes.

Source

fn write_stderr( &mut self, executable: &TestExecutable, bytes: &[u8], ) -> Result<()>

Called zero or more times per executable with stderr bytes.

§Errors

Returns the implementor’s io::Error if the sink fails to write the supplied stderr bytes.

Provided Methods§

Source

fn test_finished(&mut self, result: &TestRunResult) -> Result<()>

Called exactly once per executable, immediately after it exits and before the next executable starts. Streaming sinks render the per-test result line here so multi-test runs report progress the way cargo test does. The default implementation does nothing.

§Errors

Returns the implementor’s io::Error if the sink fails to write the result line.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl TestOutputSink for ()

Source§

fn write_stdout( &mut self, _executable: &TestExecutable, _bytes: &[u8], ) -> Result<()>

Source§

fn write_stderr( &mut self, _executable: &TestExecutable, _bytes: &[u8], ) -> Result<()>

Implementors§

Source§

impl<W1: Write, W2: Write> TestOutputSink for StreamingSink<W1, W2>