Skip to content

Commit 5f016c8

Browse files
committed
test: make sure fmt-write-bloat does not vacuously pass
1 parent 7950f24 commit 5f016c8

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

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

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,42 @@
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.
1717
1818
//@ ignore-cross-compile
1919

20-
use run_make_support::artifact_names::bin_name;
20+
use std::path::Path;
21+
2122
use run_make_support::env::std_debug_assertions_enabled;
22-
use run_make_support::rustc;
2323
use run_make_support::symbols::object_contains_any_symbol_substring;
24+
use run_make_support::{is_darwin, rustc};
25+
26+
// Not applicable for `extern "C"` symbol decoration handling.
27+
fn sym(sym_name: &str) -> String {
28+
if is_darwin() {
29+
// Symbols are decorated with an underscore prefix on darwin platforms.
30+
format!("_{sym_name}")
31+
} else {
32+
sym_name.to_string()
33+
}
34+
}
2435

2536
fn main() {
26-
rustc().input("main.rs").opt().run();
2737
// panic machinery identifiers, these should not appear in the final binary
2838
let mut panic_syms = vec!["panic_bounds_check", "Debug"];
2939
if std_debug_assertions_enabled() {
3040
// if debug assertions are allowed, we need to allow these,
3141
// otherwise, add them to the list of symbols to deny.
3242
panic_syms.extend_from_slice(&["panicking", "panic_fmt", "pad_integral", "Display"]);
3343
}
34-
assert!(!object_contains_any_symbol_substring(bin_name("main"), &panic_syms));
44+
let panic_syms = panic_syms.into_iter().map(|name| sym(name)).collect::<Vec<_>>();
45+
46+
let expect_no_panic_symbols = Path::new("expect_no_panic_symbols");
47+
rustc().input("main.rs").output(&expect_no_panic_symbols).opt().run();
48+
assert!(!object_contains_any_symbol_substring(&expect_no_panic_symbols, &panic_syms));
49+
50+
let expect_panic_symbols = Path::new("expect_panic_symbols");
51+
rustc().input("main.rs").output(&expect_panic_symbols).run();
52+
assert!(object_contains_any_symbol_substring(&expect_panic_symbols, &panic_syms));
3553
}

0 commit comments

Comments
 (0)