Skip to content

Commit 2da492b

Browse files
committed
Add a test showing that cargo metadata differs with CARGO_BUILD_TARGET
This'll change in the next commit.
1 parent 895892e commit 2da492b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/testsuite/metadata.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4954,3 +4954,34 @@ local-time = 1979-05-27
49544954
)
49554955
.run();
49564956
}
4957+
4958+
#[cargo_test]
4959+
fn metadata_ignores_build_target_configuration() -> anyhow::Result<()> {
4960+
let p = project()
4961+
.file(
4962+
"Cargo.toml",
4963+
r#"
4964+
[package]
4965+
name = "foo"
4966+
4967+
[target.'cfg(something)'.dependencies]
4968+
foobar = "0.0.1"
4969+
"#,
4970+
)
4971+
.file("src/lib.rs", "")
4972+
.build();
4973+
Package::new("foobar", "0.0.1").publish();
4974+
4975+
let output1 = p
4976+
.cargo("metadata -q --format-version 1")
4977+
.exec_with_output()?;
4978+
let output2 = p
4979+
.cargo("metadata -q --format-version 1")
4980+
.env("CARGO_BUILD_TARGET", rustc_host())
4981+
.exec_with_output()?;
4982+
assert!(
4983+
output1.stdout != output2.stdout,
4984+
"metadata should change when `CARGO_BUILD_TARGET` is set",
4985+
);
4986+
Ok(())
4987+
}

0 commit comments

Comments
 (0)