Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b65b0b5

Browse files
committedJun 5, 2024
rewrite short-ice in rmake format
1 parent eb5e244 commit b65b0b5

File tree

4 files changed

+41
-47
lines changed

4 files changed

+41
-47
lines changed
 

‎src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ run-make/sepcomp-cci-copies/Makefile
224224
run-make/sepcomp-inlining/Makefile
225225
run-make/sepcomp-separate/Makefile
226226
run-make/share-generics-dylib/Makefile
227-
run-make/short-ice/Makefile
228227
run-make/silly-file-names/Makefile
229228
run-make/simd-ffi/Makefile
230229
run-make/split-debuginfo/Makefile

‎tests/run-make/short-ice/Makefile

-10
This file was deleted.

‎tests/run-make/short-ice/check.sh

-36
This file was deleted.

‎tests/run-make/short-ice/rmake.rs

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Backtraces in internal compiler errors used to be unbearably long, spanning
2+
// multiple hundreds of lines. A fix was pushed in #108938, and this test gathers
3+
// varied metrics on level 1 and full-level backtraces to check that the output
4+
// was shortened down to an appropriate length.
5+
// See https://github.com/rust-lang/rust/issues/107910
6+
7+
use run_make_support::rustc;
8+
use std::env;
9+
10+
fn main() {
11+
env::set_var("RUST_BACKTRACE", "1");
12+
let rust_test_1 = rustc().input("src/lib.rs").arg("-Ztreat-err-as-bug=1").command_output();
13+
env::set_var("RUST_BACKTRACE", "full");
14+
let rust_test_2 = rustc().input("src/lib.rs").arg("-Ztreat-err-as-bug=1").command_output();
15+
let log_1 = rust_test_1.stdout;
16+
log_1.append(&mut rust_test_1.stderr);
17+
let log_2 = rust_test_2.stdout;
18+
log_2.append(&mut rust_test_2.stderr);
19+
let rust_test_log_1 = &std::str::from_utf8(&log_1).unwrap();
20+
let rust_test_log_2 = &std::str::from_utf8(&log_2).unwrap();
21+
22+
let rustc_query_count_full = count_lines_with(rust_test_log_2, "rustc_query_");
23+
24+
assert!(
25+
rust_test_log_1.lines().count() < rust_test_log_2.lines().count()
26+
&& count_lines_with(rust_test_log_2, "__rust_begin_short_backtrace")
27+
== count_lines_with(rust_test_log_2, "__rust_end_short_backtrace")
28+
&& count_lines_with(rust_test_log_1, "rustc_query_") + 5 < rustc_query_count_full
29+
&& rustc_query_count_full > 5
30+
);
31+
}
32+
33+
fn count_lines_with(s: &str, search: &str) -> usize {
34+
let mut count = 0;
35+
for line in s.lines() {
36+
if line.contains(search) {
37+
count += 1;
38+
}
39+
}
40+
count
41+
}

0 commit comments

Comments
 (0)
Failed to load comments.