1 USING: accessors arrays assocs calendar continuations
\r
2 environment eval hashtables io io.directories
\r
3 io.encodings.ascii io.files io.files.temp io.launcher
\r
4 io.launcher.windows io.pathnames kernel math namespaces parser
\r
5 sequences splitting system tools.test ;
\r
6 IN: io.launcher.windows.tests
\r
8 [ "hello world" ] [ { "hello" "world" } join-arguments ] unit-test
\r
10 [ "bob \"mac arthur\"" ] [ { "bob" "mac arthur" } join-arguments ] unit-test
\r
12 [ "bob mac\\\\arthur" ] [ { "bob" "mac\\\\arthur" } join-arguments ] unit-test
\r
14 [ "bob \"mac arthur\\\\\"" ] [ { "bob" "mac arthur\\" } join-arguments ] unit-test
\r
19 1/2 seconds >>timeout
\r
23 [ f ] [ "notepad" get process-running? ] unit-test
\r
25 [ f ] [ "notepad" get process-started? ] unit-test
\r
27 [ ] [ "notepad" [ run-detached ] change ] unit-test
\r
29 [ "notepad" get wait-for-process ] must-fail
\r
31 [ t ] [ "notepad" get killed>> ] unit-test
\r
33 [ f ] [ "notepad" get process-running? ] unit-test
\r
38 1/2 seconds >>timeout
\r
45 1/2 seconds >>timeout
\r
49 : console-vm ( -- path )
\r
50 vm ".exe" ?tail [ ".com" append ] when ;
\r
54 console-vm "-quiet" "-run=hello-world" 3array >>command
\r
55 "out.txt" temp-file >>stdout
\r
60 "out.txt" temp-file ascii file-lines first
\r
63 [ "( scratchpad ) " ] [
\r
65 console-vm "-run=listener" 2array >>command
\r
68 ascii [ lines last ] with-process-reader
\r
71 : launcher-test-path ( -- str )
\r
72 "resource:basis/io/launcher/windows/test" ;
\r
75 launcher-test-path [
\r
77 console-vm "-script" "stderr.factor" 3array >>command
\r
78 "out.txt" temp-file >>stdout
\r
79 "err.txt" temp-file >>stderr
\r
85 "out.txt" temp-file ascii file-lines first
\r
89 "err.txt" temp-file ascii file-lines first
\r
93 launcher-test-path [
\r
95 console-vm "-script" "stderr.factor" 3array >>command
\r
96 "out.txt" temp-file >>stdout
\r
102 [ "outputerror" ] [
\r
103 "out.txt" temp-file ascii file-lines first
\r
107 launcher-test-path [
\r
109 console-vm "-script" "stderr.factor" 3array >>command
\r
110 "err2.txt" temp-file >>stderr
\r
111 ascii <process-reader> stream-lines first
\r
116 "err2.txt" temp-file ascii file-lines first
\r
120 launcher-test-path [
\r
122 console-vm "-script" "env.factor" 3array >>command
\r
123 ascii <process-reader> stream-contents
\r
124 ] with-directory eval( -- alist )
\r
130 launcher-test-path [
\r
132 console-vm "-script" "env.factor" 3array >>command
\r
133 +replace-environment+ >>environment-mode
\r
134 os-envs >>environment
\r
135 ascii <process-reader> stream-contents
\r
136 ] with-directory eval( -- alist )
\r
142 launcher-test-path [
\r
144 console-vm "-script" "env.factor" 3array >>command
\r
145 { { "A" "B" } } >>environment
\r
146 ascii <process-reader> stream-contents
\r
147 ] with-directory eval( -- alist )
\r
153 launcher-test-path [
\r
155 console-vm "-script" "env.factor" 3array >>command
\r
156 { { "USERPROFILE" "XXX" } } >>environment
\r
157 +prepend-environment+ >>environment-mode
\r
158 ascii <process-reader> stream-contents
\r
159 ] with-directory eval( -- alist )
\r
161 "USERPROFILE" swap at "XXX" =
\r
167 "cmd.exe /c dir" >>command
\r
168 "dir.txt" temp-file >>stdout
\r
172 [ ] [ "dir.txt" temp-file delete-file ] unit-test
\r
175 [ "append-test" temp-file delete-file ] ignore-errors
\r
177 [ "Hello appender\r\nHello appender\r\n" ] [
\r
179 launcher-test-path [
\r
181 console-vm "-script" "append.factor" 3array >>command
\r
182 "append-test" temp-file <appender> >>stdout
\r
187 "append-test" temp-file ascii file-contents
\r
190 [ "( scratchpad ) " ] [
\r
191 console-vm "-run=listener" 2array
\r
192 ascii [ "USE: system 0 exit" print flush lines last ] with-process-stream
\r
196 console-vm "-run=listener" 2array
\r
197 ascii [ "USE: system 0 exit" print ] with-process-writer
\r
202 console-vm "-run=listener" 2array >>command
\r
203 "vocab:io/launcher/windows/test/input.txt" >>stdin
\r