shrub/gen/test.hoon

72 lines
1.5 KiB
Plaintext
Raw Normal View History

/+ new-hoon, tester
/= all-tests
/^ (map @ta tests:tester)
/: /===/tests
/_ /test-tree/
::
=, new-hoon
|%
::
++ test-runner
:> run all tests in {a} with a filter.
2017-12-31 21:41:01 +03:00
=| pax=path
|= [filter=path eny=@uvJ a=tests:tester]
^- tang
%- concat:ls
%+ turn a
|= b=instance:tester
^- tang
=^ matches filter (match-filter filter p.b)
?. matches
~
?- -.q.b
%& (run-test [p.b pax] eny p.q.b)
%| ^$(pax [p.b pax], a p.q.b)
==
::
++ run-test
:> executes an individual test.
|= [pax=path eny=@uvJ test=$-(@uvJ (list tape))]
^- tang
=+ name=(spud (flop pax))
=+ run=(mule |.((test eny)))
?- -.run
2018-03-19 06:54:47 +03:00
%| :: the stack is already flopped for output?
;: weld
p:run
`tang`[[%leaf (weld name " CRASHED")] ~]
==
2018-03-19 06:54:47 +03:00
%& ?: =(~ p:run)
[[%leaf (weld name " OK")] ~]
:: Create a welded list of all failures indented.
%- flop
;: weld
`tang`[[%leaf (weld name " FAILED")] ~]
%+ turn p:run
|= {i/tape}
^- tank
[%leaf (weld " " i)]
==
==
::
++ match-filter
:> checks to see if {name} matches the head of {filter}.
2017-12-31 21:41:01 +03:00
|= [filter=path name=term]
^- [? path]
?~ filter
:: when there's no filter, we always match.
[%.y ~]
[=(i.filter name) t.filter]
--
::
:- %say
2017-12-31 21:41:01 +03:00
|= $: [now=@da eny=@uvJ bec=beak]
[filter=$?($~ [pax=path $~])]
$~
==
:- %tang
%^ test-runner
?~ filter ~ pax.filter
eny
(test-map-to-test-list:tester all-tests)