urbit/pkg/arvo/gen/test.hoon

83 lines
1.8 KiB
Plaintext
Raw Normal View History

/+ test-runner
/= all-tests
/^ (map path (list test-arm:test-runner))
/: /===/tests
/* /test-gen/
::
|%
++ main
|= [defer=? tests=(list test:test-runner)]
^- tang
::
%- zing
%+ turn tests
|= [=path test-func=test-func:test-runner]
^- tang
::
=/ test-results=tang (run-test path test-func)
:: if :defer is set, produce errors; otherwise print them and produce ~
::
?: defer
test-results
((slog (flop test-results)) ~)
::
++ run-test
2018-05-25 01:39:56 +03:00
:: executes an individual test.
|= [pax=path test=test-func:test-runner]
^- tang
2018-08-24 20:46:31 +03:00
=+ name=(spud pax)
=+ run=(mule test)
?- -.run
2018-03-19 06:54:47 +03:00
%| :: the stack is already flopped for output?
;: weld
p.run
2018-08-24 20:46:31 +03:00
`tang`[[%leaf (weld "CRASHED " name)] ~]
==
%& ?: =(~ p.run)
2018-08-24 20:46:31 +03:00
[[%leaf (weld "OK " name)] ~]
:: Create a welded list of all failures indented.
%- flop
;: weld
2018-08-24 20:46:31 +03:00
`tang`[[%leaf (weld "FAILED " name)] ~]
::TODO indent
:: %+ turn p:run
:: |= {i/tape}
:: ^- tank
:: [%leaf (weld " " i)]
p.run
==
==
:: +filter-tests-by-prefix
::
++ filter-tests-by-prefix
|= [prefix=path tests=(list test:test-runner)]
^+ tests
::
=/ prefix-length=@ud (lent prefix)
::
%+ skim tests
::
|= [=path *]
=(prefix (scag prefix-length path))
--
::
:- %say
2017-12-31 21:41:01 +03:00
|= $: [now=@da eny=@uvJ bec=beak]
2018-03-19 07:18:20 +03:00
[filter=$?(~ [pax=path ~])]
[defer=_& seed=?(~ @uvJ)]
==
:: start printing early if we're not deferring output
::
~? !defer %tests-compiled
:- %tang
:: use empty path prefix if unspecified
::
=/ prefix=path ?~(filter ~ pax.filter)
::
=/ filtered-tests=(list test:test-runner)
%+ filter-tests-by-prefix
prefix
(resolve-test-paths:test-runner all-tests)
::
(main defer filtered-tests)