1 USING: accessors arrays assocs calendar continuations
2 environment eval hashtables io io.directories
3 io.encodings.ascii io.files io.files.temp io.launcher
4 io.launcher.windows io.pathnames kernel math namespaces parser
5 sequences splitting system tools.test combinators.short-circuit ;
6 IN: io.launcher.windows.tests
8 [ "hello world" ] [ { "hello" "world" } join-arguments ] unit-test
10 [ "bob \"mac arthur\"" ] [ { "bob" "mac arthur" } join-arguments ] unit-test
12 [ "bob mac\\\\arthur" ] [ { "bob" "mac\\\\arthur" } join-arguments ] unit-test
14 [ "bob \"mac arthur\\\\\"" ] [ { "bob" "mac arthur\\" } join-arguments ] unit-test
17 [ "\\\"hi\\\"" ] [ { "\"hi\"" } join-arguments ] unit-test
19 [ "\"\\\"hi you\\\"\"" ] [ { "\"hi you\"" } join-arguments ] unit-test
21 ! Commented line -- what should appear on the command line
22 ! \foo\\bar\\\bas\ -> \foo\\bar\\\bas\
23 [ "\\foo\\\\bar\\\\\\bas\\" ]
24 [ { "\\foo\\\\bar\\\\\\bas\\" } join-arguments ] unit-test
26 ! \"foo"\\bar\\\bas\ -> \\\"foo\"\\bar\\\bas\
27 [ "\\\\\\\"foo\\\"\\\\bar\\\\\\bas\\" ]
28 [ { "\\\"foo\"\\\\bar\\\\\\bas\\" } join-arguments ] unit-test
30 ! \foo\\"bar"\\\bas\ -> \foo\\\\\"bar\"\\\bas\
31 [ "\\foo\\\\\\\\\\\"bar\\\"\\\\\\bas\\" ]
32 [ { "\\foo\\\\\"bar\"\\\\\\bas\\" } join-arguments ] unit-test
34 ! \foo\\bar\\\"bas"\ -> \foo\\bar\\\\\\\"bas\"\
35 [ "\\foo\\\\bar\\\\\\\\\\\\\\\"bas\\\"\\" ]
36 [ { "\\foo\\\\bar\\\\\\\"bas\"\\" } join-arguments ] unit-test
38 ! \foo\\bar bar\\\bas\ -> "\foo\\bar bar\\\bas\\"
39 [ "\"\\foo\\\\bar bar\\\\\\bas\\\\\"" ]
40 [ { "\\foo\\\\bar bar\\\\\\bas\\" } join-arguments ] unit-test
50 [ f ] [ "notepad" get process-running? ] unit-test
52 [ f ] [ "notepad" get process-started? ] unit-test
54 [ ] [ "notepad" [ run-detached ] change ] unit-test
56 [ "notepad" get wait-for-process ] must-fail
58 [ t ] [ "notepad" get killed>> ] unit-test
60 [ f ] [ "notepad" get process-running? ] unit-test
76 : console-vm ( -- path )
77 vm ".exe" ?tail [ ".com" append ] when ;
81 console-vm "-run=hello-world" 2array >>command
82 "out.txt" temp-file >>stdout
87 "out.txt" temp-file ascii file-lines first
90 [ "IN: scratchpad " ] [
92 console-vm "-run=listener" 2array >>command
95 ascii [ lines last ] with-process-reader
98 : launcher-test-path ( -- str )
99 "resource:basis/io/launcher/windows/test" ;
104 console-vm "-script" "stderr.factor" 3array >>command
105 "out.txt" temp-file >>stdout
106 "err.txt" temp-file >>stderr
112 "out.txt" temp-file ascii file-lines first
116 "err.txt" temp-file ascii file-lines first
122 console-vm "-script" "stderr.factor" 3array >>command
123 "out.txt" temp-file >>stdout
130 "out.txt" temp-file ascii file-lines first
136 console-vm "-script" "stderr.factor" 3array >>command
137 "err2.txt" temp-file >>stderr
138 ascii <process-reader> stream-lines first
143 "err2.txt" temp-file ascii file-lines first
149 console-vm "-script" "env.factor" 3array >>command
150 ascii <process-reader> stream-contents
151 ] with-directory eval( -- alist )
159 console-vm "-script" "env.factor" 3array >>command
160 +replace-environment+ >>environment-mode
161 os-envs >>environment
162 ascii <process-reader> stream-contents
163 ] with-directory eval( -- alist )
171 console-vm "-script" "env.factor" 3array >>command
172 { { "A" "B" } } >>environment
173 ascii <process-reader> stream-contents
174 ] with-directory eval( -- alist )
182 console-vm "-script" "env.factor" 3array >>command
183 { { "USERPROFILE" "XXX" } } >>environment
184 +prepend-environment+ >>environment-mode
185 ascii <process-reader> stream-contents
186 ] with-directory eval( -- alist )
188 "USERPROFILE" of "XXX" =
194 "cmd.exe /c dir" >>command
195 "dir.txt" temp-file >>stdout
199 [ ] [ "dir.txt" temp-file delete-file ] unit-test
202 [ "append-test" temp-file delete-file ] ignore-errors
204 [ "Hello appender\r\nHello appender\r\n" ] [
208 console-vm "-script" "append.factor" 3array >>command
209 "append-test" temp-file <appender> >>stdout
214 "append-test" temp-file ascii file-contents
217 [ "IN: scratchpad " ] [
218 console-vm "-run=listener" 2array
219 ascii [ "USE: system 0 exit" print flush lines last ] with-process-stream
223 console-vm "-run=listener" 2array
224 ascii [ "USE: system 0 exit" print ] with-process-writer
229 console-vm "-run=listener" 2array >>command
230 "vocab:io/launcher/windows/test/input.txt" >>stdin
235 [ "asdfdontexistplzplz" >process wait-for-success ]
239 [ process>> process? ]
240 [ process>> command>> "asdfdontexistplzplz" = ]
241 [ process>> status>> f = ]