Skip to content

Commit d25227c

Browse files
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). try-job: x86_64-msvc
2 parents 88984fe + 8a6bc13 commit d25227c

File tree

5 files changed

+48
-47
lines changed

5 files changed

+48
-47
lines changed

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

+6
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ impl Rustc {
105105
self
106106
}
107107

108+
//Adjust the backtrace level, displaying more detailed information at higher levels.
109+
pub fn set_backtrace_level<R: AsRef<OsStr>>(&mut self, level: R) -> &mut Self {
110+
self.cmd.env("RUST_BACKTRACE", level);
111+
self
112+
}
113+
108114
/// Specify path to the output file. Equivalent to `-o`` in rustc.
109115
pub fn output<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
110116
self.cmd.arg("-o");

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ run-make/sepcomp-cci-copies/Makefile
214214
run-make/sepcomp-inlining/Makefile
215215
run-make/sepcomp-separate/Makefile
216216
run-make/share-generics-dylib/Makefile
217-
run-make/short-ice/Makefile
218217
run-make/silly-file-names/Makefile
219218
run-make/simd-ffi/Makefile
220219
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

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
//@ ignore-windows
8+
// Reason: the assert_eq! on line 32 fails, as error output on Windows is different.
9+
10+
use run_make_support::rustc;
11+
12+
fn main() {
13+
let rust_test_1 =
14+
rustc().set_backtrace_level("1").input("src/lib.rs").arg("-Ztreat-err-as-bug=1").run_fail();
15+
let rust_test_2 = rustc()
16+
.set_backtrace_level("full")
17+
.input("src/lib.rs")
18+
.arg("-Ztreat-err-as-bug=1")
19+
.run_fail();
20+
21+
let mut rust_test_log_1 = rust_test_1.stderr_utf8();
22+
rust_test_log_1.push_str(&rust_test_1.stdout_utf8());
23+
let rust_test_log_1 = rust_test_log_1.as_str();
24+
25+
let mut rust_test_log_2 = rust_test_2.stderr_utf8();
26+
rust_test_log_2.push_str(&rust_test_2.stdout_utf8());
27+
let rust_test_log_2 = rust_test_log_2.as_str();
28+
29+
let rustc_query_count_full = count_lines_with(rust_test_log_2, "rustc_query_");
30+
31+
assert!(rust_test_log_1.lines().count() < rust_test_log_2.lines().count());
32+
assert_eq!(
33+
count_lines_with(rust_test_log_2, "__rust_begin_short_backtrace"),
34+
count_lines_with(rust_test_log_2, "__rust_end_short_backtrace")
35+
);
36+
assert!(count_lines_with(rust_test_log_1, "rustc_query_") + 5 < rustc_query_count_full);
37+
assert!(rustc_query_count_full > 5);
38+
}
39+
40+
fn count_lines_with(s: &str, search: &str) -> usize {
41+
s.lines().filter(|l| l.contains(search)).count()
42+
}

0 commit comments

Comments
 (0)