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
26 : console-vm ( -- path )
27 vm ".exe" ?tail [ ".com" append ] when ;
31 console-vm "-quiet" "-run=hello-world" 3array >>command
32 "out.txt" temp-file >>stdout
37 "out.txt" temp-file ascii file-lines first
40 [ "( scratchpad ) " ] [
42 console-vm "-run=listener" 2array >>command
45 ascii [ contents ] with-process-reader
48 : launcher-test-path ( -- str )
49 "resource:basis/io/launcher/windows/nt/test" ;
54 console-vm "-script" "stderr.factor" 3array >>command
55 "out.txt" temp-file >>stdout
56 "err.txt" temp-file >>stderr
62 "out.txt" temp-file ascii file-lines first
66 "err.txt" temp-file ascii file-lines first
72 console-vm "-script" "stderr.factor" 3array >>command
73 "out.txt" temp-file >>stdout
80 "out.txt" temp-file ascii file-lines first
86 console-vm "-script" "stderr.factor" 3array >>command
87 "err2.txt" temp-file >>stderr
88 ascii <process-reader> stream-lines first
93 "err2.txt" temp-file ascii file-lines first
99 console-vm "-script" "env.factor" 3array >>command
100 ascii <process-reader> stream-contents
101 ] with-directory eval( -- alist )
109 console-vm "-script" "env.factor" 3array >>command
110 +replace-environment+ >>environment-mode
111 os-envs >>environment
112 ascii <process-reader> stream-contents
113 ] with-directory eval( -- alist )
121 console-vm "-script" "env.factor" 3array >>command
122 { { "A" "B" } } >>environment
123 ascii <process-reader> stream-contents
124 ] with-directory eval( -- alist )
132 console-vm "-script" "env.factor" 3array >>command
133 { { "USERPROFILE" "XXX" } } >>environment
134 +prepend-environment+ >>environment-mode
135 ascii <process-reader> stream-contents
136 ] with-directory eval( -- alist )
138 "USERPROFILE" swap at "XXX" =
144 "cmd.exe /c dir" >>command
145 "dir.txt" temp-file >>stdout
149 [ ] [ "dir.txt" temp-file delete-file ] unit-test
152 [ "append-test" temp-file delete-file ] ignore-errors
154 [ "Hello appender\r\nHello appender\r\n" ] [
158 console-vm "-script" "append.factor" 3array >>command
159 "append-test" temp-file <appender> >>stdout
164 "append-test" temp-file ascii file-contents
167 [ "( scratchpad ) " ] [
168 console-vm "-run=listener" 2array
169 ascii [ "USE: system 0 exit" print flush readln ] with-process-stream
173 console-vm "-run=listener" 2array
174 ascii [ "USE: system 0 exit" print ] with-process-writer
179 console-vm "-run=listener" 2array >>command
180 "vocab:io/launcher/windows/nt/test/input.txt" >>stdin