Skip to content

Commit 69acf76

Browse files
committed
Auto merge of rust-lang#126036 - Oneirical:the-intelligent-intestor, r=<try>
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 0c96061 + 2e4eff7 commit 69acf76

File tree

5 files changed

+47
-47
lines changed

5 files changed

+47
-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
@@ -216,7 +216,6 @@ run-make/sepcomp-cci-copies/Makefile
216216
run-make/sepcomp-inlining/Makefile
217217
run-make/sepcomp-separate/Makefile
218218
run-make/share-generics-dylib/Makefile
219-
run-make/short-ice/Makefile
220219
run-make/silly-file-names/Makefile
221220
run-make/simd-ffi/Makefile
222221
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+
// FIXME do not ignore windows
8+
9+
use run_make_support::rustc;
10+
11+
fn main() {
12+
let rust_test_1 =
13+
rustc().set_backtrace_level("1").input("src/lib.rs").arg("-Ztreat-err-as-bug=1").run_fail();
14+
let rust_test_2 = rustc()
15+
.set_backtrace_level("full")
16+
.input("src/lib.rs")
17+
.arg("-Ztreat-err-as-bug=1")
18+
.run_fail();
19+
20+
let mut rust_test_log_1 = rust_test_1.stderr_utf8();
21+
rust_test_log_1.push_str(&rust_test_1.stdout_utf8());
22+
let rust_test_log_1 = rust_test_log_1.as_str();
23+
24+
let mut rust_test_log_2 = rust_test_2.stderr_utf8();
25+
rust_test_log_2.push_str(&rust_test_2.stdout_utf8());
26+
let rust_test_log_2 = rust_test_log_2.as_str();
27+
28+
let rustc_query_count_full = count_lines_with(rust_test_log_2, "rustc_query_");
29+
30+
assert!(rust_test_log_1.lines().count() < rust_test_log_2.lines().count());
31+
assert_eq!(
32+
count_lines_with(rust_test_log_2, "__rust_begin_short_backtrace"),
33+
count_lines_with(rust_test_log_2, "__rust_end_short_backtrace")
34+
);
35+
assert!(count_lines_with(rust_test_log_1, "rustc_query_") + 5 < rustc_query_count_full);
36+
assert!(rustc_query_count_full > 5);
37+
}
38+
39+
fn count_lines_with(s: &str, search: &str) -> usize {
40+
s.lines().filter(|l| l.contains(search)).count()
41+
}

0 commit comments

Comments
 (0)