improve failed test reporting

main
Daniel Barlow 2024-04-20 21:46:37 +01:00
parent 712c9b266f
commit e34135c41a
1 changed files with 8 additions and 3 deletions

View File

@ -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"))