mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-28 19:55:53 +03:00
+test now deals with recursive directory structures.
+test now offloads creation of the test tree into a renderer. this should help with caching. using a renderer also lets us deal with hierarchical directory structures, leading to better organization.
This commit is contained in:
parent
625959a004
commit
48585d2b2f
@ -1,67 +1,35 @@
|
||||
:: todo: think about using horns to import all tests in %/tests?
|
||||
::
|
||||
:: i should be able to use /: ?
|
||||
/+ new-hoon, tester
|
||||
|
||||
:: 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/
|
||||
|
||||
/= all-tests
|
||||
/^ (map @ta tests:tester)
|
||||
/: /===/tests
|
||||
/_ /test-tree/
|
||||
::
|
||||
=, new-hoon
|
||||
|%
|
||||
:> # %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)))
|
||||
::
|
||||
:> # %test
|
||||
+|
|
||||
++ 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] ~]])
|
||||
((hard (list tape)) q:(slap r [%limb %results]))
|
||||
::
|
||||
++ test-runner
|
||||
:> run all tests in {a} with a filter.
|
||||
=| pax=path
|
||||
|= [filter=path a=tests]
|
||||
|= [filter=path eny=@uvJ a=tests:tester]
|
||||
^- tang
|
||||
%- concat:ls
|
||||
%+ map:ls a
|
||||
|= b=(pair term (either (trap (list tape)) tests))
|
||||
%+ turn a
|
||||
|= b=instance:tester
|
||||
^- tang
|
||||
=^ matches filter (match-filter filter p.b)
|
||||
?. matches
|
||||
~
|
||||
?- -.q.b
|
||||
%& (run-test [p.b pax] p.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 test=(trap (list tape))]
|
||||
|= [pax=path eny=@uvJ test=$-(@uvJ (list tape))]
|
||||
^- tang
|
||||
=+ name=(spud (reverse:ls pax))
|
||||
=+ run=(mule test)
|
||||
~! run
|
||||
=+ name=(spud (flop pax))
|
||||
=+ run=(mule |.((test eny)))
|
||||
?- -.run
|
||||
$| :: the stack is already flopped for output?
|
||||
;: weld
|
||||
@ -74,7 +42,6 @@
|
||||
%- flop
|
||||
;: weld
|
||||
`tang`[[%leaf (weld name " FAILED")] ~]
|
||||
~! p:run
|
||||
%+ turn p:run
|
||||
|= {i/tape}
|
||||
^- tank
|
||||
@ -98,16 +65,7 @@
|
||||
$~
|
||||
==
|
||||
:- %tang
|
||||
%+ test-runner
|
||||
%^ test-runner
|
||||
?~ filter ~ pax.filter
|
||||
^- 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)]]
|
||||
==
|
||||
eny
|
||||
(test-map-to-test-list:tester all-tests)
|
||||
|
@ -1,5 +1,65 @@
|
||||
/+ new-hoon
|
||||
:: common testing library.
|
||||
|%
|
||||
:> # %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 instance)
|
||||
::
|
||||
+= instance
|
||||
:> a mapping between a term and part of a test tree.
|
||||
:>
|
||||
(pair term (each $-(@uvJ (list tape)) tests))
|
||||
::
|
||||
:> # %generate
|
||||
:> utilities for generating models.
|
||||
+|
|
||||
++ merge-base-and-recur
|
||||
:> combine the current file and subdirectory.
|
||||
:>
|
||||
:> this merges the file {base} with its child files {recur}.
|
||||
|= [base=vase recur=(map @ta tests:tester)]
|
||||
^- tests
|
||||
=+ a=(gen-tests base)
|
||||
=+ b=(test-map-to-test-list recur)
|
||||
:: todo: why does ++weld not work here? {a} and {b} are cast and have the
|
||||
:: correct faces.
|
||||
(welp a b)
|
||||
::
|
||||
++ test-map-to-test-list
|
||||
:> translates ford output to something we can work with.
|
||||
:>
|
||||
:> ford gives us a `(map @ta tests:tester)`, but we actually
|
||||
:> want something like ++tests.
|
||||
|= a=(map @ta tests:tester)
|
||||
:: todo: i'd like to sort this, but ++sort has -find.a problems much like
|
||||
:: ++weld does above!?
|
||||
^- tests
|
||||
%+ turn
|
||||
(to-list:dct:new-hoon a)
|
||||
|= {key/@ta value/tests:tester}
|
||||
[key [%| value]]
|
||||
|
||||
::
|
||||
++ 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)
|
||||
%+ turn arms
|
||||
|= arm/term
|
||||
:- arm
|
||||
:- %&
|
||||
|= eny=@uvJ
|
||||
=+ context=(slop (init-test-vase:tester eny) v)
|
||||
=/ r (slap context [%cnsg [arm ~] [%$ 3] [[%$ 2] ~]])
|
||||
((hard (list tape)) q:(slap r [%limb %results]))
|
||||
::
|
||||
++ init-test-vase
|
||||
|= {cookie/@uvJ}
|
||||
^- vase
|
||||
@ -79,7 +139,7 @@
|
||||
:> #
|
||||
:> # %test
|
||||
:> #
|
||||
:> assertions on state
|
||||
:> test expectation functions
|
||||
+|
|
||||
:: todo: unit testing libraries have a lot more to them than just eq.
|
||||
++ expect-eq
|
||||
@ -99,7 +159,7 @@
|
||||
:> #
|
||||
:> # %output
|
||||
:> #
|
||||
:> called by the test harness after test completion
|
||||
:> called by the test harness
|
||||
::
|
||||
++ results
|
||||
:> returns results.
|
||||
|
10
ren/test-tree.hoon
Normal file
10
ren/test-tree.hoon
Normal file
@ -0,0 +1,10 @@
|
||||
/+ tester
|
||||
/= base /| /!noun/
|
||||
/~ ~
|
||||
==
|
||||
/= recur /^ (map @ta tests:tester)
|
||||
/| /_ /test-tree/
|
||||
/~ ~
|
||||
==
|
||||
::
|
||||
(merge-base-and-recur:tester !>(base) recur)
|
Loading…
Reference in New Issue
Block a user