Skip to content

Migrate run-make/short-ice to rmake #126036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/tools/run-make-support/src/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ impl Rustc {
self
}

//Adjust the backtrace level, displaying more detailed information at higher levels.
pub fn set_backtrace_level<R: AsRef<OsStr>>(&mut self, level: R) -> &mut Self {
self.cmd.env("RUST_BACKTRACE", level);
self
}

/// Specify path to the output file. Equivalent to `-o`` in rustc.
pub fn output<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
self.cmd.arg("-o");
Expand Down
1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ run-make/sepcomp-cci-copies/Makefile
run-make/sepcomp-inlining/Makefile
run-make/sepcomp-separate/Makefile
run-make/share-generics-dylib/Makefile
run-make/short-ice/Makefile
run-make/silly-file-names/Makefile
run-make/simd-ffi/Makefile
run-make/split-debuginfo/Makefile
Expand Down
10 changes: 0 additions & 10 deletions tests/run-make/short-ice/Makefile

This file was deleted.

36 changes: 0 additions & 36 deletions tests/run-make/short-ice/check.sh

This file was deleted.

42 changes: 42 additions & 0 deletions tests/run-make/short-ice/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Backtraces in internal compiler errors used to be unbearably long, spanning
// multiple hundreds of lines. A fix was pushed in #108938, and this test gathers
// varied metrics on level 1 and full-level backtraces to check that the output
// was shortened down to an appropriate length.
// See https://github.com/rust-lang/rust/issues/107910

//@ ignore-windows
// Reason: the assert_eq! on line 32 fails, as error output on Windows is different.

use run_make_support::rustc;

fn main() {
let rust_test_1 =
rustc().set_backtrace_level("1").input("src/lib.rs").arg("-Ztreat-err-as-bug=1").run_fail();
let rust_test_2 = rustc()
.set_backtrace_level("full")
.input("src/lib.rs")
.arg("-Ztreat-err-as-bug=1")
.run_fail();

let mut rust_test_log_1 = rust_test_1.stderr_utf8();
rust_test_log_1.push_str(&rust_test_1.stdout_utf8());
let rust_test_log_1 = rust_test_log_1.as_str();

let mut rust_test_log_2 = rust_test_2.stderr_utf8();
rust_test_log_2.push_str(&rust_test_2.stdout_utf8());
let rust_test_log_2 = rust_test_log_2.as_str();

let rustc_query_count_full = count_lines_with(rust_test_log_2, "rustc_query_");

assert!(rust_test_log_1.lines().count() < rust_test_log_2.lines().count());
assert_eq!(
count_lines_with(rust_test_log_2, "__rust_begin_short_backtrace"),
count_lines_with(rust_test_log_2, "__rust_end_short_backtrace")
);
assert!(count_lines_with(rust_test_log_1, "rustc_query_") + 5 < rustc_query_count_full);
assert!(rustc_query_count_full > 5);
}

fn count_lines_with(s: &str, search: &str) -> usize {
s.lines().filter(|l| l.contains(search)).count()
}
Loading