Skip to content

Commit 5c706e8

Browse files
committed
test: avoid hardcoded target spec json
Read a real target spec JSON so we no longer need to hardcode a target spec JSON here. Cargo itself should not care about the spec schema. Let's stop bothering compiler contributors.
1 parent 623d536 commit 5c706e8

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

tests/testsuite/rustc.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -818,17 +818,23 @@ windows
818818

819819
#[cargo_test]
820820
fn rustc_with_print_cfg_config_toml_env() {
821+
// We read from a built-in target json spec, so schema change won't block
822+
// compiler contributors on fixing failing Cargo tests.
823+
let target_json_spec = std::process::Command::new("rustc")
824+
.env("RUSTC_BOOTSTRAP", "1")
825+
.arg("--print")
826+
.arg("target-spec-json")
827+
.arg("-Zunstable-options")
828+
.arg("--target")
829+
.arg("x86_64-unknown-none")
830+
.output()
831+
.unwrap()
832+
.stdout;
833+
let target_json_spec = String::from_utf8_lossy(&target_json_spec);
834+
821835
let p = project()
822836
.file("Cargo.toml", &basic_bin_manifest("foo"))
823-
.file(
824-
"targets/best-target.json",
825-
r#"{
826-
"llvm-target": "x86_64-unknown-none",
827-
"target-pointer-width": "64",
828-
"data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128",
829-
"arch": "x86_64"
830-
}"#,
831-
)
837+
.file("targets/best-target.json", &target_json_spec)
832838
.file(
833839
".cargo/config.toml",
834840
r#"

0 commit comments

Comments
 (0)