Skip to content

Some tests fail if using a non-default target directory #8980

Closed
@Nemo157

Description

@Nemo157

Problem
If you override the target directory and try running cargo's testsuite some of the tests fail to find their data.

Steps

> CARGO_TARGET_DIR=$(mktemp -d) cargo test -- standard_lib::simple_bin_std
[...]
     Running /tmp/tmp.7ILfdJhI9g/debug/deps/testsuite-f6e657c77e54be9a

running 1 test
test standard_lib::simple_bin_std ... FAILED

failures:

---- standard_lib::simple_bin_std stdout ----
running `/tmp/tmp.7ILfdJhI9g/debug/cargo build`
running `/tmp/tmp.7ILfdJhI9g/debug/cargo run -v -Zbuild-std --target x86_64-unknown-linux-gnu`
thread 'standard_lib::simple_bin_std' panicked at '
Expected: execs
    but: exited with exit code: 101
--- stdout

--- stderr
error: failed to read `/tmp/tests/testsuite/mock-std/library/std/Cargo.toml`

Caused by:
  No such file or directory (os error 2)
', crates/cargo-test-support/src/lib.rs:729:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    standard_lib::simple_bin_std

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 2088 filtered out; finished in 0.75s

Possible Solution(s)
Lookup files relative to the source files path, not the compiled binary.

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