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

Prefix assertion command with user specified command #114

Closed
azriel91 opened this issue Jun 13, 2018 · 2 comments
Closed

Prefix assertion command with user specified command #114

azriel91 opened this issue Jun 13, 2018 · 2 comments

Comments

@azriel91
Copy link
Contributor

Hiya! I'm wondering if it's a good idea to allow users to prefix an assertion command with their own command. The use case is being able to run a cargo binary / example under kcov or some other wrapper tool.

What it could look like:

#[test]
fn menu_example() {
    let kcov_command = &[
        "kcov",
        &format!("--include-pattern={}/src", env!("CARGO_MANIFEST_DIR")),
        &format!("{}/coverage", env!("CARGO_TARGET_DIR"))
    ];

    assert_cli::Assert::example("01_menu")
        .with_prefix(kcov_command)
        .stdin("exit\n")
        .unwrap();
}
@azriel91
Copy link
Contributor Author

azriel91 commented Jun 13, 2018

Hm, I just realized, it's meant to run something like:

kcov --include-pattern=/path/to/workspace/crate/src \
     /path/to/workspace/target/coverage \
     /path/to/workspace/target/debug/examples/01_menu

but instead it would run

kcov --include-pattern=/path/to/workspace/crate/src \
     /path/to/workspace/target/coverage \
     cargo run --example 01_menu

which wouldn't have line coverage tracked by kcov, since cargo is an intermediate binary.

ah well it was a nice thought; I'll have to live with sprinkling // kcov-ignores and // covered by integration test everywhere then

@azriel91
Copy link
Contributor Author

See assert-rs/assert_cmd#9 where this may be addressed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant