| 
									
										
										
										
											2015-04-01 18:42:54 -04:00
										 |  |  | USING: accessors arrays assocs calendar | 
					
						
							|  |  |  | combinators.short-circuit continuations environment eval | 
					
						
							|  |  |  | hashtables io io.directories io.encodings.ascii | 
					
						
							|  |  |  | io.encodings.utf8 io.files io.files.temp io.files.unique | 
					
						
							|  |  |  | io.launcher io.launcher.windows io.pathnames kernel math | 
					
						
							|  |  |  | namespaces parser sequences splitting system tools.test ;
 | 
					
						
							| 
									
										
										
										
											2012-07-26 02:18:15 -04:00
										 |  |  | IN: io.launcher.windows.tests | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ "hello world" ] [ { "hello" "world" } join-arguments ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ "bob \"mac arthur\"" ] [ { "bob" "mac arthur" } join-arguments ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ "bob mac\\\\arthur" ] [ { "bob" "mac\\\\arthur" } join-arguments ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ "bob \"mac arthur\\\\\"" ] [ { "bob" "mac arthur\\" } join-arguments ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! Bug #245 | 
					
						
							|  |  |  | [ "\\\"hi\\\"" ] [ { "\"hi\"" } join-arguments ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ "\"\\\"hi you\\\"\"" ] [ { "\"hi you\"" } join-arguments ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! Commented line -- what should appear on the command line | 
					
						
							|  |  |  | ! \foo\\bar\\\bas\ -> \foo\\bar\\\bas\ | 
					
						
							|  |  |  | [ "\\foo\\\\bar\\\\\\bas\\" ] | 
					
						
							|  |  |  | [ { "\\foo\\\\bar\\\\\\bas\\" } join-arguments ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! \"foo"\\bar\\\bas\ -> \\\"foo\"\\bar\\\bas\ | 
					
						
							|  |  |  | [ "\\\\\\\"foo\\\"\\\\bar\\\\\\bas\\" ] | 
					
						
							|  |  |  | [ { "\\\"foo\"\\\\bar\\\\\\bas\\" } join-arguments ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! \foo\\"bar"\\\bas\ -> \foo\\\\\"bar\"\\\bas\ | 
					
						
							|  |  |  | [ "\\foo\\\\\\\\\\\"bar\\\"\\\\\\bas\\" ] | 
					
						
							|  |  |  | [ { "\\foo\\\\\"bar\"\\\\\\bas\\" } join-arguments ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! \foo\\bar\\\"bas"\ -> \foo\\bar\\\\\\\"bas\"\ | 
					
						
							|  |  |  | [ "\\foo\\\\bar\\\\\\\\\\\\\\\"bas\\\"\\" ] | 
					
						
							|  |  |  | [ { "\\foo\\\\bar\\\\\\\"bas\"\\" } join-arguments ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! \foo\\bar bar\\\bas\ -> "\foo\\bar bar\\\bas\\" | 
					
						
							|  |  |  | [ "\"\\foo\\\\bar bar\\\\\\bas\\\\\"" ] | 
					
						
							|  |  |  | [ { "\\foo\\\\bar bar\\\\\\bas\\" } join-arguments ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ ] [ | 
					
						
							|  |  |  |     <process> | 
					
						
							|  |  |  |         "notepad" >>command | 
					
						
							|  |  |  |         1/2 seconds >>timeout | 
					
						
							|  |  |  |     "notepad" set
 | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ f ] [ "notepad" get process-running? ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ f ] [ "notepad" get process-started? ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ ] [ "notepad" [ run-detached ] change ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ "notepad" get wait-for-process ] must-fail | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ t ] [ "notepad" get killed>> ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ f ] [ "notepad" get process-running? ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ | 
					
						
							|  |  |  |     <process> | 
					
						
							|  |  |  |         "notepad" >>command | 
					
						
							|  |  |  |         1/2 seconds >>timeout | 
					
						
							|  |  |  |     try-process | 
					
						
							|  |  |  | ] must-fail | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ | 
					
						
							|  |  |  |     <process> | 
					
						
							|  |  |  |         "notepad" >>command | 
					
						
							|  |  |  |         1/2 seconds >>timeout | 
					
						
							|  |  |  |     try-output-process | 
					
						
							|  |  |  | ] must-fail | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : console-vm ( -- path )
 | 
					
						
							|  |  |  |     vm ".exe" ?tail [ ".com" append ] when ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-01 18:42:54 -04:00
										 |  |  | SYMBOLS: out-path err-path ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-26 02:18:15 -04:00
										 |  |  | [ ] [ | 
					
						
							|  |  |  |     <process> | 
					
						
							|  |  |  |         console-vm "-run=hello-world" 2array >>command | 
					
						
							| 
									
										
										
										
											2015-04-01 18:42:54 -04:00
										 |  |  |         "out.txt" unique-file [ out-path set-global ] keep >>stdout | 
					
						
							| 
									
										
										
										
											2012-07-26 02:18:15 -04:00
										 |  |  |     try-process | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ "Hello world" ] [ | 
					
						
							| 
									
										
										
										
											2015-04-01 18:42:54 -04:00
										 |  |  |     out-path get-global ascii file-lines first
 | 
					
						
							| 
									
										
										
										
											2012-07-26 02:18:15 -04:00
										 |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ "IN: scratchpad " ] [ | 
					
						
							|  |  |  |     <process> | 
					
						
							|  |  |  |         console-vm "-run=listener" 2array >>command | 
					
						
							|  |  |  |         +closed+ >>stdin | 
					
						
							|  |  |  |         +stdout+ >>stderr | 
					
						
							| 
									
										
										
										
											2014-06-10 08:59:07 -04:00
										 |  |  |     utf8 [ lines last ] with-process-reader | 
					
						
							| 
									
										
										
										
											2012-07-26 02:18:15 -04:00
										 |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : launcher-test-path ( -- str )
 | 
					
						
							|  |  |  |     "resource:basis/io/launcher/windows/test" ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ ] [ | 
					
						
							|  |  |  |     launcher-test-path [ | 
					
						
							|  |  |  |         <process> | 
					
						
							|  |  |  |             console-vm "-script" "stderr.factor" 3array >>command | 
					
						
							| 
									
										
										
										
											2015-04-01 18:42:54 -04:00
										 |  |  |             "out.txt" unique-file [ out-path set-global ] keep >>stdout | 
					
						
							|  |  |  |             "err.txt" unique-file [ err-path set-global ] keep >>stderr | 
					
						
							| 
									
										
										
										
											2012-07-26 02:18:15 -04:00
										 |  |  |         try-process | 
					
						
							|  |  |  |     ] with-directory | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ "output" ] [ | 
					
						
							| 
									
										
										
										
											2015-04-01 18:42:54 -04:00
										 |  |  |     out-path get-global ascii file-lines first
 | 
					
						
							| 
									
										
										
										
											2012-07-26 02:18:15 -04:00
										 |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ "error" ] [ | 
					
						
							| 
									
										
										
										
											2015-04-01 18:42:54 -04:00
										 |  |  |     err-path get-global ascii file-lines first
 | 
					
						
							| 
									
										
										
										
											2012-07-26 02:18:15 -04:00
										 |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ ] [ | 
					
						
							|  |  |  |     launcher-test-path [ | 
					
						
							|  |  |  |         <process> | 
					
						
							|  |  |  |             console-vm "-script" "stderr.factor" 3array >>command | 
					
						
							| 
									
										
										
										
											2015-04-01 18:42:54 -04:00
										 |  |  |             "out.txt" unique-file [ out-path set-global ] keep >>stdout | 
					
						
							| 
									
										
										
										
											2012-07-26 02:18:15 -04:00
										 |  |  |             +stdout+ >>stderr | 
					
						
							|  |  |  |         try-process | 
					
						
							|  |  |  |     ] with-directory | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ "outputerror" ] [ | 
					
						
							| 
									
										
										
										
											2015-04-01 18:42:54 -04:00
										 |  |  |     out-path get-global ascii file-lines first
 | 
					
						
							| 
									
										
										
										
											2012-07-26 02:18:15 -04:00
										 |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ "output" ] [ | 
					
						
							|  |  |  |     launcher-test-path [ | 
					
						
							|  |  |  |         <process> | 
					
						
							|  |  |  |             console-vm "-script" "stderr.factor" 3array >>command | 
					
						
							| 
									
										
										
										
											2015-04-01 18:42:54 -04:00
										 |  |  |             "err2.txt" unique-file [ err-path set-global ] keep >>stderr | 
					
						
							| 
									
										
										
										
											2014-06-10 08:59:07 -04:00
										 |  |  |         utf8 <process-reader> stream-lines first
 | 
					
						
							| 
									
										
										
										
											2012-07-26 02:18:15 -04:00
										 |  |  |     ] with-directory | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ "error" ] [ | 
					
						
							| 
									
										
										
										
											2015-04-01 18:42:54 -04:00
										 |  |  |     err-path get-global ascii file-lines first
 | 
					
						
							| 
									
										
										
										
											2012-07-26 02:18:15 -04:00
										 |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-16 19:40:49 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-26 02:18:15 -04:00
										 |  |  | [ t ] [ | 
					
						
							|  |  |  |     launcher-test-path [ | 
					
						
							|  |  |  |         <process> | 
					
						
							|  |  |  |             console-vm "-script" "env.factor" 3array >>command | 
					
						
							| 
									
										
										
										
											2014-10-16 19:40:49 -04:00
										 |  |  |         utf8 [ contents ] with-process-reader | 
					
						
							| 
									
										
										
										
											2012-07-26 02:18:15 -04:00
										 |  |  |     ] with-directory eval( -- alist ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     os-envs =
 | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ t ] [ | 
					
						
							|  |  |  |     launcher-test-path [ | 
					
						
							|  |  |  |         <process> | 
					
						
							|  |  |  |             console-vm "-script" "env.factor" 3array >>command | 
					
						
							|  |  |  |             +replace-environment+ >>environment-mode | 
					
						
							|  |  |  |             os-envs >>environment | 
					
						
							| 
									
										
										
										
											2014-10-16 19:40:49 -04:00
										 |  |  |         utf8 [ contents ] with-process-reader | 
					
						
							| 
									
										
										
										
											2012-07-26 02:18:15 -04:00
										 |  |  |     ] with-directory eval( -- alist ) | 
					
						
							| 
									
										
										
										
											2014-06-10 08:59:07 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-26 02:18:15 -04:00
										 |  |  |     os-envs =
 | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ "B" ] [ | 
					
						
							|  |  |  |     launcher-test-path [ | 
					
						
							|  |  |  |         <process> | 
					
						
							|  |  |  |             console-vm "-script" "env.factor" 3array >>command | 
					
						
							|  |  |  |             { { "A" "B" } } >>environment | 
					
						
							| 
									
										
										
										
											2014-10-16 19:40:49 -04:00
										 |  |  |         utf8 [ contents ] with-process-reader | 
					
						
							| 
									
										
										
										
											2012-07-26 02:18:15 -04:00
										 |  |  |     ] with-directory eval( -- alist ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-23 17:35:01 -04:00
										 |  |  |     "A" of
 | 
					
						
							| 
									
										
										
										
											2012-07-26 02:18:15 -04:00
										 |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ f ] [ | 
					
						
							|  |  |  |     launcher-test-path [ | 
					
						
							|  |  |  |         <process> | 
					
						
							|  |  |  |             console-vm "-script" "env.factor" 3array >>command | 
					
						
							|  |  |  |             { { "USERPROFILE" "XXX" } } >>environment | 
					
						
							|  |  |  |             +prepend-environment+ >>environment-mode | 
					
						
							| 
									
										
										
										
											2014-10-16 19:40:49 -04:00
										 |  |  |         utf8 [ contents ] with-process-reader | 
					
						
							| 
									
										
										
										
											2012-07-26 02:18:15 -04:00
										 |  |  |     ] with-directory eval( -- alist ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-23 17:35:01 -04:00
										 |  |  |     "USERPROFILE" of "XXX" =
 | 
					
						
							| 
									
										
										
										
											2012-07-26 02:18:15 -04:00
										 |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 2 [ | 
					
						
							|  |  |  |     [ ] [ | 
					
						
							|  |  |  |         <process> | 
					
						
							|  |  |  |             "cmd.exe /c dir" >>command | 
					
						
							| 
									
										
										
										
											2015-04-01 18:42:54 -04:00
										 |  |  |             "dir.txt" unique-file [ out-path set-global ] keep >>stdout | 
					
						
							| 
									
										
										
										
											2012-07-26 02:18:15 -04:00
										 |  |  |         try-process | 
					
						
							|  |  |  |     ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-01 18:42:54 -04:00
										 |  |  |     [ ] [ out-path get-global delete-file ] unit-test | 
					
						
							| 
									
										
										
										
											2012-07-26 02:18:15 -04:00
										 |  |  | ] times
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-10 08:59:07 -04:00
										 |  |  | { "Hello appender\r\nÖrjan ågren är åter\r\nHello appender\r\nÖrjan ågren är åter\r\n" } [ | 
					
						
							| 
									
										
										
										
											2015-04-01 18:42:54 -04:00
										 |  |  |     "append-test" unique-file out-path set-global
 | 
					
						
							| 
									
										
										
										
											2012-07-26 02:18:15 -04:00
										 |  |  |     2 [ | 
					
						
							|  |  |  |         launcher-test-path [ | 
					
						
							|  |  |  |             <process> | 
					
						
							|  |  |  |                 console-vm "-script" "append.factor" 3array >>command | 
					
						
							| 
									
										
										
										
											2015-04-01 18:42:54 -04:00
										 |  |  |                 out-path get-global <appender> >>stdout | 
					
						
							| 
									
										
										
										
											2012-07-26 02:18:15 -04:00
										 |  |  |             try-process | 
					
						
							|  |  |  |         ] with-directory | 
					
						
							|  |  |  |     ] times
 | 
					
						
							| 
									
										
										
										
											2014-06-10 08:59:07 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-01 18:42:54 -04:00
										 |  |  |     out-path get-global utf8 file-contents | 
					
						
							| 
									
										
										
										
											2012-07-26 02:18:15 -04:00
										 |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ "IN: scratchpad " ] [ | 
					
						
							|  |  |  |     console-vm "-run=listener" 2array
 | 
					
						
							|  |  |  |     ascii [ "USE: system 0 exit" print flush lines last ] with-process-stream | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ ] [ | 
					
						
							|  |  |  |     console-vm "-run=listener" 2array
 | 
					
						
							|  |  |  |     ascii [ "USE: system 0 exit" print ] with-process-writer | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [ ] [ | 
					
						
							|  |  |  |     <process> | 
					
						
							|  |  |  |     console-vm "-run=listener" 2array >>command | 
					
						
							|  |  |  |     "vocab:io/launcher/windows/test/input.txt" >>stdin | 
					
						
							|  |  |  |     try-process | 
					
						
							|  |  |  | ] unit-test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! Regression | 
					
						
							|  |  |  | [ "asdfdontexistplzplz" >process wait-for-success ] | 
					
						
							|  |  |  | [ | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         [ process-failed? ] | 
					
						
							|  |  |  |         [ process>> process? ] | 
					
						
							|  |  |  |         [ process>> command>> "asdfdontexistplzplz" = ] | 
					
						
							|  |  |  |         [ process>> status>> f = ] | 
					
						
							|  |  |  |     } 1&& | 
					
						
							| 
									
										
										
										
											2013-03-23 17:35:01 -04:00
										 |  |  | ] must-fail-with |