Skip to content

Commit 8acd554

Browse files
committed
test: Added regression test for new build-dir layout with __CARGO_DEFAULT_LIB_METADATA
1 parent 35f8202 commit 8acd554

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

tests/testsuite/build_dir.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,43 @@ CARGO_BIN_FILE_BAR_bar=[ROOT]/foo/build-dir/debug/build/bar/[HASH]/artifact/bin/
12191219
"#]]);
12201220
}
12211221

1222+
/// __CARGO_DEFAULT_LIB_METADATA is internal but used by rustc bootstrap and https://github.com/RalfJung/rustc-build-sysroot/
1223+
/// Regression test for https://github.com/rust-lang/cargo/issues/16854
1224+
#[cargo_test]
1225+
fn should_work_with_cargo_default_lib_metadata() {
1226+
let p = project()
1227+
.file("src/main.rs", r#"fn main() { println!("Hello, World!") }"#)
1228+
.file("build.rs", r#"fn main() { }"#)
1229+
.file(
1230+
".cargo/config.toml",
1231+
r#"
1232+
[build]
1233+
target-dir = "target-dir"
1234+
build-dir = "build-dir"
1235+
"#,
1236+
)
1237+
.build();
1238+
1239+
p.cargo("-Zbuild-dir-new-layout build")
1240+
.masquerade_as_nightly_cargo(&["new build-dir layout"])
1241+
.env("__CARGO_DEFAULT_LIB_METADATA", "true")
1242+
.enable_mac_dsym()
1243+
.with_status(101)
1244+
.with_stderr_data(str![[r#"
1245+
[COMPILING] foo v0.0.1 ([ROOT]/foo)
1246+
[ERROR] failed to run custom build command for `foo v0.0.1 ([ROOT]/foo)`
1247+
1248+
Caused by:
1249+
could not execute process `[ROOT]/foo/build-dir/debug/build/foo/[HASH]/out/build_script_build[EXE]` (never executed)
1250+
1251+
Caused by:
1252+
[NOT_FOUND]
1253+
1254+
"#]])
1255+
.run();
1256+
1257+
}
1258+
12221259
fn parse_workspace_manifest_path_hash(hash_dir: &PathBuf) -> PathBuf {
12231260
// Since the hash will change between test runs simply find the first directories and assume
12241261
// that is the hash dir. The format is a 2 char directory followed by the remaining hash in the

0 commit comments

Comments
 (0)