From e34135c41ac50333727a642ed1cd29dec20dc27f Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Sat, 20 Apr 2024 21:46:37 +0100 Subject: [PATCH] improve failed test reporting --- pkgs/devout/test.fnl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkgs/devout/test.fnl b/pkgs/devout/test.fnl index 1efcbce..852006a 100644 --- a/pkgs/devout/test.fnl +++ b/pkgs/devout/test.fnl @@ -31,8 +31,14 @@ (tset db e.path e))) })) +(var failed false) +(fn fail [d msg] (set failed true) (print :FAIL d (.. "\n" msg))) + (macro example [description & body] - `(do ,body)) + `(let [(ok?# err#) (xpcall (fn [] ,body) debug.traceback)] + (if ok?# + (print :PASS ,description) + (fail ,description err#)))) (example "given an empty database, searching it finds no entries" @@ -74,5 +80,4 @@ SEQNUM=1527") - -(print "OK") +(if failed (os.exit 1) (print "OK"))