Skip to content

Commit f88c647

Browse files
committed
rewrite short-ice in rmake format
1 parent 7bb0ef4 commit f88c647

File tree

4 files changed

+31
-47
lines changed

4 files changed

+31
-47
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ run-make/sepcomp-cci-copies/Makefile
218218
run-make/sepcomp-inlining/Makefile
219219
run-make/sepcomp-separate/Makefile
220220
run-make/share-generics-dylib/Makefile
221-
run-make/short-ice/Makefile
222221
run-make/silly-file-names/Makefile
223222
run-make/simd-ffi/Makefile
224223
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

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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 mut rust_test_1 = rustc().input("src/lib.rs").arg("-Ztreat-err-as-bug=1").run_fail();
13+
env::set_var("RUST_BACKTRACE", "full");
14+
let mut rust_test_2 = rustc().input("src/lib.rs").arg("-Ztreat-err-as-bug=1").run_fail();
15+
let rust_test_log_1 = rust_test_1.stderr_utf8().push_str(&rust_test_1.stdout_utf8()).as_str();
16+
let rust_test_log_2 = rust_test_2.stderr_utf8().push_str(&rust_test_2.stdout_utf8()).as_str();
17+
18+
let rustc_query_count_full = count_lines_with(rust_test_log_2, "rustc_query_");
19+
20+
assert!(
21+
rust_test_log_1.lines().count() < rust_test_log_2.lines().count()
22+
&& count_lines_with(rust_test_log_2, "__rust_begin_short_backtrace")
23+
== count_lines_with(rust_test_log_2, "__rust_end_short_backtrace")
24+
&& count_lines_with(rust_test_log_1, "rustc_query_") + 5 < rustc_query_count_full
25+
&& rustc_query_count_full > 5
26+
);
27+
}
28+
29+
fn count_lines_with(s: &str, search: &str) -> usize {
30+
s.lines().filter(|l| l.contains(search)).count()
31+
}

0 commit comments

Comments
 (0)