]> gitweb.factorcode.org Git - factor.git/blob - basis/tools/deploy/deploy-tests.factor
db4255cdb1f034bafb2bc1c1c722e38d874d1b17
[factor.git] / basis / tools / deploy / deploy-tests.factor
1 IN: tools.deploy.tests\r
2 USING: tools.test system io.files kernel tools.deploy.config\r
3 tools.deploy.backend math sequences io.launcher arrays\r
4 namespaces continuations layouts accessors ;\r
5 \r
6 : shake-and-bake ( vocab -- )\r
7     [ "test.image" temp-file delete-file ] ignore-errors\r
8     "resource:" [\r
9         >r vm\r
10         "test.image" temp-file\r
11         r> dup deploy-config make-deploy-image\r
12     ] with-directory ;\r
13 \r
14 : small-enough? ( n -- ? )\r
15     >r "test.image" temp-file file-info size>> r> cell 4 / * <= ;\r
16 \r
17 [ ] [ "hello-world" shake-and-bake ] unit-test\r
18 \r
19 [ t ] [ 500000 small-enough? ] unit-test\r
20 \r
21 [ ] [ "sudoku" shake-and-bake ] unit-test\r
22 \r
23 [ t ] [ 800000 small-enough? ] unit-test\r
24 \r
25 [ ] [ "hello-ui" shake-and-bake ] unit-test\r
26 \r
27 [ t ] [ 1300000 small-enough? ] unit-test\r
28 \r
29 [ "staging.math-compiler-threads-ui-strip.image" ] [\r
30     "hello-ui" deploy-config\r
31     [ bootstrap-profile staging-image-name file-name ] bind\r
32 ] unit-test\r
33 \r
34 [ ] [ "maze" shake-and-bake ] unit-test\r
35 \r
36 [ t ] [ 1200000 small-enough? ] unit-test\r
37 \r
38 ! [ ] [ "tetris" shake-and-bake ] unit-test\r
39\r
40 ! [ t ] [ 1500000 small-enough? ] unit-test\r
41\r
42 [ ] [ "bunny" shake-and-bake ] unit-test\r
43 \r
44 [ t ] [ 2500000 small-enough? ] unit-test\r
45 \r
46 : run-temp-image ( -- )\r
47     vm\r
48     "-i=" "test.image" temp-file append\r
49     2array try-process ;\r
50 \r
51 {\r
52     "tools.deploy.test.1"\r
53     "tools.deploy.test.2"\r
54     "tools.deploy.test.3"\r
55     "tools.deploy.test.4"\r
56 } [\r
57     [ ] swap [\r
58         shake-and-bake\r
59         run-temp-image\r
60     ] curry unit-test\r
61 ] each\r
62 \r
63 USING: http.client http.server http.server.dispatchers\r
64 http.server.responses http.server.static io.servers.connection ;\r
65 \r
66 SINGLETON: quit-responder\r
67 \r
68 M: quit-responder call-responder*\r
69     2drop stop-this-server "Goodbye" "text/html" <content> ;\r
70 \r
71 : add-quot-responder ( responder -- responder )\r
72     quit-responder "quit" add-responder ;\r
73 \r
74 : test-httpd ( -- )\r
75     #! Return as soon as server is running.\r
76     <http-server>\r
77         1237 >>insecure\r
78         f >>secure\r
79     start-server* ;\r
80 \r
81 [ ] [\r
82     [\r
83         <dispatcher>\r
84             add-quot-responder\r
85             "resource:basis/http/test" <static> >>default\r
86         main-responder set\r
87 \r
88         test-httpd\r
89     ] with-scope\r
90 ] unit-test\r
91 \r
92 [ ] [\r
93     "tools.deploy.test.5" shake-and-bake\r
94     run-temp-image\r
95 ] unit-test\r
96 \r
97 [ ] [ "http://localhost:1237/quit" http-get 2drop ] unit-test\r
98 \r
99 [ ] [\r
100     "tools.deploy.test.6" shake-and-bake\r
101     run-temp-image\r
102 ] unit-test\r