1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-24 17:27:18 +00:00

Make test output less verbose.

This commit is contained in:
Calvin Rose 2019-01-02 23:06:23 -05:00
parent 337a498edb
commit ddba0010b0

View File

@ -3,20 +3,29 @@
(var num-tests-passed 0) (var num-tests-passed 0)
(var num-tests-run 0) (var num-tests-run 0)
(var suite-num 0) (var suite-num 0)
(var numchecks 0)
(defn assert [x e] (defn assert [x e]
(++ num-tests-run) (++ num-tests-run)
(when x (++ num-tests-passed)) (when x (++ num-tests-passed))
(print (if x (if x
" \e[32m✔\e[0m " (do
" \e[31m✘\e[0m ") e) (when (= numchecks 25)
(set numchecks 0)
(print))
(++ numchecks)
(file/write stdout "\e[32m✔\e[0m"))
(do
(file/write stdout "\n\e[31m✘\e[0m ")
(set numchecks 0)
(print e)))
x) x)
(defn start-suite [x] (defn start-suite [x]
(set suite-num x) (set suite-num x)
(print "\nRunning test suite " x " tests...\n")) (print "\nRunning test suite " x " tests...\n "))
(defn end-suite [] (defn end-suite []
(print "\nTest suite " suite-num " finished.") (print "\n\nTest suite " suite-num " finished.")
(print num-tests-passed " of " num-tests-run " tests passed.\n") (print num-tests-passed " of " num-tests-run " tests passed.\n")
(if (not= num-tests-passed num-tests-run) (os/exit 1))) (if (not= num-tests-passed num-tests-run) (os/exit 1)))