Skip to content

cargo_bin returns incorrect paths when build-dir is used #257

@kornelski

Description

@kornelski

assert_cmd::cargo::cargo_bin returns incorrect path when used from integration tests. The tests are ran from the build-dir, but assert_cmd expects them to be in the target-dir.

assert_cmd/src/cargo.rs

Lines 220 to 233 in ee88946

// Adapted from
// https://github.com/rust-lang/cargo/blob/485670b3983b52289a2f353d589c57fae2f60f82/tests/testsuite/support/mod.rs#L507
fn target_dir() -> path::PathBuf {
env::current_exe()
.ok()
.map(|mut path| {
path.pop();
if path.ends_with("deps") {
path.pop();
}
path
})
.expect("this should only be used where a `current_exe` can be set")
}

The same code in snapbox is already deprecated:

https://github.com/assert-rs/snapbox/blob/90fd7f0c6d9e0d462bfcaa3a8df66a462a2be28a/crates/snapbox/src/cmd.rs#L854-L877

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions