mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-11 08:55:23 +03:00
clean and doc
This commit is contained in:
parent
b5414a49af
commit
154a726ba7
65
app/ph.hoon
65
app/ph.hoon
@ -158,6 +158,67 @@
|
||||
:: :~
|
||||
:: ==
|
||||
*raw-test-core
|
||||
::
|
||||
:- %simple-add
|
||||
%+ compose-tests (galaxy ~bud)
|
||||
%+ stateless-test
|
||||
%add
|
||||
^- stateless-test-core
|
||||
|_ now=@da
|
||||
++ start
|
||||
=/ command "[%test-result (add 2 3)]"
|
||||
:~ [%event ~bud //term/1 %belt %txt ((list @c) command)]
|
||||
[%event ~bud //term/1 %belt %ret ~]
|
||||
==
|
||||
::
|
||||
++ route
|
||||
|= [who=ship uf=unix-effect]
|
||||
?. (is-dojo-output ~bud who uf "[%test-result 5]")
|
||||
~
|
||||
[%test-done &]~
|
||||
--
|
||||
::
|
||||
:- %count
|
||||
%+ compose-tests (galaxy ~bud)
|
||||
%+ porcelain-test
|
||||
%state
|
||||
=| count=@
|
||||
|_ now=@da
|
||||
++ start
|
||||
^- (quip ph-event _..start)
|
||||
[(dojo ~bud "\"count: {<count>}\"") ..start]
|
||||
::
|
||||
++ route
|
||||
|= [who=ship uf=unix-effect]
|
||||
^- (quip ph-event _..start)
|
||||
?. (is-dojo-output ~bud who uf "\"count: {<count>}\"")
|
||||
[~ ..start]
|
||||
?: (gte count 10)
|
||||
[[%test-done &]~ ..start]
|
||||
=. count +(count)
|
||||
start
|
||||
--
|
||||
::
|
||||
:- %break-behn
|
||||
%+ compose-tests
|
||||
%+ compose-tests
|
||||
(galaxy ~bud)
|
||||
(galaxy ~dev)
|
||||
^- raw-test-core
|
||||
|_ now=@da
|
||||
++ label %break-behn
|
||||
++ ships ~
|
||||
++ start
|
||||
[(dojo ~bud "|hi ~dev") ..start]
|
||||
::
|
||||
++ route
|
||||
|= [who=ship uf=unix-effect]
|
||||
^- [? (quip ph-event _..start)]
|
||||
?: ?=(%doze -.q.uf)
|
||||
[| ~ ..start]
|
||||
:- & :_ ..start
|
||||
(expect-dojo-output ~bud who uf "hi ~dev successful")
|
||||
--
|
||||
==
|
||||
::
|
||||
++ install-tests
|
||||
@ -235,7 +296,7 @@
|
||||
==
|
||||
==
|
||||
::
|
||||
:: XXX doc
|
||||
:: Start another test if one is in the queue
|
||||
::
|
||||
++ run-test
|
||||
^- (quip move _this)
|
||||
@ -256,7 +317,7 @@
|
||||
=^ moves-2 this (run-events lab events.res)
|
||||
[:(weld init-vanes pause-fleet subscribe-vanes moves-1 moves-2) this]
|
||||
::
|
||||
::
|
||||
:: Print results with ~&
|
||||
::
|
||||
++ print-results
|
||||
~& "TEST REPORT:"
|
||||
|
@ -80,11 +80,11 @@
|
||||
::
|
||||
?: ?=($pawn myr)
|
||||
[[%base %collections] [%base %hall] [%base %talk] [%base %dojo] ~]
|
||||
:~ :: [%home %collections]
|
||||
:: [%home %acme]
|
||||
:: [%home %dns]
|
||||
:~ [%home %collections]
|
||||
[%home %acme]
|
||||
[%home %dns]
|
||||
[%home %dojo]
|
||||
:: [%home %hall]
|
||||
[%home %hall]
|
||||
[%home %talk]
|
||||
==
|
||||
::
|
||||
|
@ -196,8 +196,7 @@
|
||||
=/ top=path /(scot %p our)/home/(scot %da now)/sys
|
||||
=/ hun .^(@ %cx (welp top /hoon/hoon))
|
||||
=/ arv .^(@ %cx (welp top /arvo/hoon))
|
||||
:- `card`[%flog /reset [%lyra `@t`hun `@t`arv]]
|
||||
^- (list card)
|
||||
:- [%flog /reset [%lyra `@t`hun `@t`arv]]
|
||||
%+ turn
|
||||
(module-ova:pill top)
|
||||
|=(a=[wire flog:dill] [%flog a])
|
||||
|
60
lib/ph.hoon
60
lib/ph.hoon
@ -1,7 +1,6 @@
|
||||
::
|
||||
:::: /hoon/ph/lib
|
||||
::
|
||||
:: XXX should raw-ship and others be stateless-test-core?
|
||||
/- aquarium
|
||||
=, aquarium
|
||||
|%
|
||||
@ -28,10 +27,18 @@
|
||||
::
|
||||
:: Called on every effect from a ship.
|
||||
::
|
||||
:: The loobean in the return value says whether we should pass on
|
||||
:: the effect to vane drivers. Usually this should be yes.
|
||||
::
|
||||
++ route |~([ship unix-effect] *[? (quip ph-event _^|(..start))])
|
||||
--
|
||||
::
|
||||
:: XXX doc
|
||||
:: A simpler interface for when you don't need all the power.
|
||||
::
|
||||
:: Doesn't allwow you to explicitly subscribe to certain ships or
|
||||
:: blocking certain effects from going to their usual vane drivers.
|
||||
::
|
||||
:: Use with +porcelain-test
|
||||
::
|
||||
++ porcelain-test-core
|
||||
$_ ^|
|
||||
@ -45,12 +52,19 @@
|
||||
++ route |~([ship unix-effect] *(quip ph-event _^|(..start)))
|
||||
--
|
||||
::
|
||||
:: XXX doc
|
||||
:: A simpler interface for when you don't need test state.
|
||||
::
|
||||
:: Use with +stateless-test
|
||||
::
|
||||
++ stateless-test-core
|
||||
$_ ^|
|
||||
|_ now=@da
|
||||
:: Called first to kick off the test.
|
||||
::
|
||||
++ start *(list ph-event)
|
||||
::
|
||||
:: Called on every effect from a ship.
|
||||
::
|
||||
++ route |~([ship unix-effect] *(list ph-event))
|
||||
--
|
||||
::
|
||||
@ -59,7 +73,7 @@
|
||||
aqua-event
|
||||
==
|
||||
::
|
||||
:: XXX doc
|
||||
:: Call with a +porecelain-test-core create a stateless test.
|
||||
::
|
||||
++ porcelain-test
|
||||
|= [label=@ta porcelain=porcelain-test-core]
|
||||
@ -77,7 +91,7 @@
|
||||
[& events ..start]
|
||||
--
|
||||
::
|
||||
:: XXX doc
|
||||
:: Call with a +stateless-test-core create a stateless test.
|
||||
::
|
||||
++ stateless-test
|
||||
|= [label=@tas stateless=stateless-test-core]
|
||||
@ -93,6 +107,8 @@
|
||||
[(~(route stateless now) args) ..start]
|
||||
--
|
||||
::
|
||||
:: Turn [ship (list unix-event)] into (list ph-event)
|
||||
::
|
||||
++ send-events-to
|
||||
|= [who=ship what=(list unix-event)]
|
||||
^- (list ph-event)
|
||||
@ -100,6 +116,8 @@
|
||||
|= ue=unix-event
|
||||
[%event who ue]
|
||||
::
|
||||
:: Start a ship (low-level; prefer +raw-ship)
|
||||
::
|
||||
++ init
|
||||
|= [who=ship keys=(unit dawn-event)]
|
||||
^- (list ph-event)
|
||||
@ -119,6 +137,8 @@
|
||||
[//term/1 %belt %ret ~]
|
||||
==
|
||||
::
|
||||
:: Inject a file into a ship
|
||||
::
|
||||
++ insert-file
|
||||
|= [who=ship des=desk pax=path txt=@t]
|
||||
^- (list ph-event)
|
||||
@ -129,6 +149,9 @@
|
||||
[//sync/0v1n.2m9vh %into des | [t.t.t.pax `file]~]
|
||||
==
|
||||
::
|
||||
:: Checks whether the given event is a dojo output blit containing the
|
||||
:: given tape
|
||||
::
|
||||
++ is-dojo-output
|
||||
|= [who=ship her=ship uf=unix-effect what=tape]
|
||||
?& =(who her)
|
||||
@ -141,6 +164,8 @@
|
||||
!=(~ (find what p.blit))
|
||||
==
|
||||
::
|
||||
:: Test is successful if +is-dojo-output
|
||||
::
|
||||
++ expect-dojo-output
|
||||
|= [who=ship her=ship uf=unix-effect what=tape]
|
||||
^- (list ph-event)
|
||||
@ -148,18 +173,14 @@
|
||||
~
|
||||
[%test-done &]~
|
||||
::
|
||||
:: Check whether the given event is an ergo
|
||||
::
|
||||
++ is-ergo
|
||||
|= [who=ship her=ship uf=unix-effect]
|
||||
?& =(who her)
|
||||
?=(%ergo -.q.uf)
|
||||
==
|
||||
::
|
||||
++ on-ergo
|
||||
|= [who=ship her=ship uf=unix-effect fun=$-($~ (list ph-event))]
|
||||
?. (is-ergo who her uf)
|
||||
~
|
||||
(fun)
|
||||
::
|
||||
++ azimuth
|
||||
|%
|
||||
++ dawn
|
||||
@ -207,6 +228,11 @@
|
||||
::
|
||||
++ test-lib
|
||||
|_ our=ship
|
||||
::
|
||||
:: Run one test, then the next.
|
||||
::
|
||||
:: Caches the result of the first test.
|
||||
::
|
||||
++ compose-tests
|
||||
|= [a=raw-test-core b=raw-test-core]
|
||||
^- raw-test-core
|
||||
@ -278,7 +304,7 @@
|
||||
[thru events ..start]
|
||||
--
|
||||
::
|
||||
:: Don't use directly, or else you might not have a parent.
|
||||
:: Don't use directly unless you've already started any parent.
|
||||
::
|
||||
:: Consider ++galaxy, ++star, ++planet, and ++ship-with-ancestors.
|
||||
::
|
||||
@ -345,8 +371,6 @@
|
||||
::
|
||||
:: Touches /sur/aquarium/hoon on the given ship.
|
||||
::
|
||||
:: Ship must have been started.
|
||||
::
|
||||
++ touch-file
|
||||
|= [her=ship des=desk]
|
||||
%+ porcelain-test
|
||||
@ -377,9 +401,7 @@
|
||||
~
|
||||
--
|
||||
::
|
||||
:: Checks that /sur/aquarium/hoon has been touched, as by ++touch-file
|
||||
::
|
||||
:: Ship must have been started.
|
||||
:: Check that /sur/aquarium/hoon has been touched, as by ++touch-file
|
||||
::
|
||||
++ check-file-touched
|
||||
|= [her=ship des=desk]
|
||||
@ -416,8 +438,6 @@
|
||||
::
|
||||
:: Reload vane from filesystem
|
||||
::
|
||||
:: Ship must have been started.
|
||||
::
|
||||
++ reload-vane
|
||||
|= [her=ship vane=term]
|
||||
%+ stateless-test
|
||||
@ -438,6 +458,8 @@
|
||||
~
|
||||
--
|
||||
::
|
||||
:: Scry into a running aqua ship
|
||||
::
|
||||
++ scry-aqua
|
||||
|* [a=mold now=@da pax=path]
|
||||
.^ a
|
||||
|
@ -627,7 +627,6 @@
|
||||
==
|
||||
:: upgrade once we've accumulated identity, entropy, and %zuse
|
||||
::
|
||||
~& [%upgrading ?=(^ who) ?=(^ eny) ?=(^ bod)]
|
||||
?. &(?=(^ who) ?=(^ eny) ?=(^ bod))
|
||||
[~ +>.$]
|
||||
~> %slog.[0 leaf+"arvo: metamorphosis"]
|
||||
|
Loading…
Reference in New Issue
Block a user