Execute /. and /^ in scaffolds

This commit is contained in:
Elliot Glaysher 2018-05-17 14:49:44 -07:00
parent e6ff085fce
commit 2df0b8b863
2 changed files with 187 additions and 4 deletions

View File

@ -85,6 +85,8 @@
test-core
test-core-linker
test-core-fsts-fssg
test-core-fsdt-fskt
test-core-fskt-nest-fail
==
++ test-tear
~& %test-tear
@ -4116,6 +4118,108 @@
(expect-ford-empty ford ~nul)
==
::
++ test-core-fsdt-fskt
~& %test-core-fsdt-fskt
::
=/ ford *ford-gate
::
=/ hoon-src-type=type [%atom %$ ~]
=/ scry-results=(map [term beam] cage)
%- my :~
:- [%cx [[~nul %home %da ~1234.5.6] /hoon/program/gen]]
:- %hoon
:- hoon-src-type
'''
/= data /^ (list @ud)
/. /~ 1
/~ 2
/~ 3
==
(weld data [4 5 ~])
'''
==
::
=^ results1 ford
%- test-ford-call-with-comparator :*
ford
now=~1234.5.6
scry=(scry-with-results scry-results)
::
^= call-args
:* duct=~[/path] type=~ %make ~nul
%pin ~1234.5.6
[%core source-path=`rail:ford-gate`[[~nul %home] /hoon/program/gen]]
==
::
^= comparator
|= moves=(list move:ford-gate)
::
?> =(1 (lent moves))
?> ?=(^ moves)
?> ?=([* %give %made @da %complete %success %pin *] i.moves)
=/ result result.p.card.i.moves
=/ pin-result build-result.result
?> ?=([%success %core *] build-result.pin-result)
::
=/ =vase vase.build-result.pin-result
::
%+ weld
%- expect-eq !>
:- [1 2 3 4 5 ~]
q.vase
::
%- expect-eq !>
:- &
(~(nest ut p.vase) | -:!>([1 2 3 4 5 ~]))
==
::
;: weld
results1
(expect-ford-empty ford ~nul)
==
::
++ test-core-fskt-nest-fail
~& %test-core-fskt-nest-fail
::
=/ ford *ford-gate
::
=/ hoon-src-type=type [%atom %$ ~]
=/ scry-results=(map [term beam] cage)
%- my :~
:- [%cx [[~nul %home %da ~1234.5.6] /hoon/program/gen]]
:- %hoon
:- hoon-src-type
'''
/= data /^ (list @u)
/~ 5
data
'''
==
::
=^ results1 ford
%- test-ford-call :*
ford
now=~1234.5.6
scry=(scry-with-results scry-results)
::
^= call-args
:* duct=~[/path] type=~ %make ~nul
%pin ~1234.5.6
[%core source-path=`rail:ford-gate`[[~nul %home] /hoon/program/gen]]
==
::
^= moves
:~ :* duct=~[/path] %give %made ~1234.5.6 %complete %success
%pin ~1234.5.6 %error
:~ [%leaf "ford: %core failed: "]
[%leaf "/^ failed: nest-fail"]
== == == ==
::
;: weld
results1
(expect-ford-empty ford ~nul)
==
::
:: |utilities: helper arms
::
::+| utilities

View File

@ -3076,6 +3076,13 @@
:: compilation succeeded: produce resulting +vase
::
[build [%build-result %success %plan vase.u.compiled] accessed-builds]
:: +compose-result: the result of a single composition
::
+= compose-result
$% [%subject subject=vase]
[%block builds=(list ^build)]
[%error message=tang]
==
:: +compose-cranes: runs each crane and composes the results
::
:: For each crane in :cranes, runs it and composes its result into a
@ -3083,10 +3090,7 @@
::
++ compose-cranes
|= [subject=vase cranes=(list crane)]
^- $: $% [%subject subject=vase]
[%block builds=(list ^build)]
[%error message=tang]
==
^- $: compose-result
_..compose-cranes
==
::
@ -3108,6 +3112,8 @@
|^ ?+ -.crane !!
%fssg (run-fssg +.crane)
%fsts (run-fsts +.crane)
%fsdt (run-fsdt +.crane)
%fskt (run-fskt +.crane)
==
:: +run-fssg: runs the `/~` rune
::
@ -3135,6 +3141,79 @@
[child ..run-crane]
:_ ..run-crane
[%subject [[%face [~ face] p.subject.child] q.subject.child]]
:: +run-fsdt: runs the `/.` rune
::
++ run-fsdt
|= sub-cranes=(list ^crane)
^- compose-cranes
::
=^ list-results ..run-crane
%+ roll sub-cranes
|= $: sub-crane=^crane
accumulator=[(list compose-result) _..run-crane]
==
=. ..run-crane +.accumulator
=^ result ..run-crane (run-crane subject sub-crane)
[[result -.accumulator] ..run-crane]
:: if any sub-cranes error, return the first error
::
=/ error-list=(list compose-result)
%+ skim list-results
|= =compose-result
=(%error -.compose-result)
::
?^ error-list
[i.error-list ..run-crane]
:: if any sub-cranes block, return all blocks
::
=/ block-list=(list ^build)
=| block-list=(list ^build)
|-
^+ block-list
?~ list-results
block-list
?. ?=(%block -.i.list-results)
$(list-results t.list-results)
=. block-list (weld builds.i.list-results block-list)
$(list-results t.list-results)
::
?^ block-list
[[%block block-list] ..run-crane]
:: concatenate all the results together with null termination
::
=. list-results (flop list-results)
::
=/ final-result=vase
|-
^- vase
?~ list-results
[[%atom %n `~] 0]
?> ?=(%subject -.i.list-results)
(slop subject.i.list-results $(list-results t.list-results))
::
[[%subject final-result] ..run-crane]
:: +run-fskt: runs the `/^` rune
::
++ run-fskt
|= [mold=hoon sub-crane=^crane]
^- compose-cranes
::
=^ child ..run-crane (run-crane subject sub-crane)
?. ?=([%subject *] child)
[child ..run-crane]
::
=/ bunt-build=^build
[date.build [%ride [%bunt mold] [%$ %noun subject]]]
=^ bunt-result accessed-builds (depend-on bunt-build)
?~ bunt-result
[[%block [bunt-build]~] ..run-crane]
?: ?=([~ %error *] bunt-result)
[[%error [leaf+"/^ failed: " message.u.bunt-result]] ..run-crane]
?> ?=([~ %success %ride *] bunt-result)
::
?. (~(nest ut p.vase.u.bunt-result) | p.subject.child)
[[%error [leaf+"/^ failed: nest-fail"]~] ..run-crane]
[[%subject [p.vase.u.bunt-result q.subject.child]] ..run-crane]
--
:: +gather-path-builds: produce %path builds to resolve import paths
::