]> gitweb.factorcode.org Git - factor.git/blob - basis/tools/deploy/deploy-tests.factor
http.server.responses: adding <html-content>, use it.
[factor.git] / basis / tools / deploy / deploy-tests.factor
1 USING: bootstrap.image tools.test system io io.encodings.ascii
2 io.pathnames io.files io.files.info io.files.temp kernel
3 tools.deploy.config tools.deploy.config.editor
4 tools.deploy.backend math sequences io.launcher arrays
5 namespaces continuations layouts accessors urls math.parser
6 io.directories splitting tools.deploy tools.deploy.test vocabs ;
7
8 IN: tools.deploy.tests
9
10 ! Delete all cached staging images in case syntax or
11 ! other core vocabularies have changed and staging
12 ! images are stale.
13 cache-directory [
14     [ "staging." head? ] filter
15     my-arch ".image" append [ tail? ] curry filter
16     [ delete-file ] each
17 ] with-directory-files
18
19 [ "nosuchvocab" deploy ] [ no-vocab? ] must-fail-with
20
21 [ "no such vocab, fool!" deploy ] [ bad-vocab-name? ] must-fail-with
22
23 [ ] [ "hello-world" shake-and-bake 500000 small-enough? ] unit-test
24
25 [ ] [ "sudoku" shake-and-bake 800000 small-enough? ] unit-test
26
27 [ ] [ "hello-ui" shake-and-bake 1300000 small-enough? ] unit-test
28
29 [ "math-threads-compiler-ui" ] [
30     "hello-ui" deploy-config [
31         bootstrap-profile staging-image-name file-name
32         "." split second
33     ] with-variables
34 ] unit-test
35
36 [ ] [ "maze" shake-and-bake 1200000 small-enough? ] unit-test
37
38 [ ] [ "tetris" shake-and-bake 1500000 small-enough? ] unit-test
39
40 [ ] [ "spheres" shake-and-bake 1500000 small-enough? ] unit-test
41
42 [ ] [ "terrain" shake-and-bake 1700000 small-enough? ] unit-test
43
44 [ ] [ "gpu.demos.raytrace" shake-and-bake 2500000 small-enough? ] unit-test
45
46 [ ] [ "bunny" shake-and-bake 2500000 small-enough? ] unit-test
47
48 [ ] [ "gpu.demos.bunny" shake-and-bake 3500000 small-enough? ] unit-test
49
50 os macosx? [
51     [ ] [ "webkit-demo" shake-and-bake 500000 small-enough? ] unit-test
52 ] when
53
54 [ ] [ "benchmark.regex-dna" shake-and-bake 900000 small-enough? ] unit-test
55
56 {
57     "tools.deploy.test.1"
58     "tools.deploy.test.2"
59     "tools.deploy.test.3"
60     "tools.deploy.test.4"
61 } [
62     [ ] swap [
63         shake-and-bake
64         run-temp-image
65     ] curry unit-test
66 ] each
67
68 USING: http.client http.server http.server.dispatchers
69 http.server.responses http.server.static io.servers ;
70
71 SINGLETON: quit-responder
72
73 M: quit-responder call-responder*
74     2drop stop-this-server "Goodbye" <html-content> ;
75
76 : add-quot-responder ( responder -- responder )
77     quit-responder "quit" add-responder ;
78
79 : test-httpd ( responder -- )
80     [
81         main-responder set
82         <http-server>
83             0 >>insecure
84             f >>secure
85         start-server
86         servers>> first addr>> port>>
87         dup number>string "port-number" temp-file ascii set-file-contents
88     ] with-scope
89     "port" set ;
90
91 [ ] [
92     <dispatcher>
93         add-quot-responder
94         "vocab:http/test" <static> >>default
95
96     test-httpd
97 ] unit-test
98
99 [ ] [
100     "tools.deploy.test.5" shake-and-bake
101     run-temp-image
102 ] unit-test
103
104 : add-port ( url -- url' )
105     >url clone "port" get >>port ;
106
107 [ ] [ "http://localhost/quit" add-port http-get 2drop ] unit-test
108
109 {
110     "tools.deploy.test.6"
111     "tools.deploy.test.7"
112     "tools.deploy.test.9"
113     "tools.deploy.test.10"
114     "tools.deploy.test.11"
115     "tools.deploy.test.12"
116 } [
117     [ ] swap [
118         shake-and-bake
119         run-temp-image
120     ] curry unit-test
121 ] each
122
123 os windows? os macosx? or [
124     [ ] [ "tools.deploy.test.8" shake-and-bake run-temp-image ] unit-test
125 ] when
126
127 os macosx? [
128     [ ] [ "tools.deploy.test.14" shake-and-bake run-temp-image ] unit-test
129 ] when
130
131 [ { "a" "b" "c" } ] [
132     "tools.deploy.test.15" shake-and-bake deploy-test-command
133     { "a" "b" "c" } append
134     ascii [ lines ] with-process-reader
135     rest
136 ] unit-test
137
138 [ ] [ "tools.deploy.test.16" shake-and-bake run-temp-image ] unit-test
139
140 [ ] [ "tools.deploy.test.17" shake-and-bake run-temp-image ] unit-test
141
142 [ t ] [
143     "tools.deploy.test.18" shake-and-bake
144     deploy-test-command ascii [ readln ] with-process-reader
145     test-image temp-file =
146 ] unit-test
147
148 [ ] [ "resource:license.txt" "license.txt" temp-file copy-file ] unit-test
149
150 [ ] [ "tools.deploy.test.19" shake-and-bake run-temp-image ] unit-test
151
152 [ ] [ "tools.deploy.test.20" shake-and-bake ] unit-test
153
154 [ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><foo>Factor</foo>" ]
155 [ deploy-test-command ascii [ readln ] with-process-reader ] unit-test
156
157 [ ] [ "tools.deploy.test.20" drop 870000 small-enough? ] unit-test
158
159 [ ] [ "tools.deploy.test.21" shake-and-bake ] unit-test
160
161 [ "1 2 3" ]
162 [ deploy-test-command ascii [ readln ] with-process-reader ] unit-test
163
164 [ ] [ "tools.deploy.test.21" drop 800000 small-enough? ] unit-test
165
166 [ ] [ "benchmark.ui-panes" shake-and-bake run-temp-image ] unit-test