|
1 | 1 | /* This tests a lot of fiddly platform-specific impl details.
|
2 |
| - It will probably flake a lot for a while. Feel free to split it up into |
3 |
| - different tests or add more `ignore-` directives. If at all possible, rather |
4 |
| - than removing the assert that the different revisions behave the same, move |
5 |
| - only the revisions that are failing into a separate test, so that the rest |
6 |
| - are still kept the same. |
7 |
| -
|
8 |
| - TODO: this test is megacursed, either split it into a separate run-make test |
9 |
| - that looks at the .stderr files or get `compare-mode` working |
10 |
| - */ |
| 2 | + It will probably flake a lot for a while. Feel free to split it up into |
| 3 | + different tests or add more `ignore-` directives. |
| 4 | +*/ |
11 | 5 |
|
12 | 6 | //@ ignore-android FIXME #17520
|
13 | 7 | //@ ignore-wasm32 spawning processes is not supported
|
|
18 | 12 |
|
19 | 13 | //@ run-pass
|
20 | 14 | //@ check-run-results
|
21 |
| -//@ normalize-stderr-test: "omitted [0-9]+ frames" -> "omitted N frames" |
22 |
| -//@ normalize-stderr-test: ".rs:[0-9]+:[0-9]+" -> ".rs:LL:CC" |
| 15 | +//@ normalize-stderr: "omitted [0-9]+ frames" -> "omitted N frames" |
| 16 | +//@ normalize-stderr: ".rs:[0-9]+:[0-9]+" -> ".rs:LL:CC" |
23 | 17 | //@ error-pattern:stack backtrace:
|
24 | 18 | //@ regex-error-pattern:omitted [0-9]+ frames
|
25 | 19 | //@ error-pattern:main
|
26 |
| -// NOTE: if this is missing it's probably because the check that .stderr files match failed. |
27 |
| -//@ error-pattern:finished all checks |
28 | 20 |
|
29 | 21 | //@ exec-env:RUST_BACKTRACE=1
|
30 | 22 | //@ unset-exec-env:RUST_LIB_BACKTRACE
|
|
42 | 34 | //@[limited] compile-flags:-Cdebuginfo=limited
|
43 | 35 | //@[full] compile-flags:-Cdebuginfo=full
|
44 | 36 |
|
45 |
| -use std::collections::BTreeMap; |
46 |
| -use std::env; |
47 |
| -use std::path::Path; |
48 |
| - |
49 | 37 | fn main() {
|
50 |
| - // Make sure this comes first. Otherwise the error message when the check |
51 |
| - // below fails prevents you from using --bless to see the actual output. |
52 |
| - std::panic::catch_unwind(|| check_all_panics()).unwrap_err(); |
53 |
| - |
54 |
| - // compiletest generates a bunch of files for each revision. make sure they're all the same. |
55 |
| - let mut files = BTreeMap::new(); |
56 |
| - let dir = Path::new(env!("SOURCE_DIR")).join("backtrace"); |
57 |
| - for file in std::fs::read_dir(dir).unwrap() { |
58 |
| - let file = file.unwrap(); |
59 |
| - let name = file.file_name().into_string().unwrap(); |
60 |
| - if !file.file_type().unwrap().is_file() || !name.starts_with("std-backtrace-skip-frames.") |
61 |
| - || !name.ends_with(".run.stderr") { |
62 |
| - continue; |
63 |
| - } |
64 |
| - files.insert(name, std::fs::read_to_string(file.path()).unwrap()); |
65 |
| - } |
66 |
| - |
67 |
| - let mut first_line_tables = None; |
68 |
| - let mut first_full = None; |
69 |
| - |
70 |
| - for (name, contents) in &files { |
71 |
| - // These have different output. Rather than duplicating this whole test, |
72 |
| - // just special-case them here. |
73 |
| - let target = if name.contains(".full.") || name.contains(".limited.") { |
74 |
| - &mut first_full |
75 |
| - } else { |
76 |
| - &mut first_line_tables |
77 |
| - }; |
78 |
| - if let Some((target_name, target_contents)) = target { |
79 |
| - if contents != *target_contents { |
80 |
| - eprintln!("are you *sure* that you want {name} to have different backtrace output\ |
81 |
| - than {target_name}?"); |
82 |
| - eprintln!("NOTE: this test is stateful; run \ |
83 |
| - `rm tests/ui/backtrace/std-backtrace-skip-frames.*.stderr` to reset it"); |
84 |
| - std::process::exit(0); |
85 |
| - } |
86 |
| - } else { |
87 |
| - // compiletest doesn't support negative matching for `error-pattern`. Do that here. |
88 |
| - assert!(!contents.contains("FnOnce::call_once")); |
89 |
| - *target = Some((name, contents)); |
90 |
| - } |
91 |
| - } |
92 |
| - |
93 |
| - // We need this so people don't --bless away the assertion failure by accident. |
94 |
| - eprintln!("finished all checks"); |
| 38 | + check_all_panics(); |
95 | 39 | }
|
96 | 40 |
|
97 | 41 | fn check_all_panics() {
|
98 | 42 | // Spawn a bunch of threads and make sure all of them hide panic details we don't care about.
|
99 | 43 | let tests = [
|
100 |
| - unwrap_result, expect_result, unwrap_option, expect_option, explicit_panic, literal_panic, |
101 |
| - /*panic_nounwind*/ |
| 44 | + unwrap_result, |
| 45 | + expect_result, |
| 46 | + unwrap_option, |
| 47 | + expect_option, |
| 48 | + explicit_panic, |
| 49 | + literal_panic, |
| 50 | + /*panic_nounwind*/ |
102 | 51 | ];
|
103 | 52 | for func in tests {
|
104 | 53 | std::thread::spawn(move || func()).join().unwrap_err();
|
105 | 54 | }
|
106 | 55 | std::thread::spawn(|| panic_fmt(3)).join().unwrap_err();
|
107 | 56 |
|
108 | 57 | // Finally, panic ourselves so we can make sure `lang_start`, etc. frames are hidden.
|
109 |
| - panic!(); |
| 58 | + std::panic::catch_unwind(|| panic!()).unwrap_err(); |
110 | 59 | }
|
111 | 60 |
|
112 | 61 | fn unwrap_result() {
|
@@ -141,5 +90,7 @@ fn panic_fmt(x: u32) {
|
141 | 90 | // TODO: separate test
|
142 | 91 | #[allow(dead_code)]
|
143 | 92 | fn panic_nounwind() {
|
144 |
| - unsafe { [0].get_unchecked(1); } |
| 93 | + unsafe { |
| 94 | + [0].get_unchecked(1); |
| 95 | + } |
145 | 96 | }
|
0 commit comments