1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-18 14:44:48 +00:00

Make test output less verbose

This commit is contained in:
Calvin Rose 2021-11-06 11:01:21 -05:00
parent 2833a983d8
commit 0284df503f
3 changed files with 10 additions and 7 deletions

View File

@ -5,6 +5,8 @@
(var suite-num 0)
(var start-time 0)
(def is-verbose (os/getenv "VERBOSE"))
(defn assert
"Override's the default assert with some nice error handling."
[x &opt e]
@ -15,7 +17,7 @@
(def truncated
(if (> (length e) 40) (string (string/slice e 0 35) "...") (describe e)))
(if x
(eprintf "\e[32m✔\e[0m %s: %v" truncated x)
(when is-verbose (eprintf "\e[32m✔\e[0m %s: %v" truncated x))
(eprintf "\n\e[31m✘\e[0m %s: %v" truncated x))
x)
@ -32,10 +34,10 @@
(defn start-suite [x]
(set suite-num x)
(set start-time (os/clock))
(eprint "\nRunning test suite " x " tests...\n "))
(eprint "Running test suite " x " tests..."))
(defn end-suite []
(def delta (- (os/clock) start-time))
(eprintf "\n\nTest suite %d finished in %.3f seconds" suite-num delta)
(eprint num-tests-passed " of " num-tests-run " tests passed.\n")
(eprintf "Test suite %d finished in %.3f seconds" suite-num delta)
(eprint num-tests-passed " of " num-tests-run " tests passed.")
(if (not= num-tests-passed num-tests-run) (os/exit 1)))

View File

@ -308,8 +308,9 @@
(assert (deep= (range 4) a) "eachk 1")
(tracev (def my-unique-var-name true))
(assert my-unique-var-name "tracev upscopes")
(with-dyns [:err @""]
(tracev (def my-unique-var-name true))
(assert my-unique-var-name "tracev upscopes"))
(assert (pos? (length (gensym))) "gensym not empty, regression #753")

View File

@ -203,7 +203,7 @@
(def step1 "(a b c d)\n")
(def step2 "(a b)\n")
(def p1 (parser/new))
(pp (parser/state p1))
(parser/state p1)
(parser/consume p1 step1)
(loop [v :iterate (parser/produce p1)])
(parser/state p1)