1 USING: io.launcher tools.test calendar accessors environment
2 namespaces kernel system arrays io io.files io.encodings.ascii
3 sequences parser assocs hashtables math continuations eval
4 io.files.temp io.directories io.pathnames splitting ;
5 IN: io.launcher.windows.nt.tests
14 [ f ] [ "notepad" get process-running? ] unit-test
16 [ f ] [ "notepad" get process-started? ] unit-test
18 [ ] [ "notepad" [ run-detached ] change ] unit-test
20 [ "notepad" get wait-for-process ] must-fail
22 [ t ] [ "notepad" get killed>> ] unit-test
24 [ f ] [ "notepad" get process-running? ] unit-test
40 : console-vm ( -- path )
41 vm ".exe" ?tail [ ".com" append ] when ;
45 console-vm "-quiet" "-run=hello-world" 3array >>command
46 "out.txt" temp-file >>stdout
51 "out.txt" temp-file ascii file-lines first
54 [ "( scratchpad ) " ] [
56 console-vm "-run=listener" 2array >>command
59 ascii [ lines last ] with-process-reader
62 : launcher-test-path ( -- str )
63 "resource:basis/io/launcher/windows/nt/test" ;
68 console-vm "-script" "stderr.factor" 3array >>command
69 "out.txt" temp-file >>stdout
70 "err.txt" temp-file >>stderr
76 "out.txt" temp-file ascii file-lines first
80 "err.txt" temp-file ascii file-lines first
86 console-vm "-script" "stderr.factor" 3array >>command
87 "out.txt" temp-file >>stdout
94 "out.txt" temp-file ascii file-lines first
100 console-vm "-script" "stderr.factor" 3array >>command
101 "err2.txt" temp-file >>stderr
102 ascii <process-reader> stream-lines first
107 "err2.txt" temp-file ascii file-lines first
113 console-vm "-script" "env.factor" 3array >>command
114 ascii <process-reader> stream-contents
115 ] with-directory eval( -- alist )
123 console-vm "-script" "env.factor" 3array >>command
124 +replace-environment+ >>environment-mode
125 os-envs >>environment
126 ascii <process-reader> stream-contents
127 ] with-directory eval( -- alist )
135 console-vm "-script" "env.factor" 3array >>command
136 { { "A" "B" } } >>environment
137 ascii <process-reader> stream-contents
138 ] with-directory eval( -- alist )
146 console-vm "-script" "env.factor" 3array >>command
147 { { "USERPROFILE" "XXX" } } >>environment
148 +prepend-environment+ >>environment-mode
149 ascii <process-reader> stream-contents
150 ] with-directory eval( -- alist )
152 "USERPROFILE" swap at "XXX" =
158 "cmd.exe /c dir" >>command
159 "dir.txt" temp-file >>stdout
163 [ ] [ "dir.txt" temp-file delete-file ] unit-test
166 [ "append-test" temp-file delete-file ] ignore-errors
168 [ "Hello appender\r\nHello appender\r\n" ] [
172 console-vm "-script" "append.factor" 3array >>command
173 "append-test" temp-file <appender> >>stdout
178 "append-test" temp-file ascii file-contents
181 [ "( scratchpad ) " ] [
182 console-vm "-run=listener" 2array
183 ascii [ "USE: system 0 exit" print flush lines last ] with-process-stream
187 console-vm "-run=listener" 2array
188 ascii [ "USE: system 0 exit" print ] with-process-writer
193 console-vm "-run=listener" 2array >>command
194 "vocab:io/launcher/windows/nt/test/input.txt" >>stdin