io.launcher.windows.tests: dos2unixfy it

db4
Doug Coleman 2012-07-25 23:18:15 -07:00
parent a4d7a76143
commit c448ea0e3e
1 changed files with 242 additions and 242 deletions

View File

@ -1,243 +1,243 @@
USING: accessors arrays assocs calendar continuations USING: accessors arrays assocs calendar continuations
environment eval hashtables io io.directories environment eval hashtables io io.directories
io.encodings.ascii io.files io.files.temp io.launcher io.encodings.ascii io.files io.files.temp io.launcher
io.launcher.windows io.pathnames kernel math namespaces parser io.launcher.windows io.pathnames kernel math namespaces parser
sequences splitting system tools.test combinators.short-circuit ; sequences splitting system tools.test combinators.short-circuit ;
IN: io.launcher.windows.tests IN: io.launcher.windows.tests
[ "hello world" ] [ { "hello" "world" } join-arguments ] unit-test [ "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 [ "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 ! Bug #245
[ "\\\"hi\\\"" ] [ { "\"hi\"" } join-arguments ] unit-test [ "\\\"hi\\\"" ] [ { "\"hi\"" } join-arguments ] unit-test
[ "\"\\\"hi you\\\"\"" ] [ { "\"hi you\"" } join-arguments ] unit-test [ "\"\\\"hi you\\\"\"" ] [ { "\"hi you\"" } join-arguments ] unit-test
! Commented line -- what should appear on the command line ! Commented line -- what should appear on the command line
! \foo\\bar\\\bas\ -> \foo\\bar\\\bas\ ! \foo\\bar\\\bas\ -> \foo\\bar\\\bas\
[ "\\foo\\\\bar\\\\\\bas\\" ] [ "\\foo\\\\bar\\\\\\bas\\" ]
[ { "\\foo\\\\bar\\\\\\bas\\" } join-arguments ] unit-test [ { "\\foo\\\\bar\\\\\\bas\\" } join-arguments ] unit-test
! \"foo"\\bar\\\bas\ -> \\\"foo\"\\bar\\\bas\ ! \"foo"\\bar\\\bas\ -> \\\"foo\"\\bar\\\bas\
[ "\\\\\\\"foo\\\"\\\\bar\\\\\\bas\\" ] [ "\\\\\\\"foo\\\"\\\\bar\\\\\\bas\\" ]
[ { "\\\"foo\"\\\\bar\\\\\\bas\\" } join-arguments ] unit-test [ { "\\\"foo\"\\\\bar\\\\\\bas\\" } join-arguments ] unit-test
! \foo\\"bar"\\\bas\ -> \foo\\\\\"bar\"\\\bas\ ! \foo\\"bar"\\\bas\ -> \foo\\\\\"bar\"\\\bas\
[ "\\foo\\\\\\\\\\\"bar\\\"\\\\\\bas\\" ] [ "\\foo\\\\\\\\\\\"bar\\\"\\\\\\bas\\" ]
[ { "\\foo\\\\\"bar\"\\\\\\bas\\" } join-arguments ] unit-test [ { "\\foo\\\\\"bar\"\\\\\\bas\\" } join-arguments ] unit-test
! \foo\\bar\\\"bas"\ -> \foo\\bar\\\\\\\"bas\"\ ! \foo\\bar\\\"bas"\ -> \foo\\bar\\\\\\\"bas\"\
[ "\\foo\\\\bar\\\\\\\\\\\\\\\"bas\\\"\\" ] [ "\\foo\\\\bar\\\\\\\\\\\\\\\"bas\\\"\\" ]
[ { "\\foo\\\\bar\\\\\\\"bas\"\\" } join-arguments ] unit-test [ { "\\foo\\\\bar\\\\\\\"bas\"\\" } join-arguments ] unit-test
! \foo\\bar bar\\\bas\ -> "\foo\\bar bar\\\bas\\" ! \foo\\bar bar\\\bas\ -> "\foo\\bar bar\\\bas\\"
[ "\"\\foo\\\\bar bar\\\\\\bas\\\\\"" ] [ "\"\\foo\\\\bar bar\\\\\\bas\\\\\"" ]
[ { "\\foo\\\\bar bar\\\\\\bas\\" } join-arguments ] unit-test [ { "\\foo\\\\bar bar\\\\\\bas\\" } join-arguments ] unit-test
[ ] [ [ ] [
<process> <process>
"notepad" >>command "notepad" >>command
1/2 seconds >>timeout 1/2 seconds >>timeout
"notepad" set "notepad" set
] unit-test ] unit-test
[ f ] [ "notepad" get process-running? ] unit-test [ f ] [ "notepad" get process-running? ] unit-test
[ f ] [ "notepad" get process-started? ] unit-test [ f ] [ "notepad" get process-started? ] unit-test
[ ] [ "notepad" [ run-detached ] change ] unit-test [ ] [ "notepad" [ run-detached ] change ] unit-test
[ "notepad" get wait-for-process ] must-fail [ "notepad" get wait-for-process ] must-fail
[ t ] [ "notepad" get killed>> ] unit-test [ t ] [ "notepad" get killed>> ] unit-test
[ f ] [ "notepad" get process-running? ] unit-test [ f ] [ "notepad" get process-running? ] unit-test
[ [
<process> <process>
"notepad" >>command "notepad" >>command
1/2 seconds >>timeout 1/2 seconds >>timeout
try-process try-process
] must-fail ] must-fail
[ [
<process> <process>
"notepad" >>command "notepad" >>command
1/2 seconds >>timeout 1/2 seconds >>timeout
try-output-process try-output-process
] must-fail ] must-fail
: console-vm ( -- path ) : console-vm ( -- path )
vm ".exe" ?tail [ ".com" append ] when ; vm ".exe" ?tail [ ".com" append ] when ;
[ ] [ [ ] [
<process> <process>
console-vm "-run=hello-world" 2array >>command console-vm "-run=hello-world" 2array >>command
"out.txt" temp-file >>stdout "out.txt" temp-file >>stdout
try-process try-process
] unit-test ] unit-test
[ "Hello world" ] [ [ "Hello world" ] [
"out.txt" temp-file ascii file-lines first "out.txt" temp-file ascii file-lines first
] unit-test ] unit-test
[ "IN: scratchpad " ] [ [ "IN: scratchpad " ] [
<process> <process>
console-vm "-run=listener" 2array >>command console-vm "-run=listener" 2array >>command
+closed+ >>stdin +closed+ >>stdin
+stdout+ >>stderr +stdout+ >>stderr
ascii [ lines last ] with-process-reader ascii [ lines last ] with-process-reader
] unit-test ] unit-test
: launcher-test-path ( -- str ) : launcher-test-path ( -- str )
"resource:basis/io/launcher/windows/test" ; "resource:basis/io/launcher/windows/test" ;
[ ] [ [ ] [
launcher-test-path [ launcher-test-path [
<process> <process>
console-vm "-script" "stderr.factor" 3array >>command console-vm "-script" "stderr.factor" 3array >>command
"out.txt" temp-file >>stdout "out.txt" temp-file >>stdout
"err.txt" temp-file >>stderr "err.txt" temp-file >>stderr
try-process try-process
] with-directory ] with-directory
] unit-test ] unit-test
[ "output" ] [ [ "output" ] [
"out.txt" temp-file ascii file-lines first "out.txt" temp-file ascii file-lines first
] unit-test ] unit-test
[ "error" ] [ [ "error" ] [
"err.txt" temp-file ascii file-lines first "err.txt" temp-file ascii file-lines first
] unit-test ] unit-test
[ ] [ [ ] [
launcher-test-path [ launcher-test-path [
<process> <process>
console-vm "-script" "stderr.factor" 3array >>command console-vm "-script" "stderr.factor" 3array >>command
"out.txt" temp-file >>stdout "out.txt" temp-file >>stdout
+stdout+ >>stderr +stdout+ >>stderr
try-process try-process
] with-directory ] with-directory
] unit-test ] unit-test
[ "outputerror" ] [ [ "outputerror" ] [
"out.txt" temp-file ascii file-lines first "out.txt" temp-file ascii file-lines first
] unit-test ] unit-test
[ "output" ] [ [ "output" ] [
launcher-test-path [ launcher-test-path [
<process> <process>
console-vm "-script" "stderr.factor" 3array >>command console-vm "-script" "stderr.factor" 3array >>command
"err2.txt" temp-file >>stderr "err2.txt" temp-file >>stderr
ascii <process-reader> stream-lines first ascii <process-reader> stream-lines first
] with-directory ] with-directory
] unit-test ] unit-test
[ "error" ] [ [ "error" ] [
"err2.txt" temp-file ascii file-lines first "err2.txt" temp-file ascii file-lines first
] unit-test ] unit-test
[ t ] [ [ t ] [
launcher-test-path [ launcher-test-path [
<process> <process>
console-vm "-script" "env.factor" 3array >>command console-vm "-script" "env.factor" 3array >>command
ascii <process-reader> stream-contents ascii <process-reader> stream-contents
] with-directory eval( -- alist ) ] with-directory eval( -- alist )
os-envs = os-envs =
] unit-test ] unit-test
[ t ] [ [ t ] [
launcher-test-path [ launcher-test-path [
<process> <process>
console-vm "-script" "env.factor" 3array >>command console-vm "-script" "env.factor" 3array >>command
+replace-environment+ >>environment-mode +replace-environment+ >>environment-mode
os-envs >>environment os-envs >>environment
ascii <process-reader> stream-contents ascii <process-reader> stream-contents
] with-directory eval( -- alist ) ] with-directory eval( -- alist )
os-envs = os-envs =
] unit-test ] unit-test
[ "B" ] [ [ "B" ] [
launcher-test-path [ launcher-test-path [
<process> <process>
console-vm "-script" "env.factor" 3array >>command console-vm "-script" "env.factor" 3array >>command
{ { "A" "B" } } >>environment { { "A" "B" } } >>environment
ascii <process-reader> stream-contents ascii <process-reader> stream-contents
] with-directory eval( -- alist ) ] with-directory eval( -- alist )
"A" swap at "A" swap at
] unit-test ] unit-test
[ f ] [ [ f ] [
launcher-test-path [ launcher-test-path [
<process> <process>
console-vm "-script" "env.factor" 3array >>command console-vm "-script" "env.factor" 3array >>command
{ { "USERPROFILE" "XXX" } } >>environment { { "USERPROFILE" "XXX" } } >>environment
+prepend-environment+ >>environment-mode +prepend-environment+ >>environment-mode
ascii <process-reader> stream-contents ascii <process-reader> stream-contents
] with-directory eval( -- alist ) ] with-directory eval( -- alist )
"USERPROFILE" swap at "XXX" = "USERPROFILE" swap at "XXX" =
] unit-test ] unit-test
2 [ 2 [
[ ] [ [ ] [
<process> <process>
"cmd.exe /c dir" >>command "cmd.exe /c dir" >>command
"dir.txt" temp-file >>stdout "dir.txt" temp-file >>stdout
try-process try-process
] unit-test ] unit-test
[ ] [ "dir.txt" temp-file delete-file ] unit-test [ ] [ "dir.txt" temp-file delete-file ] unit-test
] times ] times
[ "append-test" temp-file delete-file ] ignore-errors [ "append-test" temp-file delete-file ] ignore-errors
[ "Hello appender\r\nHello appender\r\n" ] [ [ "Hello appender\r\nHello appender\r\n" ] [
2 [ 2 [
launcher-test-path [ launcher-test-path [
<process> <process>
console-vm "-script" "append.factor" 3array >>command console-vm "-script" "append.factor" 3array >>command
"append-test" temp-file <appender> >>stdout "append-test" temp-file <appender> >>stdout
try-process try-process
] with-directory ] with-directory
] times ] times
"append-test" temp-file ascii file-contents "append-test" temp-file ascii file-contents
] unit-test ] unit-test
[ "IN: scratchpad " ] [ [ "IN: scratchpad " ] [
console-vm "-run=listener" 2array console-vm "-run=listener" 2array
ascii [ "USE: system 0 exit" print flush lines last ] with-process-stream ascii [ "USE: system 0 exit" print flush lines last ] with-process-stream
] unit-test ] unit-test
[ ] [ [ ] [
console-vm "-run=listener" 2array console-vm "-run=listener" 2array
ascii [ "USE: system 0 exit" print ] with-process-writer ascii [ "USE: system 0 exit" print ] with-process-writer
] unit-test ] unit-test
[ ] [ [ ] [
<process> <process>
console-vm "-run=listener" 2array >>command console-vm "-run=listener" 2array >>command
"vocab:io/launcher/windows/test/input.txt" >>stdin "vocab:io/launcher/windows/test/input.txt" >>stdin
try-process try-process
] unit-test ] unit-test
! Regression ! Regression
[ "asdfdontexistplzplz" >process wait-for-success ] [ "asdfdontexistplzplz" >process wait-for-success ]
[ [
{ {
[ process-failed? ] [ process-failed? ]
[ process>> process? ] [ process>> process? ]
[ process>> command>> "asdfdontexistplzplz" = ] [ process>> command>> "asdfdontexistplzplz" = ]
[ process>> status>> f = ] [ process>> status>> f = ]
} 1&& } 1&&
] must-fail-with ] must-fail-with