Skip to content

Commit 478399a

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

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

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)