Skip to content

Commit 0d52289

Browse files
committed
rewrite dump-ice-to-disk to rmake
1 parent 54be9ad commit 0d52289

File tree

5 files changed

+64
-75
lines changed

5 files changed

+64
-75
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ run-make/cross-lang-lto/Makefile
1010
run-make/dep-info-doesnt-run-much/Makefile
1111
run-make/dep-info-spaces/Makefile
1212
run-make/dep-info/Makefile
13-
run-make/dump-ice-to-disk/Makefile
1413
run-make/emit-to-stdout/Makefile
1514
run-make/export-executable-symbols/Makefile
1615
run-make/extern-flag-disambiguates/Makefile

tests/run-make/dump-ice-to-disk/Makefile

-10
This file was deleted.

tests/run-make/dump-ice-to-disk/check.sh

-64
This file was deleted.
+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// This test checks if internal compilation error (ICE) log files work as expected.
2+
// - Get the number of lines from the log files without any configuration options,
3+
// then check that the line count doesn't change if the backtrace gets configured to be short
4+
// or full.
5+
// - Check that disabling ICE logging results in zero files created.
6+
// - Check that the ICE files contain some of the expected strings.
7+
// See https://github.com/rust-lang/rust/pull/108714
8+
9+
// FIXME(Oneirical): try it on Windows!
10+
11+
use run_make_support::{cwd, fs_wrapper, has_extension, has_prefix, rustc, shallow_find_files};
12+
13+
fn main() {
14+
rustc().input("lib.rs").arg("-Ztreat-err-as-bug=1").run_fail();
15+
let ice_text = get_text_from_ice();
16+
let default_set = ice_text.lines().count();
17+
let content = ice_text;
18+
// Ensure that the ICE files don't contain `:` in their filename because
19+
// this causes problems on Windows.
20+
for file in shallow_find_files(cwd(), |path| {
21+
has_prefix(path, "rustc-ice") && has_extension(path, "txt")
22+
}) {
23+
assert!(!file.display().to_string().contains(":"));
24+
}
25+
26+
clear_ice_files();
27+
rustc().input("lib.rs").env("RUST_BACKTRACE", "short").arg("-Ztreat-err-as-bug=1").run_fail();
28+
let short = get_text_from_ice().lines().count();
29+
clear_ice_files();
30+
rustc().input("lib.rs").env("RUST_BACKTRACE", "full").arg("-Ztreat-err-as-bug=1").run_fail();
31+
let full = get_text_from_ice().lines().count();
32+
clear_ice_files();
33+
34+
// The ICE dump is explicitely disabled. Therefore, this should produce no files.
35+
rustc().env("RUSTC_ICE", "0").input("lib.rs").arg("-Ztreat-err-as-bug=1").run_fail();
36+
assert!(get_text_from_ice().is_empty());
37+
38+
// The line count should not change.
39+
assert_eq!(short, default_set);
40+
assert_eq!(full, default_set);
41+
// Some of the expected strings in an ICE file should appear.
42+
assert!(content.contains("thread 'rustc' panicked at"));
43+
assert!(content.contains("stack backtrace:"));
44+
}
45+
46+
fn clear_ice_files() {
47+
let ice_files = shallow_find_files(cwd(), |path| {
48+
has_prefix(path, "rustc-ice") && has_extension(path, "txt")
49+
});
50+
for file in ice_files {
51+
fs_wrapper::remove_file(file);
52+
}
53+
}
54+
55+
fn get_text_from_ice() -> String {
56+
let ice_files = shallow_find_files(cwd(), |path| {
57+
has_prefix(path, "rustc-ice") && has_extension(path, "txt")
58+
});
59+
let mut output = String::new();
60+
for file in ice_files {
61+
output.push_str(&fs_wrapper::read_to_string(file));
62+
}
63+
output
64+
}

0 commit comments

Comments
 (0)