+USING: accessors arrays assocs calendar continuations\r
+environment eval hashtables io io.directories\r
+io.encodings.ascii io.files io.files.temp io.launcher\r
+io.launcher.windows io.pathnames kernel math namespaces parser\r
+sequences splitting system tools.test ;\r
IN: io.launcher.windows.tests\r
-USING: tools.test io.launcher.windows ;\r
\r
[ "hello world" ] [ { "hello" "world" } join-arguments ] unit-test\r
\r
[ "bob mac\\\\arthur" ] [ { "bob" "mac\\\\arthur" } join-arguments ] unit-test\r
\r
[ "bob \"mac arthur\\\\\"" ] [ { "bob" "mac arthur\\" } join-arguments ] unit-test\r
+\r
+[ ] [\r
+ <process>\r
+ "notepad" >>command\r
+ 1/2 seconds >>timeout\r
+ "notepad" set\r
+] unit-test\r
+\r
+[ f ] [ "notepad" get process-running? ] unit-test\r
+\r
+[ f ] [ "notepad" get process-started? ] unit-test\r
+\r
+[ ] [ "notepad" [ run-detached ] change ] unit-test\r
+\r
+[ "notepad" get wait-for-process ] must-fail\r
+\r
+[ t ] [ "notepad" get killed>> ] unit-test\r
+\r
+[ f ] [ "notepad" get process-running? ] unit-test\r
+\r
+[\r
+ <process>\r
+ "notepad" >>command\r
+ 1/2 seconds >>timeout\r
+ try-process\r
+] must-fail\r
+\r
+[\r
+ <process>\r
+ "notepad" >>command\r
+ 1/2 seconds >>timeout\r
+ try-output-process\r
+] must-fail\r
+\r
+: console-vm ( -- path )\r
+ vm ".exe" ?tail [ ".com" append ] when ;\r
+\r
+[ ] [\r
+ <process>\r
+ console-vm "-quiet" "-run=hello-world" 3array >>command\r
+ "out.txt" temp-file >>stdout\r
+ try-process\r
+] unit-test\r
+\r
+[ "Hello world" ] [\r
+ "out.txt" temp-file ascii file-lines first\r
+] unit-test\r
+\r
+[ "( scratchpad ) " ] [\r
+ <process>\r
+ console-vm "-run=listener" 2array >>command\r
+ +closed+ >>stdin\r
+ +stdout+ >>stderr\r
+ ascii [ lines last ] with-process-reader\r
+] unit-test\r
+\r
+: launcher-test-path ( -- str )\r
+ "resource:basis/io/launcher/windows/test" ;\r
+\r
+[ ] [\r
+ launcher-test-path [\r
+ <process>\r
+ console-vm "-script" "stderr.factor" 3array >>command\r
+ "out.txt" temp-file >>stdout\r
+ "err.txt" temp-file >>stderr\r
+ try-process\r
+ ] with-directory\r
+] unit-test\r
+\r
+[ "output" ] [\r
+ "out.txt" temp-file ascii file-lines first\r
+] unit-test\r
+\r
+[ "error" ] [\r
+ "err.txt" temp-file ascii file-lines first\r
+] unit-test\r
+\r
+[ ] [\r
+ launcher-test-path [\r
+ <process>\r
+ console-vm "-script" "stderr.factor" 3array >>command\r
+ "out.txt" temp-file >>stdout\r
+ +stdout+ >>stderr\r
+ try-process\r
+ ] with-directory\r
+] unit-test\r
+\r
+[ "outputerror" ] [\r
+ "out.txt" temp-file ascii file-lines first\r
+] unit-test\r
+\r
+[ "output" ] [\r
+ launcher-test-path [\r
+ <process>\r
+ console-vm "-script" "stderr.factor" 3array >>command\r
+ "err2.txt" temp-file >>stderr\r
+ ascii <process-reader> stream-lines first\r
+ ] with-directory\r
+] unit-test\r
+\r
+[ "error" ] [\r
+ "err2.txt" temp-file ascii file-lines first\r
+] unit-test\r
+\r
+[ t ] [\r
+ launcher-test-path [\r
+ <process>\r
+ console-vm "-script" "env.factor" 3array >>command\r
+ ascii <process-reader> stream-contents\r
+ ] with-directory eval( -- alist )\r
+\r
+ os-envs =\r
+] unit-test\r
+\r
+[ t ] [\r
+ launcher-test-path [\r
+ <process>\r
+ console-vm "-script" "env.factor" 3array >>command\r
+ +replace-environment+ >>environment-mode\r
+ os-envs >>environment\r
+ ascii <process-reader> stream-contents\r
+ ] with-directory eval( -- alist )\r
+ \r
+ os-envs =\r
+] unit-test\r
+\r
+[ "B" ] [\r
+ launcher-test-path [\r
+ <process>\r
+ console-vm "-script" "env.factor" 3array >>command\r
+ { { "A" "B" } } >>environment\r
+ ascii <process-reader> stream-contents\r
+ ] with-directory eval( -- alist )\r
+\r
+ "A" swap at\r
+] unit-test\r
+\r
+[ f ] [\r
+ launcher-test-path [\r
+ <process>\r
+ console-vm "-script" "env.factor" 3array >>command\r
+ { { "USERPROFILE" "XXX" } } >>environment\r
+ +prepend-environment+ >>environment-mode\r
+ ascii <process-reader> stream-contents\r
+ ] with-directory eval( -- alist )\r
+\r
+ "USERPROFILE" swap at "XXX" =\r
+] unit-test\r
+\r
+2 [\r
+ [ ] [\r
+ <process>\r
+ "cmd.exe /c dir" >>command\r
+ "dir.txt" temp-file >>stdout\r
+ try-process\r
+ ] unit-test\r
+\r
+ [ ] [ "dir.txt" temp-file delete-file ] unit-test\r
+] times\r
+\r
+[ "append-test" temp-file delete-file ] ignore-errors\r
+\r
+[ "Hello appender\r\nHello appender\r\n" ] [\r
+ 2 [\r
+ launcher-test-path [\r
+ <process>\r
+ console-vm "-script" "append.factor" 3array >>command\r
+ "append-test" temp-file <appender> >>stdout\r
+ try-process\r
+ ] with-directory\r
+ ] times\r
+ \r
+ "append-test" temp-file ascii file-contents\r
+] unit-test\r
+\r
+[ "( scratchpad ) " ] [\r
+ console-vm "-run=listener" 2array\r
+ ascii [ "USE: system 0 exit" print flush lines last ] with-process-stream\r
+] unit-test\r
+\r
+[ ] [\r
+ console-vm "-run=listener" 2array\r
+ ascii [ "USE: system 0 exit" print ] with-process-writer\r
+] unit-test\r
+\r
+[ ] [\r
+ <process>\r
+ console-vm "-run=listener" 2array >>command\r
+ "vocab:io/launcher/windows/test/input.txt" >>stdin\r
+ try-process\r
+] unit-test\r