]> gitweb.factorcode.org Git - factor.git/blob - basis/tools/deploy/deploy-tests.factor
Removing more >r/r> usages
[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 io.encodings.ascii\r
5 urls math.parser ;\r
6 \r
7 : shake-and-bake ( vocab -- )\r
8     [ "test.image" temp-file delete-file ] ignore-errors\r
9     "resource:" [\r
10         [ vm "test.image" temp-file ] dip\r
11         dup deploy-config make-deploy-image\r
12     ] with-directory ;\r
13 \r
14 : small-enough? ( n -- ? )\r
15     [ "test.image" temp-file file-info size>> ] [ cell 4 / * ] bi* <= ;\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 ( responder -- )\r
75     [\r
76         main-responder set\r
77         <http-server>\r
78             0 >>insecure\r
79             f >>secure\r
80         dup start-server*\r
81         sockets>> first addr>> port>>\r
82         dup number>string "resource:temp/port-number" ascii set-file-contents\r
83     ] with-scope\r
84     "port" set ;\r
85 \r
86 [ ] [\r
87     <dispatcher>\r
88         add-quot-responder\r
89         "resource:basis/http/test" <static> >>default\r
90 \r
91     test-httpd\r
92 ] unit-test\r
93 \r
94 [ ] [\r
95     "tools.deploy.test.5" shake-and-bake\r
96     run-temp-image\r
97 ] unit-test\r
98 \r
99 : add-port ( url -- url' )\r
100     >url clone "port" get >>port ;\r
101 \r
102 [ ] [ "http://localhost/quit" add-port http-get 2drop ] unit-test\r
103 \r
104 [ ] [\r
105     "tools.deploy.test.6" shake-and-bake\r
106     run-temp-image\r
107 ] unit-test\r
108 \r
109 [ ] [\r
110     "tools.deploy.test.7" shake-and-bake\r
111     run-temp-image\r
112 ] unit-test\r