Skip to content

Commit 635b731

Browse files
Auto merge of #143669 - jieyouxu:fmt-write-bloat, r=<try>
Make sure `fmt-write-bloat` doesn't vacuously pass on no symbols try-job: aarch64-apple try-job: aarch64-msvc-1 try-job: x86_64-msvc-1 try-job: i686-msvc-1 try-job: x86_64-mingw-1
2 parents a0f398e + 1946935 commit 635b731

File tree

1 file changed

+61
-7
lines changed

1 file changed

+61
-7
lines changed

tests/run-make/fmt-write-bloat/rmake.rs

Lines changed: 61 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,78 @@
1212
//! present.
1313
//!
1414
//! Some CI jobs try to run faster by disabling debug assertions (through setting
15-
//! `NO_DEBUG_ASSERTIONS=1`). If debug assertions are disabled, then we can check for the absence of
16-
//! additional `usize` formatting and padding related symbols.
15+
//! `NO_DEBUG_ASSERTIONS=1`). If std debug assertions are disabled, then we can check for the
16+
//! absence of additional `usize` formatting and padding related symbols.
17+
18+
// ignore-tidy-linelength
1719

1820
//@ ignore-cross-compile
1921

20-
use run_make_support::artifact_names::bin_name;
22+
use std::path::Path;
23+
2124
use run_make_support::env::std_debug_assertions_enabled;
22-
use run_make_support::rustc;
25+
use run_make_support::llvm::{llvm_filecheck, llvm_pdbutil};
2326
use run_make_support::symbols::object_contains_any_symbol_substring;
27+
use run_make_support::{is_windows_msvc, rfs, rustc};
2428

2529
fn main() {
26-
rustc().input("main.rs").opt().run();
2730
// panic machinery identifiers, these should not appear in the final binary
2831
let mut panic_syms = vec!["panic_bounds_check", "Debug"];
29-
if std_debug_assertions_enabled() {
32+
if !std_debug_assertions_enabled() {
3033
// if debug assertions are allowed, we need to allow these,
3134
// otherwise, add them to the list of symbols to deny.
3235
panic_syms.extend_from_slice(&["panicking", "panic_fmt", "pad_integral", "Display"]);
3336
}
34-
assert!(!object_contains_any_symbol_substring(bin_name("main"), &panic_syms));
37+
38+
let expect_no_panic_symbols = Path::new("expect_no_panic_symbols");
39+
rustc().input("main.rs").output(&expect_no_panic_symbols).opt().run();
40+
41+
let expect_panic_symbols = Path::new("expect_panic_symbols");
42+
rustc().input("main.rs").output(&expect_panic_symbols).run();
43+
44+
if is_windows_msvc() {
45+
// FIXME(#143737): use actual DIA wrappers instead of parsing `llvm-pdbutil` textual output.
46+
47+
let expect_no_filecheck_pattern = r#"
48+
CHECK: main
49+
CHECK-NOT: {{.*}}Display{{.*}}
50+
CHECK-NOT: {{.*}}panic_bounds_check{{.*}}
51+
"#;
52+
let expect_no_filecheck_path = Path::new("expect_no_panic_symbols_filecheck.txt");
53+
rfs::write(&expect_no_filecheck_path, expect_no_filecheck_pattern);
54+
55+
let expect_no_panic_symbols_pdbutil_dump = llvm_pdbutil()
56+
.arg("dump")
57+
.arg("-publics")
58+
.input(expect_no_panic_symbols.with_extension("pdb"))
59+
.run();
60+
llvm_filecheck()
61+
.patterns(expect_no_filecheck_path)
62+
.stdin_buf(expect_no_panic_symbols_pdbutil_dump.stdout_utf8())
63+
.run();
64+
65+
let expect_filecheck_pattern = r#"
66+
CHECK: main
67+
CHECK: {{.*}}core{{.*}}fmt{{.*}}write{{.*}}
68+
CHECK: {{.*}}core{{.*}}panicking{{.*}}panic_fmt{{.*}}
69+
// _ZN4core3fmt3num3imp54_$LT$impl$u20$core..fmt..Display$u20$for$u20$usize...
70+
CHECK: {{.*}}Display{{.*}}
71+
CHECK-NOT: {{.*}}panic_bounds_check{{.*}}
72+
"#;
73+
let expect_filecheck_path = Path::new("expect_panic_symbols_filecheck.txt");
74+
rfs::write(&expect_filecheck_path, expect_filecheck_pattern);
75+
76+
let expect_panic_symbols_pdbutil_dump = llvm_pdbutil()
77+
.arg("dump")
78+
.arg("-publics")
79+
.input(expect_panic_symbols.with_extension("pdb"))
80+
.run();
81+
llvm_filecheck()
82+
.patterns(expect_filecheck_path)
83+
.stdin_buf(expect_panic_symbols_pdbutil_dump.stdout_utf8())
84+
.run();
85+
} else {
86+
assert!(!object_contains_any_symbol_substring(&expect_no_panic_symbols, &panic_syms));
87+
assert!(object_contains_any_symbol_substring(&expect_panic_symbols, &panic_syms));
88+
}
3589
}

0 commit comments

Comments
 (0)