tools/golden: guard() turns a panicking case into a PANIC line
Browse files at this commit5b64ff02802c5ef212a01bfe452b3c9ba8602316Parent: feb22ac1 changed file +7 -0
- tools/golden/src/main.rs +7 -0
tools/golden/src/main.rsmodified+7 -0
| @@ -38,12 +38,19 @@ pub fn error(case: &str, err: impl Display) { | |||
| 38 | println!("{case}\tERR {err}"); | 38 | println!("{case}\tERR {err}"); |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | +pub fn guard(case: &str, f: impl FnOnce()) { | ||
| 42 | + if std::panic::catch_unwind(std::panic::AssertUnwindSafe(f)).is_err() { | ||
| 43 | + text(case, "PANIC"); | ||
| 44 | + } | ||
| 45 | +} | ||
| 46 | + | ||
| 41 | pub fn name(path: &Path) -> String { | 47 | pub fn name(path: &Path) -> String { |
| 42 | let root = ec_testkit::root(); | 48 | let root = ec_testkit::root(); |
| 43 | path.strip_prefix(&root).unwrap_or(path).display().to_string() | 49 | path.strip_prefix(&root).unwrap_or(path).display().to_string() |
| 44 | } | 50 | } |
| 45 | 51 | ||
| 46 | fn main() { | 52 | fn main() { |
| 53 | + std::panic::set_hook(Box::new(|_| {})); | ||
| 47 | let wanted = std::env::args().nth(1).unwrap_or_default(); | 54 | let wanted = std::env::args().nth(1).unwrap_or_default(); |
| 48 | let mut ran = false; | 55 | let mut ran = false; |
| 49 | for (domain, run) in DOMAINS { | 56 | for (domain, run) in DOMAINS { |