-test, -build-file, -build-mark, -build-cast

This commit is contained in:
Ted Blackman 2020-04-18 04:21:15 -04:00
parent 8d3a497bb9
commit a705954b08
6 changed files with 99 additions and 1 deletions

View File

@ -417,7 +417,7 @@
?~ riot
(strand-fail %build-file >arg< ~)
?> =(%vase p.r.u.riot)
(pure:m q.r.u.riot)
(pure:m !<(vase q.r.u.riot))
:: +build-mark: build a mark definition to a $dais
::
++ build-mark

View File

@ -10,6 +10,45 @@
+$ test-func (trap tang)
--
|%
++ run-test
:: executes an individual test.
|= [pax=path test=test-func]
^- [ok=? =tang]
=+ name=(spud pax)
=+ run=(mule test)
?- -.run
%| :- %| :: the stack is already flopped for output?
;: weld
p.run
`tang`[[%leaf (weld "CRASHED " name)] ~]
==
%& ?: =(~ p.run)
&+[[%leaf (weld "OK " name)] ~]
:: Create a welded list of all failures indented.
:- %|
%- flop
;: weld
`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)]
^+ tests
::
=/ prefix-length=@ud (lent prefix)
::
%+ skim tests
::
|= [=path *]
=(prefix (scag prefix-length path))
:: +resolve-test-paths: add test names to file paths to form full identifiers
::
++ resolve-test-paths

View File

@ -0,0 +1,12 @@
/- spider
/+ strandio
=, strand=strand:spider
^- thread:spider
|= arg=vase
=/ m (strand ,vase)
^- form:m
=+ !<([a=mark b=mark ~] arg)
;< =bowl:spider bind:m get-bowl:strandio
=/ bek=beak [our q.byk da+now]:bowl
;< =tube:clay bind:m (build-cast:strandio bek a b)
(pure:m !>(tube))

View File

@ -0,0 +1,11 @@
/- spider
/+ strandio
=, strand=strand:spider
^- thread:spider
|= arg=vase
=/ m (strand ,vase)
^- form:m
=+ !<([pax=path ~] arg)
;< =bowl:spider bind:m get-bowl:strandio
=/ bek=beak [our q.byk da+now]:bowl
(build-file:strandio bek (flop pax))

View File

@ -0,0 +1,12 @@
/- spider
/+ strandio
=, strand=strand:spider
^- thread:spider
|= arg=vase
=/ m (strand ,vase)
^- form:m
=+ !<([mak=mark ~] arg)
;< =bowl:spider bind:m get-bowl:strandio
=/ bek=beak [our q.byk da+now]:bowl
;< =dais:clay bind:m (build-mark:strandio bek mak)
(pure:m !>(dais))

24
pkg/arvo/ted/test.hoon Normal file
View File

@ -0,0 +1,24 @@
/- spider
/+ strandio, *test-runner
=, strand=strand:spider
^- thread:spider
|= arg=vase
=/ m (strand ,vase)
^- form:m
=/ paz=(list path) (turn !<((list path) arg) |=(path [%tests +<]))
;< =bowl:spider bind:m get-bowl:strandio
=/ bek=beak [our q.byk da+now]:bowl
=| test-arms=(map path (list test-arm))
|- ^- form:m
=* gather-tests $
?^ paz
;< cor=vase bind:m (build-file:strandio bek hoon+(flop i.paz))
=. test-arms (~(put by test-arms) i.paz (get-test-arms cor))
gather-tests(paz t.paz)
%- pure:m !> ^= ok
%+ roll (resolve-test-paths test-arms)
|= [[=path =test-func] ok=_`?`%&]
^+ ok
=/ res (run-test path test-func)
%- (slog (flop tang.res))
&(ok ok.res)