]> gitweb.factorcode.org Git - factor.git/blob - basis/tools/deploy/deploy-tests.factor
Create basis vocab root
[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-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 {\r
47     "tools.deploy.test.1"\r
48     "tools.deploy.test.2"\r
49     "tools.deploy.test.3"\r
50     "tools.deploy.test.4"\r
51 } [\r
52     [ ] swap [\r
53         shake-and-bake\r
54         vm\r
55         "-i=" "test.image" temp-file append\r
56         2array try-process\r
57     ] curry unit-test\r
58 ] each\r
59 \r
60 USING: http.client http.server http.server.dispatchers\r
61 http.server.responses http.server.static io.servers.connection ;\r
62 \r
63 SINGLETON: quit-responder\r
64 \r
65 M: quit-responder call-responder*\r
66     2drop stop-server "Goodbye" "text/html" <content> ;\r
67 \r
68 : add-quot-responder ( responder -- responder )\r
69     quit-responder "quit" add-responder ;\r
70 \r
71 : test-httpd ( -- )\r
72     #! Return as soon as server is running.\r
73     <http-server>\r
74         1237 >>insecure\r
75         f >>secure\r
76     start-server* ;\r
77 \r
78 [ ] [\r
79     [\r
80         <dispatcher>\r
81             add-quot-responder\r
82             "resource:basis/http/test" <static> >>default\r
83         main-responder set\r
84 \r
85         test-httpd\r
86     ] with-scope\r
87 ] unit-test\r
88 \r
89 [ ] [\r
90     "tools.deploy.test.5" shake-and-bake\r
91     vm\r
92     "-i=" "test.image" temp-file append\r
93     2array try-process\r
94 ] unit-test\r
95 \r
96 [ ] [ "http://localhost:1237/quit" http-get 2drop ] unit-test\r