liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit e34135c41ac50333727a642ed1cd29dec20dc27f
parent 712c9b266f7f10ae94ec9b60eb82ba57c205dc5b
Author: Daniel Barlow <dan@telent.net>
Date:   Sat, 20 Apr 2024 21:46:37 +0100

improve failed test reporting

Diffstat:
Mpkgs/devout/test.fnl | 11++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git 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"))