Skip to content
This repository was archived by the owner on Dec 29, 2021. It is now read-only.
This repository was archived by the owner on Dec 29, 2021. It is now read-only.

stderr().is() fails due to cargo output #45

@steveej

Description

@steveej

Hey, during my first attempts of writing integration tests I've stumbled upon an issue when the program is supposed to exit with an error output.

My test looks like this:

    #[test]
    fn called_without_args() {
        assert_cli::Assert::main_binary()
            .fails_with(::libc::EINVAL)
            .and()
            .stderr().is(MISSING_ARGUMENTS_OUTPUT)
            .unwrap();
    }
test integration::called_without_args ... FAILED

failures:

---- integration::called_without_args stdout ----
        thread 'integration::called_without_args' panicked at 'CLI assertion failed: `cargo run --` StdErr mismatch: diff:

+Compiling invsearch v0.1.0 (file:///.../invsearch.rs)
    Finished dev [unoptimized + debuginfo] target(s) in 0.62 secs
     Running `target/debug/invsearch`
 No arguments provided. Please provide files to parse.
', /home/steveej/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/assert_cli-0.5.3/src/assert.rs:319:12
note: Run with `RUST_BACKTRACE=1` for a backtrace.

The issue is that the error outputs of cargo and the integration test are mixed and the test fails because it's not an exact match.
I know that I could just use .contains(..) instead of .is(..), but IMHO that's only a workaround.

Please let me know if I'm doing something unexpected, as this is my very first attempt of writing (integration) tests in Rust.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions