mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-02 10:18:25 +00:00

`panic!` does not print any identifying information for threads that are unnamed. However, in many cases, the thread ID can be determined. This changes the panic message from something like this: thread '<unnamed>' panicked at src/main.rs:3:5: explicit panic To something like this: thread '<unnamed>' (0xff9bf) panicked at src/main.rs:3:5: explicit panic Stack overflow messages are updated as well. This change applies to both named and unnamed threads. The ID printed is the OS integer thread ID rather than the Rust thread ID, which should also be what debuggers print.
33 lines
1.0 KiB
Rust
33 lines
1.0 KiB
Rust
// Check libtest's JUnit (XML) output against snapshots.
|
|
|
|
//@ ignore-cross-compile
|
|
//@ needs-unwind (test file contains #[should_panic] test)
|
|
|
|
use run_make_support::{cmd, diff, python_command, rustc};
|
|
|
|
fn main() {
|
|
rustc().arg("--test").input("f.rs").run();
|
|
|
|
run_tests(&[], "output-default.xml");
|
|
run_tests(&["--show-output"], "output-stdout-success.xml");
|
|
}
|
|
|
|
#[track_caller]
|
|
fn run_tests(extra_args: &[&str], expected_file: &str) {
|
|
let cmd_out = cmd("./f")
|
|
.env("RUST_BACKTRACE", "0")
|
|
.args(&["-Zunstable-options", "--test-threads=1", "--format=junit"])
|
|
.args(extra_args)
|
|
.run_fail();
|
|
let test_stdout = &cmd_out.stdout_utf8();
|
|
|
|
python_command().arg("validate_junit.py").stdin_buf(test_stdout).run();
|
|
|
|
diff()
|
|
.expected_file(expected_file)
|
|
.actual_text("stdout", test_stdout)
|
|
.normalize(r#"\btime="[0-9.]+""#, r#"time="$$TIME""#)
|
|
.normalize(r"thread '(?P<name>.*?)' \(\d+\) panicked", "thread '$name' ($$TID) panicked")
|
|
.run();
|
|
}
|