factor/basis/tools/deploy/deploy-tests.factor

106 lines
2.7 KiB
Factor
Raw Normal View History

2008-03-01 17:00:45 -05:00
IN: tools.deploy.tests
USING: tools.test system io.files kernel tools.deploy.config
tools.deploy.backend math sequences io.launcher arrays
namespaces continuations layouts accessors io.encodings.ascii
urls math.parser ;
2008-03-14 18:39:57 -04:00
: shake-and-bake ( vocab -- )
2008-03-27 12:48:51 -04:00
[ "test.image" temp-file delete-file ] ignore-errors
"resource:" [
2008-12-03 09:46:16 -05:00
[ vm "test.image" temp-file ] dip
dup deploy-config make-deploy-image
] with-directory ;
2008-03-14 18:39:57 -04:00
: small-enough? ( n -- ? )
2008-12-03 09:46:16 -05:00
[ "test.image" temp-file file-info size>> ] [ cell 4 / * ] bi* <= ;
2008-03-14 18:39:57 -04:00
[ t ] [ "hello-world" shake-and-bake 500000 small-enough? ] unit-test
[ t ] [ "sudoku" shake-and-bake 800000 small-enough? ] unit-test
[ t ] [ "hello-ui" shake-and-bake 1300000 small-enough? ] unit-test
2008-09-07 22:32:06 -04:00
[ "staging.math-compiler-threads-ui-strip.image" ] [
2008-03-20 22:35:01 -04:00
"hello-ui" deploy-config
[ bootstrap-profile staging-image-name file-name ] bind
2008-03-19 15:39:08 -04:00
] unit-test
[ t ] [ "maze" shake-and-bake 1200000 small-enough? ] unit-test
2008-11-01 19:56:12 -04:00
[ t ] [ "tetris" shake-and-bake 1500000 small-enough? ] unit-test
[ t ] [ "bunny" shake-and-bake 2500000 small-enough? ] unit-test
: run-temp-image ( -- )
vm
"-i=" "test.image" temp-file append
2array try-process ;
2008-06-18 23:29:48 -04:00
{
"tools.deploy.test.1"
"tools.deploy.test.2"
"tools.deploy.test.3"
"tools.deploy.test.4"
} [
[ ] swap [
shake-and-bake
run-temp-image
2008-06-18 23:29:48 -04:00
] curry unit-test
] each
2008-06-25 21:47:07 -04:00
2008-07-03 21:50:08 -04:00
USING: http.client http.server http.server.dispatchers
2008-06-25 21:47:07 -04:00
http.server.responses http.server.static io.servers.connection ;
2008-07-03 21:50:08 -04:00
SINGLETON: quit-responder
M: quit-responder call-responder*
2008-10-02 09:30:38 -04:00
2drop stop-this-server "Goodbye" "text/html" <content> ;
2008-07-03 21:50:08 -04:00
: add-quot-responder ( responder -- responder )
quit-responder "quit" add-responder ;
2008-06-25 21:47:07 -04:00
: test-httpd ( responder -- )
2008-06-25 21:47:07 -04:00
[
main-responder set
<http-server>
0 >>insecure
f >>secure
dup start-server*
sockets>> first addr>> port>>
dup number>string "resource:temp/port-number" ascii set-file-contents
2008-06-25 21:47:07 -04:00
] with-scope
"port" set ;
[ ] [
<dispatcher>
add-quot-responder
"resource:basis/http/test" <static> >>default
test-httpd
2008-06-25 21:47:07 -04:00
] unit-test
[ ] [
"tools.deploy.test.5" shake-and-bake
run-temp-image
2008-06-25 21:47:07 -04:00
] unit-test
: add-port ( url -- url' )
>url clone "port" get >>port ;
[ ] [ "http://localhost/quit" add-port http-get 2drop ] unit-test
[ ] [
"tools.deploy.test.6" shake-and-bake
run-temp-image
] unit-test
[ ] [
"tools.deploy.test.7" shake-and-bake
run-temp-image
] unit-test
[ ] [
"tools.deploy.test.8" shake-and-bake
run-temp-image
] unit-test