shrub/pkg/arvo/app/test.hoon

160 lines
3.8 KiB
Plaintext
Raw Normal View History

2019-11-14 05:05:39 +03:00
/+ default-agent
2020-05-05 06:20:41 +03:00
!:
2019-11-14 05:05:39 +03:00
|%
2019-11-19 07:36:21 +03:00
+$ card card:agent:gall
2020-05-20 03:28:46 +03:00
+$ test ?(%agents %marks %generators)
2020-05-05 06:20:41 +03:00
+$ state
$: app=(set path)
app-ok=?
mar=(set path)
mar-ok=?
2020-05-20 03:28:46 +03:00
gen=(set path)
gen-ok=?
2019-11-14 05:05:39 +03:00
==
--
=, format
2019-11-19 07:36:21 +03:00
^- agent:gall
2020-05-05 06:20:41 +03:00
=| =state
2019-11-19 07:36:21 +03:00
|_ =bowl:gall
2019-11-14 05:05:39 +03:00
+* this .
def ~(. (default-agent this %|) bowl)
::
++ on-init on-init:def
++ on-save on-save:def
++ on-load on-load:def
++ on-poke
|= [=mark =vase]
2020-05-05 06:20:41 +03:00
^- [(list card) _this]
2019-11-14 05:05:39 +03:00
|^
2020-05-05 06:20:41 +03:00
=+ !<(=test vase)
?- test
%marks test-marks
%agents test-agents
2020-05-20 03:28:46 +03:00
%generators test-generators
2019-11-14 05:05:39 +03:00
==
::
2020-05-05 06:20:41 +03:00
++ test-marks
=| fex=(list card)
^+ [fex this]
?> =(~ mar.state)
=. mar-ok.state %.y
=+ .^(paz=(list path) ct+(en-beam now-beak /mar))
|- ^+ [fex this]
?~ paz [fex this]
=/ xap=path (flop i.paz)
?. ?=([%hoon *] xap)
$(paz t.paz)
=/ mak=^mark
%- crip
%+ turn (tail (spud (tail (flop (tail xap)))))
|=(c=@tD `@tD`?:(=('/' c) '-' c))
=/ sing=card
:+ %pass /build/mar/[mak]
[%arvo %c %warp our.bowl %home ~ %sing %b da+now.bowl /[mak]]
%_ $
paz t.paz
fex [sing fex]
mar.state (~(put in mar.state) /mar/[mak])
==
2019-11-14 05:05:39 +03:00
::
2020-05-05 06:20:41 +03:00
++ test-agents
=| fex=(list card)
^+ [fex this]
?> =(~ app.state)
=. app-ok.state %.y
=+ .^(app-arch=arch cy+(en-beam now-beak /app))
=/ daz ~(tap in ~(key by dir.app-arch))
|- ^+ [fex this]
?~ daz [fex this]
=/ dap-pax=path /app/[i.daz]/hoon
=/ dap-arch .^(arch cy+(en-beam now-beak (flop dap-pax)))
?~ fil.dap-arch
$(daz t.daz)
=/ sing=card
:+ %pass /build/app/[i.daz]
[%arvo %c %warp our.bowl %home ~ %sing %a da+now.bowl dap-pax]
%_ $
daz t.daz
fex [sing fex]
app.state (~(put in app.state) /app/[i.daz])
2019-11-14 05:05:39 +03:00
==
2020-05-05 06:20:41 +03:00
::
2020-05-20 03:28:46 +03:00
++ test-generators
=| fex=(list card)
^+ [fex this]
?> =(~ gen.state)
=. gen-ok.state %.y
=+ .^(paz=(list path) ct+(en-beam now-beak /gen))
|- ^+ [fex this]
?~ paz [fex this]
=/ xap=path (flop i.paz)
?. ?=([%hoon *] xap)
$(paz t.paz)
=/ sing=card
:+ %pass build+i.paz
[%arvo %c %warp our.bowl %home ~ %sing %a da+now.bowl i.paz]
%_ $
paz t.paz
fex [sing fex]
gen.state (~(put in gen.state) i.paz)
==
::
2020-05-05 06:20:41 +03:00
++ now-beak %_(byk.bowl r [%da now.bowl])
2019-11-14 05:05:39 +03:00
--
++ on-watch on-watch:def
++ on-leave on-leave:def
++ on-peek on-peek:def
++ on-agent on-agent:def
++ on-arvo
|= [=wire =sign-arvo]
2020-05-05 06:20:41 +03:00
^- [(list card) _this]
?. ?=([%build *] wire)
2019-11-14 05:05:39 +03:00
(on-arvo:def wire sign-arvo)
2020-05-05 06:20:41 +03:00
?. ?=(%writ +<.sign-arvo)
2019-11-14 05:05:39 +03:00
(on-arvo:def wire sign-arvo)
2020-05-05 06:20:41 +03:00
=/ =path t.wire
?+ path ~|(path+path !!)
[%app *]
2020-05-20 03:28:46 +03:00
=/ ok
?~ p.sign-arvo |
(~(nest ut -:!>(*agent:gall)) | -:!<(vase q.r.u.p.sign-arvo))
2020-05-05 06:20:41 +03:00
~& ?: ok
agent-built+path
agent-failed+path
=? app-ok.state !ok %.n
=. app.state (~(del in app.state) path)
~? =(~ app.state)
?: app-ok.state
%all-agents-built
%some-agents-failed
[~ this]
2019-11-14 05:05:39 +03:00
::
2020-05-05 06:20:41 +03:00
[%mar *]
=/ ok ?=(^ p.sign-arvo)
~& ?: ok
mark-built+path
mark-failed+path
=? mar-ok.state !ok %.n
=. mar.state (~(del in mar.state) path)
~? =(~ mar.state)
?: mar-ok.state
%all-marks-built
%some-marks-failed
[~ this]
2020-05-20 03:28:46 +03:00
::
[%gen *]
=/ ok ?=(^ p.sign-arvo)
~& ?: ok
generator-built+path
generator-failed+path
=? gen-ok.state !ok %.n
=. gen.state (~(del in gen.state) path)
~? =(~ gen.state)
?: gen-ok.state
%all-generators-built
%some-generators-failed
[~ this]
2020-05-05 06:20:41 +03:00
==
2019-11-14 05:05:39 +03:00
++ on-fail on-fail:def
--