tools.deploy.backend: refactoring of make-staging-image

char-rename
Björn Lindqvist 2016-08-19 06:17:48 +02:00
parent 64d3c01523
commit a70deca651
2 changed files with 41 additions and 35 deletions

View File

@ -1,18 +1,42 @@
USING: pcre sequences tools.deploy.backend tools.test ;
USING: bootstrap.image kernel pcre sequences tools.deploy.backend
tools.test ;
IN: tools.deploy.backend.tests
: complete-match? ( str regexp -- ? )
"^" "$" surround matches? ;
! deploy-command-line
{ t } [
{ } staging-command-line
"image" "hello-world" "manifest.file" { "foob" } deploy-command-line
{
"-pic=0"
"-i=.*foob.*"
"-vocab-manifest-out=manifest.file"
"-deploy-vocab=hello-world"
"-deploy-config=.*hello-world"
"-output-image=image"
"-resource-path=.*"
"-run=tools.deploy.shaker"
} [ complete-match? ] 2all?
] unit-test
! input-image-name
{ t } [
{ "foo" } input-image-name my-boot-image-name =
] unit-test
! staging-command-line
{ t } [
{ "one" "two" } staging-command-line
{
"-staging"
"-no-user-init"
"-pic=0"
"-output-image.*"
"-include="
"-i=boot\\..*"
"-include=one two"
"-i=.*"
"-resource-path=.*"
"-run=tools.deploy.restage"
} [ complete-match? ] 2all?
] unit-test
@ -29,17 +53,3 @@ IN: tools.deploy.backend.tests
"-run=tools.deploy.restage"
} [ complete-match? ] 2all?
] unit-test
{ t } [
"image" "hello-world" "manifest.file" { "foob" } deploy-command-line
{
"-pic=0"
"-i=.*foob.*"
"-vocab-manifest-out=manifest.file"
"-deploy-vocab=hello-world"
"-deploy-config=.*hello-world"
"-output-image=image"
"-resource-path=.*"
"-run=tools.deploy.shaker"
} [ complete-match? ] 2all?
] unit-test

View File

@ -55,6 +55,12 @@ ERROR: can't-deploy-library-file library ;
[ delete-file ] each
] with-directory-files ;
: input-image-name ( profile -- name )
but-last [ my-boot-image-name ] [ staging-image-name ] if-empty ;
: run-factor ( vm-path flags -- )
swap prefix dup . run-with-output ; inline
: staging-command-line ( profile -- flags )
[
[
@ -62,26 +68,16 @@ ERROR: can't-deploy-library-file library ;
[ staging-image-name "-output-image=" prepend , ]
[ " " join "-include=" prepend , ] bi
] [
[ "-i=" my-boot-image-name append , ] [
but-last staging-image-name "-i=" prepend ,
"-resource-path=" "" resource-path append ,
"-run=tools.deploy.restage" ,
] if-empty
input-image-name "-i=" prepend ,
"-resource-path=" "" resource-path append ,
"-run=tools.deploy.restage" ,
] bi
] { } make ;
: run-factor ( vm-path flags -- )
swap prefix dup . run-with-output ; inline
DEFER: ?make-staging-image
: make-staging-image ( profile -- )
dup [ but-last ?make-staging-image ] unless-empty
vm-path swap staging-command-line run-factor ;
: ?make-staging-image ( profile -- )
dup staging-image-name exists?
[ drop ] [ make-staging-image ] if ;
{ } [ suffix ] accumulate* [ staging-image-name exists? ] reject
[ staging-command-line ] map
[ vm-path swap run-factor ] each ;
: make-deploy-config ( vocab -- file )
[ deploy-config vocab-roots get vocab-roots associate assoc-union unparse-use ]
@ -114,7 +110,7 @@ DEFER: ?make-staging-image
vocab "vocab-manifest-" prepend temp-file :> manifest-file
image vocab manifest-file profile deploy-command-line :> flags
profile ?make-staging-image
profile make-staging-image
vm flags run-factor
manifest-file parse-vocab-manifest-file ;