From 154a726ba78ae99fac4273d7dd123d5df8700d4a Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Fri, 22 Mar 2019 17:18:54 -0700 Subject: [PATCH] clean and doc --- app/ph.hoon | 65 ++++++++++++++++++++++++++++++++++++++++++++-- lib/hood/drum.hoon | 8 +++--- lib/hood/helm.hoon | 3 +-- lib/ph.hoon | 60 ++++++++++++++++++++++++++++-------------- sys/arvo.hoon | 1 - 5 files changed, 109 insertions(+), 28 deletions(-) diff --git a/app/ph.hoon b/app/ph.hoon index 5723f3ee8..3182e2dae 100644 --- a/app/ph.hoon +++ b/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: {}\"") ..start] + :: + ++ route + |= [who=ship uf=unix-effect] + ^- (quip ph-event _..start) + ?. (is-dojo-output ~bud who uf "\"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:" diff --git a/lib/hood/drum.hoon b/lib/hood/drum.hoon index ac67177ff..7293ea83a 100644 --- a/lib/hood/drum.hoon +++ b/lib/hood/drum.hoon @@ -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] == :: diff --git a/lib/hood/helm.hoon b/lib/hood/helm.hoon index c3c8b9b7b..0fe2d42be 100644 --- a/lib/hood/helm.hoon +++ b/lib/hood/helm.hoon @@ -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]) diff --git a/lib/ph.hoon b/lib/ph.hoon index 9f2ecd00b..ddf3e0921 100644 --- a/lib/ph.hoon +++ b/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 diff --git a/sys/arvo.hoon b/sys/arvo.hoon index a9e85ba03..9ecd67a41 100644 --- a/sys/arvo.hoon +++ b/sys/arvo.hoon @@ -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"]