2017-11-14 03:43:39 +03:00
|
|
|
:: todo: think about using horns to import all tests in %/tests?
|
2017-11-27 02:41:49 +03:00
|
|
|
::
|
|
|
|
:: i should be able to use /: ?
|
|
|
|
/+ new-hoon, tester
|
|
|
|
|
2017-12-27 00:03:47 +03:00
|
|
|
:: ok, doing this as a list first. then do it automated. is there an equivalent
|
|
|
|
:: to /_ which works on an arbitrary directory?
|
|
|
|
/= test-thr /: /===/tests/thr /!noun/
|
|
|
|
/= test-myb /: /===/tests/myb /!noun/
|
|
|
|
/= test-ls /: /===/tests/ls /!noun/
|
|
|
|
/= test-mp /: /===/tests/mp /!noun/
|
2017-11-27 02:41:49 +03:00
|
|
|
|
2017-12-31 09:37:49 +03:00
|
|
|
=, new-hoon
|
2017-11-14 03:43:39 +03:00
|
|
|
|%
|
2017-12-31 09:37:49 +03:00
|
|
|
:> # %models
|
|
|
|
+|
|
|
|
|
+= tests
|
|
|
|
:> a hierarchical structure of tests
|
|
|
|
:>
|
|
|
|
:> an alphabetically sorted recursive association list
|
|
|
|
:> mapping a part of a path to either a test trap or a
|
|
|
|
:> sublist of the same type.
|
|
|
|
(list (pair term (either (trap (list tape)) tests)))
|
|
|
|
::
|
2017-12-31 10:23:54 +03:00
|
|
|
:> # %test
|
2017-12-31 09:37:49 +03:00
|
|
|
+|
|
|
|
|
++ gen-tests
|
|
|
|
:> creates a {tests} list out of a vase of a test suite
|
|
|
|
|= [v=vase eny=@uvJ]
|
|
|
|
^- tests
|
|
|
|
=+ arms=(sort (sloe p.v) aor)
|
|
|
|
=+ context=(slop (init-test-vase:tester eny) v)
|
|
|
|
%+ map:ls arms
|
|
|
|
|= arm/term
|
|
|
|
:- arm
|
|
|
|
:- %&
|
|
|
|
|.
|
|
|
|
=/ r (slap context [%cnsg [arm ~] [%$ 3] [[%$ 2] ~]])
|
2017-12-31 09:41:01 +03:00
|
|
|
((hard (list tape)) q:(slap r [%limb %results]))
|
2017-12-31 09:37:49 +03:00
|
|
|
::
|
|
|
|
++ test-runner
|
2017-12-31 10:23:54 +03:00
|
|
|
:> run all tests in {a} with a filter.
|
2017-12-31 21:41:01 +03:00
|
|
|
=| pax=path
|
|
|
|
|= [filter=path a=tests]
|
2017-12-31 10:23:54 +03:00
|
|
|
^- tang
|
2017-12-31 09:37:49 +03:00
|
|
|
%- concat:ls
|
|
|
|
%+ map:ls a
|
2017-12-31 21:41:01 +03:00
|
|
|
|= b=(pair term (either (trap (list tape)) tests))
|
2017-12-27 00:03:47 +03:00
|
|
|
^- tang
|
2017-12-31 10:23:54 +03:00
|
|
|
=^ matches filter (match-filter filter p.b)
|
|
|
|
?. matches
|
|
|
|
~
|
2017-12-31 09:37:49 +03:00
|
|
|
?- -.q.b
|
|
|
|
%& (run-test [p.b pax] p.q.b)
|
|
|
|
%| ^$(pax [p.b pax], a p.q.b)
|
2017-12-27 00:03:47 +03:00
|
|
|
==
|
|
|
|
::
|
2017-12-31 09:37:49 +03:00
|
|
|
++ run-test
|
|
|
|
:> executes an individual test.
|
2017-12-31 21:41:01 +03:00
|
|
|
|= [pax=path test=(trap (list tape))]
|
2017-12-27 00:03:47 +03:00
|
|
|
^- tang
|
2017-12-31 09:37:49 +03:00
|
|
|
=+ name=(spud (reverse:ls pax))
|
|
|
|
=+ run=(mule test)
|
|
|
|
~! run
|
2017-12-27 00:03:47 +03:00
|
|
|
?- -.run
|
|
|
|
$| :: the stack is already flopped for output?
|
|
|
|
;: weld
|
|
|
|
p:run
|
2017-12-31 09:37:49 +03:00
|
|
|
`tang`[[%leaf (weld name " CRASHED")] ~]
|
2017-12-27 00:03:47 +03:00
|
|
|
==
|
2017-12-31 09:37:49 +03:00
|
|
|
$& ?: =(~ p:run)
|
|
|
|
[[%leaf (weld name " OK")] ~]
|
2017-12-27 00:03:47 +03:00
|
|
|
:: Create a welded list of all failures indented.
|
|
|
|
%- flop
|
|
|
|
;: weld
|
2017-12-31 09:37:49 +03:00
|
|
|
`tang`[[%leaf (weld name " FAILED")] ~]
|
|
|
|
~! p:run
|
|
|
|
%+ turn p:run
|
2017-12-27 00:03:47 +03:00
|
|
|
|= {i/tape}
|
|
|
|
^- tank
|
|
|
|
[%leaf (weld " " i)]
|
|
|
|
==
|
|
|
|
==
|
2017-12-31 10:23:54 +03:00
|
|
|
::
|
|
|
|
++ 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]
|
2017-12-31 10:23:54 +03:00
|
|
|
?~ filter
|
|
|
|
:: when there's no filter, we always match.
|
|
|
|
[%.y ~]
|
|
|
|
[=(i.filter name) t.filter]
|
2017-09-25 08:44:45 +03:00
|
|
|
--
|
2017-12-27 00:03:47 +03:00
|
|
|
::
|
2017-09-25 08:44:45 +03:00
|
|
|
:- %say
|
2017-12-31 21:41:01 +03:00
|
|
|
|= $: [now=@da eny=@uvJ bec=beak]
|
|
|
|
[filter=$?($~ [pax=path $~])]
|
2017-09-25 08:44:45 +03:00
|
|
|
$~
|
|
|
|
==
|
|
|
|
:- %tang
|
2017-12-31 10:23:54 +03:00
|
|
|
%+ test-runner
|
|
|
|
?~ filter ~ pax.filter
|
2017-12-31 09:37:49 +03:00
|
|
|
^- tests
|
|
|
|
:~
|
|
|
|
:: todo: for now, this is manually constructed. later, this should
|
|
|
|
:: be generated from the contents of %/tests, without addressing the
|
|
|
|
:: files individually. if possible, lift the call to ++gen-tests into
|
|
|
|
:: the build steps for caching.
|
|
|
|
['ls' [%| (gen-tests !>(test-ls) eny)]]
|
|
|
|
['mp' [%| (gen-tests !>(test-mp) eny)]]
|
|
|
|
['myb' [%| (gen-tests !>(test-myb) eny)]]
|
|
|
|
['thr' [%| (gen-tests !>(test-thr) eny)]]
|
|
|
|
==
|