Skip to content

Commit 79388f6

Browse files
authored
Rollup merge of rust-lang#126036 - Oneirical:the-intelligent-intestor, r=jieyouxu
Migrate `run-make/short-ice` to `rmake` Part of rust-lang#121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).
2 parents 0de24a5 + bba05d6 commit 79388f6

File tree

5 files changed

+45
-47
lines changed

5 files changed

+45
-47
lines changed

src/tools/run-make-support/src/rustc.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ impl Rustc {
100100
self
101101
}
102102

103+
//Adjust the backtrace level, displaying more detailed information at higher levels.
104+
pub fn set_backtrace_level<R: AsRef<OsStr>>(&mut self, level: R) -> &mut Self {
105+
self.cmd.env("RUST_BACKTRACE", level);
106+
self
107+
}
108+
103109
/// Specify path to the output file. Equivalent to `-o`` in rustc.
104110
pub fn output<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
105111
self.cmd.arg("-o");

src/tools/tidy/src/allowed_run_make_makefiles.txt

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 10 deletions
This file was deleted.

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

Lines changed: 0 additions & 36 deletions
This file was deleted.

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

Lines changed: 39 additions & 0 deletions
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+
9+
fn main() {
10+
let rust_test_1 =
11+
rustc().set_backtrace_level("1").input("src/lib.rs").arg("-Ztreat-err-as-bug=1").run_fail();
12+
let rust_test_2 = rustc()
13+
.set_backtrace_level("full")
14+
.input("src/lib.rs")
15+
.arg("-Ztreat-err-as-bug=1")
16+
.run_fail();
17+
18+
let mut rust_test_log_1 = rust_test_1.stderr_utf8();
19+
rust_test_log_1.push_str(&rust_test_1.stdout_utf8());
20+
let rust_test_log_1 = rust_test_log_1.as_str();
21+
22+
let mut rust_test_log_2 = rust_test_2.stderr_utf8();
23+
rust_test_log_2.push_str(&rust_test_2.stdout_utf8());
24+
let rust_test_log_2 = rust_test_log_2.as_str();
25+
26+
let rustc_query_count_full = count_lines_with(rust_test_log_2, "rustc_query_");
27+
28+
assert!(
29+
rust_test_log_1.lines().count() < rust_test_log_2.lines().count()
30+
&& count_lines_with(rust_test_log_2, "__rust_begin_short_backtrace")
31+
== count_lines_with(rust_test_log_2, "__rust_end_short_backtrace")
32+
&& count_lines_with(rust_test_log_1, "rustc_query_") + 5 < rustc_query_count_full
33+
&& rustc_query_count_full > 5
34+
);
35+
}
36+
37+
fn count_lines_with(s: &str, search: &str) -> usize {
38+
s.lines().filter(|l| l.contains(search)).count()
39+
}

0 commit comments

Comments
 (0)