Skip to content

Commit

Permalink
test: redact host target when comparing CARGO_ENV path
Browse files Browse the repository at this point in the history
This was found when updating git submodule in rust-lang/rust

```
---- test::cargo_test_env stdout ----
running `/Users/weihanglo/dev/rust/build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/cargo test --lib -- --nocapture`
thread 'test::cargo_test_env' panicked at tests/testsuite/test.rs:3904:10:

test failed running `/Users/weihanglo/dev/rust/build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/cargo test --lib -- --nocapture`
error: expected to find:
/Users/weihanglo/dev/rust/build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/cargo

did not find in output:
[COMPILING] foo v0.5.0 ([ROOT]/foo)
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
[RUNNING] unittests src/lib.rs (target/debug/deps/foo-[HASH])
/Users/weihanglo/dev/rust/build/[HOST_TARGET]/stage2-tools/[HOST_TARGET]/release/cargo
```
  • Loading branch information
weihanglo committed Nov 9, 2024
1 parent c03c580 commit 7347918
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/testsuite/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3870,6 +3870,7 @@ fn doctest_and_registry() {

#[cargo_test]
fn cargo_test_env() {
let rustc_host = rustc_host();
let src = format!(
r#"
#![crate_type = "rlib"]
Expand All @@ -3896,6 +3897,7 @@ fn cargo_test_env() {
.with_extension("")
.to_str()
.unwrap()
.replace(rustc_host, "[HOST_TARGET]")
);
p.cargo("test --lib -- --nocapture")
.with_stderr_contains(cargo)
Expand All @@ -3911,7 +3913,14 @@ test env_test ... ok
.unwrap()
.canonicalize()
.unwrap();
let stderr_rustc = format!("{}[EXE]", rustc.with_extension("").to_str().unwrap());
let stderr_rustc = format!(
"{}[EXE]",
rustc
.with_extension("")
.to_str()
.unwrap()
.replace(rustc_host, "[HOST_TARGET]")
);
p.cargo("test --lib -- --nocapture")
// we use rustc since $CARGO is only used if it points to a path that exists
.env(cargo::CARGO_ENV, rustc)
Expand Down

0 comments on commit 7347918

Please sign in to comment.