Skip to content

Commit 0ab14a6

Browse files
committed
test(cfg): parse rustc --print=target-spec-json
1 parent a60fb6c commit 0ab14a6

File tree

4 files changed

+46
-6
lines changed

4 files changed

+46
-6
lines changed

tests/testsuite/artifact_dep.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ fn check_with_invalid_target_triple() {
149149
[ERROR] failed to run `rustc` to learn about target-specific information
150150
151151
Caused by:
152-
process didn't exit successfully: `rustc - --crate-name ___ --print=file-names --target unknown-target-triple [..]` ([EXIT_STATUS]: 1)
152+
process didn't exit successfully: `rustc - --crate-name ___ -Zunstable-options --print=file-names --target unknown-target-triple [..]` ([EXIT_STATUS]: 1)
153153
--- stderr
154154
[ERROR] Error loading target specification: Could not find specification for target "unknown-target-triple". Run `rustc --print target-list` for a list of built-in targets
155155

tests/testsuite/bad_config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ fn bad_crate_type() {
425425
[ERROR] failed to run `rustc` to learn about crate-type bad_type information
426426
427427
Caused by:
428-
process didn't exit successfully: `rustc - --crate-name ___ --print=file-names --crate-type bad_type` ([EXIT_STATUS]: 1)
428+
process didn't exit successfully: `rustc - --crate-name ___ -Zunstable-options --print=file-names --crate-type bad_type` ([EXIT_STATUS]: 1)
429429
--- stderr
430430
[ERROR] unknown crate type: `bad_type`
431431

tests/testsuite/build.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5199,7 +5199,7 @@ fn rustc_wrapper_queries() {
51995199
.env("RUSTC_WRAPPER", &wrapper)
52005200
.with_stderr_contains("[..]running [..]rustc-echo-wrapper[EXE] rustc -vV[..]")
52015201
.with_stderr_contains(
5202-
"[..]running [..]rustc-echo-wrapper[EXE] rustc - --crate-name ___ --print[..]",
5202+
"[..]running [..]rustc-echo-wrapper[EXE] rustc - --crate-name ___ -Zunstable-options --print[..]",
52035203
)
52045204
.run();
52055205
p.build_dir().rm_rf();
@@ -5208,7 +5208,7 @@ fn rustc_wrapper_queries() {
52085208
.env("RUSTC_WORKSPACE_WRAPPER", &wrapper)
52095209
.with_stderr_contains("[..]running [..]rustc-echo-wrapper[EXE] rustc -vV[..]")
52105210
.with_stderr_contains(
5211-
"[..]running [..]rustc-echo-wrapper[EXE] rustc - --crate-name ___ --print[..]",
5211+
"[..]running [..]rustc-echo-wrapper[EXE] rustc - --crate-name ___ -Zunstable-options --print[..]",
52125212
)
52135213
.run();
52145214
}

tests/testsuite/cfg.rs

+42-2
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,17 @@ fn bad_cfg_discovery() {
387387
}
388388
};
389389
390+
if mode == "no-target-spec-json" {
391+
return;
392+
}
393+
loop {
394+
let line = lines.next().unwrap();
395+
println!("{line}");
396+
if line == "}" {
397+
break;
398+
}
399+
}
400+
390401
if mode != "bad-cfg" {
391402
panic!("unexpected");
392403
}
@@ -471,10 +482,34 @@ command was: `[..]compiler[..]--crate-type [..]`
471482

472483
p.cargo("check")
473484
.env("RUSTC", &funky_rustc)
474-
.env("FUNKY_MODE", "bad-cfg")
485+
.env("FUNKY_MODE", "no-target-spec-json")
475486
.with_status(101)
476487
.with_stderr(
477488
"\
489+
[ERROR] output of --print=target-spec-json missing when learning about target-specific information from rustc
490+
command was: `[..]compiler[..]--crate-type [..]`
491+
492+
--- stdout
493+
[..]___[..]
494+
[..]___[..]
495+
[..]___[..]
496+
[..]___[..]
497+
[..]___[..]
498+
[..]___[..]
499+
[..]
500+
[..]
501+
___
502+
503+
",
504+
)
505+
.run();
506+
507+
p.cargo("check")
508+
.env("RUSTC", &funky_rustc)
509+
.env("FUNKY_MODE", "bad-cfg")
510+
.with_status(101)
511+
.with_stderr_contains(
512+
"\
478513
[ERROR] failed to parse the cfg from `rustc --print=cfg`, got:
479514
[..]___[..]
480515
[..]___[..]
@@ -483,8 +518,13 @@ command was: `[..]compiler[..]--crate-type [..]`
483518
[..]___[..]
484519
[..]___[..]
485520
[..]
486-
[..],[..]
521+
[..]
487522
___
523+
{
524+
",
525+
)
526+
.with_stderr_contains(
527+
"\
488528
123
489529
490530

0 commit comments

Comments
 (0)