From c448ea0e3e71d566f4943e99057fd326cf6cd200 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 25 Jul 2012 23:18:15 -0700 Subject: [PATCH] io.launcher.windows.tests: dos2unixfy it --- .../io/launcher/windows/windows-tests.factor | 484 +++++++++--------- 1 file changed, 242 insertions(+), 242 deletions(-) diff --git a/basis/io/launcher/windows/windows-tests.factor b/basis/io/launcher/windows/windows-tests.factor index 628b783b89..754c3db871 100644 --- a/basis/io/launcher/windows/windows-tests.factor +++ b/basis/io/launcher/windows/windows-tests.factor @@ -1,243 +1,243 @@ -USING: accessors arrays assocs calendar continuations -environment eval hashtables io io.directories -io.encodings.ascii io.files io.files.temp io.launcher -io.launcher.windows io.pathnames kernel math namespaces parser -sequences splitting system tools.test combinators.short-circuit ; -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 - - -[ ] [ - - "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 - -[ - - "notepad" >>command - 1/2 seconds >>timeout - try-process -] must-fail - -[ - - "notepad" >>command - 1/2 seconds >>timeout - try-output-process -] must-fail - -: console-vm ( -- path ) - vm ".exe" ?tail [ ".com" append ] when ; - -[ ] [ - - console-vm "-run=hello-world" 2array >>command - "out.txt" temp-file >>stdout - try-process -] unit-test - -[ "Hello world" ] [ - "out.txt" temp-file ascii file-lines first -] unit-test - -[ "IN: scratchpad " ] [ - - console-vm "-run=listener" 2array >>command - +closed+ >>stdin - +stdout+ >>stderr - ascii [ lines last ] with-process-reader -] unit-test - -: launcher-test-path ( -- str ) - "resource:basis/io/launcher/windows/test" ; - -[ ] [ - launcher-test-path [ - - console-vm "-script" "stderr.factor" 3array >>command - "out.txt" temp-file >>stdout - "err.txt" temp-file >>stderr - try-process - ] with-directory -] unit-test - -[ "output" ] [ - "out.txt" temp-file ascii file-lines first -] unit-test - -[ "error" ] [ - "err.txt" temp-file ascii file-lines first -] unit-test - -[ ] [ - launcher-test-path [ - - console-vm "-script" "stderr.factor" 3array >>command - "out.txt" temp-file >>stdout - +stdout+ >>stderr - try-process - ] with-directory -] unit-test - -[ "outputerror" ] [ - "out.txt" temp-file ascii file-lines first -] unit-test - -[ "output" ] [ - launcher-test-path [ - - console-vm "-script" "stderr.factor" 3array >>command - "err2.txt" temp-file >>stderr - ascii stream-lines first - ] with-directory -] unit-test - -[ "error" ] [ - "err2.txt" temp-file ascii file-lines first -] unit-test - -[ t ] [ - launcher-test-path [ - - console-vm "-script" "env.factor" 3array >>command - ascii stream-contents - ] with-directory eval( -- alist ) - - os-envs = -] unit-test - -[ t ] [ - launcher-test-path [ - - console-vm "-script" "env.factor" 3array >>command - +replace-environment+ >>environment-mode - os-envs >>environment - ascii stream-contents - ] with-directory eval( -- alist ) - - os-envs = -] unit-test - -[ "B" ] [ - launcher-test-path [ - - console-vm "-script" "env.factor" 3array >>command - { { "A" "B" } } >>environment - ascii stream-contents - ] with-directory eval( -- alist ) - - "A" swap at -] unit-test - -[ f ] [ - launcher-test-path [ - - console-vm "-script" "env.factor" 3array >>command - { { "USERPROFILE" "XXX" } } >>environment - +prepend-environment+ >>environment-mode - ascii stream-contents - ] with-directory eval( -- alist ) - - "USERPROFILE" swap at "XXX" = -] unit-test - -2 [ - [ ] [ - - "cmd.exe /c dir" >>command - "dir.txt" temp-file >>stdout - try-process - ] unit-test - - [ ] [ "dir.txt" temp-file delete-file ] unit-test -] times - -[ "append-test" temp-file delete-file ] ignore-errors - -[ "Hello appender\r\nHello appender\r\n" ] [ - 2 [ - launcher-test-path [ - - console-vm "-script" "append.factor" 3array >>command - "append-test" temp-file >>stdout - try-process - ] with-directory - ] times - - "append-test" temp-file ascii file-contents -] 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 - -[ ] [ - - 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&& +USING: accessors arrays assocs calendar continuations +environment eval hashtables io io.directories +io.encodings.ascii io.files io.files.temp io.launcher +io.launcher.windows io.pathnames kernel math namespaces parser +sequences splitting system tools.test combinators.short-circuit ; +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 + + +[ ] [ + + "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 + +[ + + "notepad" >>command + 1/2 seconds >>timeout + try-process +] must-fail + +[ + + "notepad" >>command + 1/2 seconds >>timeout + try-output-process +] must-fail + +: console-vm ( -- path ) + vm ".exe" ?tail [ ".com" append ] when ; + +[ ] [ + + console-vm "-run=hello-world" 2array >>command + "out.txt" temp-file >>stdout + try-process +] unit-test + +[ "Hello world" ] [ + "out.txt" temp-file ascii file-lines first +] unit-test + +[ "IN: scratchpad " ] [ + + console-vm "-run=listener" 2array >>command + +closed+ >>stdin + +stdout+ >>stderr + ascii [ lines last ] with-process-reader +] unit-test + +: launcher-test-path ( -- str ) + "resource:basis/io/launcher/windows/test" ; + +[ ] [ + launcher-test-path [ + + console-vm "-script" "stderr.factor" 3array >>command + "out.txt" temp-file >>stdout + "err.txt" temp-file >>stderr + try-process + ] with-directory +] unit-test + +[ "output" ] [ + "out.txt" temp-file ascii file-lines first +] unit-test + +[ "error" ] [ + "err.txt" temp-file ascii file-lines first +] unit-test + +[ ] [ + launcher-test-path [ + + console-vm "-script" "stderr.factor" 3array >>command + "out.txt" temp-file >>stdout + +stdout+ >>stderr + try-process + ] with-directory +] unit-test + +[ "outputerror" ] [ + "out.txt" temp-file ascii file-lines first +] unit-test + +[ "output" ] [ + launcher-test-path [ + + console-vm "-script" "stderr.factor" 3array >>command + "err2.txt" temp-file >>stderr + ascii stream-lines first + ] with-directory +] unit-test + +[ "error" ] [ + "err2.txt" temp-file ascii file-lines first +] unit-test + +[ t ] [ + launcher-test-path [ + + console-vm "-script" "env.factor" 3array >>command + ascii stream-contents + ] with-directory eval( -- alist ) + + os-envs = +] unit-test + +[ t ] [ + launcher-test-path [ + + console-vm "-script" "env.factor" 3array >>command + +replace-environment+ >>environment-mode + os-envs >>environment + ascii stream-contents + ] with-directory eval( -- alist ) + + os-envs = +] unit-test + +[ "B" ] [ + launcher-test-path [ + + console-vm "-script" "env.factor" 3array >>command + { { "A" "B" } } >>environment + ascii stream-contents + ] with-directory eval( -- alist ) + + "A" swap at +] unit-test + +[ f ] [ + launcher-test-path [ + + console-vm "-script" "env.factor" 3array >>command + { { "USERPROFILE" "XXX" } } >>environment + +prepend-environment+ >>environment-mode + ascii stream-contents + ] with-directory eval( -- alist ) + + "USERPROFILE" swap at "XXX" = +] unit-test + +2 [ + [ ] [ + + "cmd.exe /c dir" >>command + "dir.txt" temp-file >>stdout + try-process + ] unit-test + + [ ] [ "dir.txt" temp-file delete-file ] unit-test +] times + +[ "append-test" temp-file delete-file ] ignore-errors + +[ "Hello appender\r\nHello appender\r\n" ] [ + 2 [ + launcher-test-path [ + + console-vm "-script" "append.factor" 3array >>command + "append-test" temp-file >>stdout + try-process + ] with-directory + ] times + + "append-test" temp-file ascii file-contents +] 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 + +[ ] [ + + 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&& ] must-fail-with \ No newline at end of file