2019-04-20 03:41:58 +03:00
|
|
|
:: Utility functions for constructing tests
|
|
|
|
::
|
2019-11-16 14:25:30 +03:00
|
|
|
/- aquarium
|
|
|
|
=, aquarium
|
2019-04-20 03:41:58 +03:00
|
|
|
|%
|
|
|
|
::
|
|
|
|
:: Turn [ship (list unix-event)] into (list ph-event)
|
|
|
|
::
|
|
|
|
++ send-events-to
|
|
|
|
|= [who=ship what=(list unix-event)]
|
2019-09-29 07:44:31 +03:00
|
|
|
^- (list aqua-event)
|
2019-04-20 03:41:58 +03:00
|
|
|
%+ turn what
|
|
|
|
|= ue=unix-event
|
|
|
|
[%event who ue]
|
|
|
|
::
|
|
|
|
:: Start a ship (low-level; prefer +raw-ship)
|
|
|
|
::
|
|
|
|
++ init
|
2019-08-23 01:33:52 +03:00
|
|
|
|= [who=ship keys=(unit dawn-event:able:jael)]
|
2019-09-29 07:44:31 +03:00
|
|
|
^- (list aqua-event)
|
2019-04-20 03:41:58 +03:00
|
|
|
[%init-ship who keys]~
|
|
|
|
::
|
|
|
|
:: Send dojo command
|
|
|
|
::
|
|
|
|
++ dojo
|
|
|
|
|= [who=ship what=tape]
|
2019-09-29 07:44:31 +03:00
|
|
|
^- (list aqua-event)
|
2019-04-20 03:41:58 +03:00
|
|
|
%+ send-events-to who
|
|
|
|
^- (list unix-event)
|
|
|
|
:~
|
|
|
|
[//term/1 %belt %ctl `@c`%e]
|
|
|
|
[//term/1 %belt %ctl `@c`%u]
|
|
|
|
[//term/1 %belt %txt ((list @c) what)]
|
|
|
|
[//term/1 %belt %ret ~]
|
|
|
|
==
|
|
|
|
::
|
2019-09-25 00:53:31 +03:00
|
|
|
:: Control character
|
|
|
|
::
|
|
|
|
++ ctrl
|
|
|
|
|= [who=ship what=term]
|
|
|
|
^- (list ph-event)
|
|
|
|
%+ send-events-to who
|
|
|
|
:~ [//term/1 %belt %ctl (,@c what)]
|
|
|
|
==
|
|
|
|
::
|
2019-04-20 03:41:58 +03:00
|
|
|
:: Inject a file into a ship
|
|
|
|
::
|
2020-05-22 09:05:42 +03:00
|
|
|
++ insert-files
|
|
|
|
|= [who=ship des=desk files=(list [=path txt=@t])]
|
2019-10-02 01:06:12 +03:00
|
|
|
^- (list aqua-event)
|
2020-05-22 09:05:42 +03:00
|
|
|
=/ input
|
|
|
|
%+ turn files
|
|
|
|
|= [=path txt=@t]
|
|
|
|
[path ~ /text/plain (as-octs:mimes:html txt)]
|
2019-04-20 03:41:58 +03:00
|
|
|
%+ send-events-to who
|
|
|
|
:~
|
2020-05-22 09:05:42 +03:00
|
|
|
[//sync/0v1n.2m9vh %into des | input]
|
2019-04-20 03:41:58 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
:: 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)
|
|
|
|
?=(%blit -.q.uf)
|
|
|
|
::
|
|
|
|
%+ lien p.q.uf
|
|
|
|
|= =blit:dill
|
|
|
|
?. ?=(%lin -.blit)
|
|
|
|
|
|
|
|
|
!=(~ (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)
|
|
|
|
?. (is-dojo-output who her uf what)
|
|
|
|
~
|
|
|
|
[%test-done &]~
|
|
|
|
::
|
|
|
|
:: Check whether the given event is an ergo
|
|
|
|
::
|
|
|
|
++ is-ergo
|
|
|
|
|= [who=ship her=ship uf=unix-effect]
|
|
|
|
?& =(who her)
|
|
|
|
?=(%ergo -.q.uf)
|
|
|
|
==
|
|
|
|
::
|
|
|
|
:: Check if given effect is an http request; extract
|
|
|
|
::
|
2019-07-25 01:54:45 +03:00
|
|
|
++ extract-request
|
2019-04-20 03:41:58 +03:00
|
|
|
|= [uf=unix-effect dest=@t]
|
2019-07-25 01:54:45 +03:00
|
|
|
^- (unit [num=@ud =request:http])
|
|
|
|
?. ?=(%request -.q.uf) ~
|
|
|
|
?. =(dest url.request.q.uf) ~
|
|
|
|
`[id.q.uf request.q.uf]
|
2019-04-24 02:30:47 +03:00
|
|
|
::
|
|
|
|
:: Scry into a running aqua ship
|
|
|
|
::
|
|
|
|
++ scry-aqua
|
|
|
|
|* [a=mold our=@p now=@da pax=path]
|
|
|
|
.^ a
|
2019-11-19 07:36:21 +03:00
|
|
|
%gx
|
2019-04-24 02:30:47 +03:00
|
|
|
(scot %p our)
|
|
|
|
%aqua
|
|
|
|
(scot %da now)
|
|
|
|
pax
|
|
|
|
==
|
2019-04-20 03:41:58 +03:00
|
|
|
--
|