Skip to content

Commit 56e4ec0

Browse files
committed
Auto merge of rust-lang#127523 - Oneirical:treasure-test, r=<try>
Migrate `dump-ice-to-disk` and `panic-abort-eh_frame` `run-make` tests 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). Please try: try-job: aarch64-apple try-job: x86_64-msvc
2 parents f25e92b + 7b37e2b commit 56e4ec0

File tree

7 files changed

+86
-86
lines changed

7 files changed

+86
-86
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ run-make/cross-lang-lto/Makefile
2121
run-make/dep-info-doesnt-run-much/Makefile
2222
run-make/dep-info-spaces/Makefile
2323
run-make/dep-info/Makefile
24-
run-make/dump-ice-to-disk/Makefile
2524
run-make/dump-mono-stats/Makefile
2625
run-make/emit-to-stdout/Makefile
2726
run-make/env-dep-info/Makefile
@@ -96,7 +95,6 @@ run-make/no-alloc-shim/Makefile
9695
run-make/no-builtins-attribute/Makefile
9796
run-make/no-duplicate-libs/Makefile
9897
run-make/obey-crate-type-flag/Makefile
99-
run-make/panic-abort-eh_frame/Makefile
10098
run-make/pass-non-c-like-enum-to-c/Makefile
10199
run-make/pdb-buildinfo-cl-cmd/Makefile
102100
run-make/pgo-gen-lto/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+
}

tests/run-make/panic-abort-eh_frame/Makefile

-10
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// An `.eh_frame` section in an object file is a symptom of an UnwindAction::Terminate
2+
// being inserted, useful for determining whether or not unwinding is necessary.
3+
// This is useless when panics would NEVER unwind due to -C panic=abort. This section should
4+
// therefore never appear in the emit file of a -C panic=abort compilation, and this test
5+
// checks that this is respected.
6+
// See https://github.com/rust-lang/rust/pull/112403
7+
8+
// FIXME(Oneirical): try it on more than only-linux!
9+
10+
use run_make_support::{llvm_objdump, rustc};
11+
12+
fn main() {
13+
rustc()
14+
.input("foo.rs")
15+
.crate_type("lib")
16+
.emit("obj=foo.o")
17+
.panic("abort")
18+
.edition("2021")
19+
.arg("-Zvalidate-mir")
20+
.run();
21+
llvm_objdump().arg("--dwarf=frames").input("foo.o").run().assert_stdout_not_contains("DW_CFA");
22+
}

0 commit comments

Comments
 (0)