Skip to content

Commit ef4835f

Browse files
committed
rewrite short-ice in rmake format
1 parent eb5e244 commit ef4835f

File tree

3 files changed

+39
-46
lines changed

3 files changed

+39
-46
lines changed

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

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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 rust_test_log_1 =
16+
&std::str::from_utf8(rust_test_1.stdout.append(&mut rust_test_1.stderr)).unwrap();
17+
let rust_test_log_2 =
18+
&std::str::from_utf8(rust_test_2.stdout.append(&mut rust_test_2.stderr)).unwrap();
19+
20+
let rustc_query_count_full = count_lines_with(rust_test_log_2, "rustc_query_");
21+
22+
assert!(
23+
rust_test_log_1.lines().count() < rust_test_log_2.lines().count()
24+
&& count_lines_with(rust_test_log_2, "__rust_begin_short_backtrace")
25+
== count_lines_with(rust_test_log_2, "__rust_end_short_backtrace")
26+
&& count_lines_with(rust_test_log_1, "rustc_query_") + 5 < rustc_query_count_full
27+
&& rustc_query_count_full > 5
28+
);
29+
}
30+
31+
fn count_lines_with(s: &str, search: &str) -> usize {
32+
let mut count = 0;
33+
for line in s.lines() {
34+
if line.contains(search) {
35+
count += 1;
36+
}
37+
}
38+
count
39+
}

0 commit comments

Comments
 (0)