forge
Explore
Log in

Don't you dare go Hollow

tools/golden: guard() turns a panicking case into a PANIC line

Browse files at this commit

5b64ff02802c5ef212a01bfe452b3c9ba8602316Ahmet Kaan GümüşParent: feb22ac
tools/golden/src/main.rsmodified+7 -0
@@ -38,12 +38,19 @@ pub fn error(case: &str, err: impl Display) {
3838 println!("{case}\tERR {err}");
3939 }
4040
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+
4147 pub fn name(path: &Path) -> String {
4248 let root = ec_testkit::root();
4349 path.strip_prefix(&root).unwrap_or(path).display().to_string()
4450 }
4551
4652 fn main() {
53+ std::panic::set_hook(Box::new(|_| {}));
4754 let wanted = std::env::args().nth(1).unwrap_or_default();
4855 let mut ran = false;
4956 for (domain, run) in DOMAINS {