-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OUT_DIR
env var Behaviour discrepancy between testing a whole crate and individual test
#13127
Comments
We limit what build targets get processed when specifying a test as an optimization, see https://github.com/rust-lang/cargo/blob/master/src/bin/cargo/commands/test.rs#L100 I'm guessing we don't set By looking at the code, I'm guessing The question is which behavior is more correct. |
My interpretation of "running binaries" are the binary targets (i.e. |
Hadn't had a chance to check the docs yet. The only way to set it for running the bins is if we set it for running the tests. Looks like we aren't lining up with the documentation. |
I believe this was an unintentional regression in 1.15 via #3310. The code has moved around a bit, but it now looks like this: cargo/src/cargo/core/compiler/context/mod.rs Lines 216 to 234 in 749654c
The problem is that it is only including
I can try to explain it further if that isn't clear. |
@rustbot claim I will try to fix it. |
Problem
Hi! I want to run the integration tests of a lib crate (
my_crate_2
) in my rust project. The crate has such structure:In
tests/my_crate_2.rs
, I need to extract artifacts output path of the package, i.e., theOUT_DIR
env var, which should be set byCargo
.I observed a
cargo test
behaviour discrepancy onOUT_DIR
env var between running tests against the whole package and a single/specific test. I created this sandbox to demo: here.The test:
test_add()
will fail ifOUT_DIR
env var is not set:If you run the whole test package (
cargo test -- --nocapture
) inmy_crate_2/
, the test can pass without a problem.But if I only run a specific test:
cargo test --package my_crate_2 --test my_crate_2 -- tests::test_add --nocapture
, the test would fail withOUT_DIR
env var not found.Looks like
cargo test --package <package_name> -- <test_name>
lose theOUT_DIR
env var? Thank you for your help.Steps
Provided in the description
Possible Solution(s)
No response
Notes
No response
Version
The text was updated successfully, but these errors were encountered: