Skip to content

Commit

Permalink
rewrite short-ice in rmake format
Browse files Browse the repository at this point in the history
  • Loading branch information
Oneirical committed Jun 6, 2024
1 parent eb5e244 commit d49a7c8
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 47 deletions.
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 @@ -224,7 +224,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.

41 changes: 41 additions & 0 deletions tests/run-make/short-ice/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// 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

use run_make_support::rustc;
use std::env;

fn main() {
env::set_var("RUST_BACKTRACE", "1");
let mut rust_test_1 = rustc().input("src/lib.rs").arg("-Ztreat-err-as-bug=1").run();
env::set_var("RUST_BACKTRACE", "full");
let mut rust_test_2 = rustc().input("src/lib.rs").arg("-Ztreat-err-as-bug=1").run();
let mut log_1 = rust_test_1.stdout;
log_1.append(&mut rust_test_1.stderr);
let mut log_2 = rust_test_2.stdout;
log_2.append(&mut rust_test_2.stderr);
let rust_test_log_1 = &std::str::from_utf8(&log_1).unwrap();
let rust_test_log_2 = &std::str::from_utf8(&log_2).unwrap();

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()
&& count_lines_with(rust_test_log_2, "__rust_begin_short_backtrace")
== count_lines_with(rust_test_log_2, "__rust_end_short_backtrace")
&& count_lines_with(rust_test_log_1, "rustc_query_") + 5 < rustc_query_count_full
&& rustc_query_count_full > 5
);
}

fn count_lines_with(s: &str, search: &str) -> usize {
let mut count = 0;
for line in s.lines() {
if line.contains(search) {
count += 1;
}
}
count
}

0 comments on commit d49a7c8

Please sign in to comment.