1
0
mirror of https://github.com/janet-lang/janet synced 2025-12-01 14:28:05 +00:00

Fix subprocess spawning on windows.

Also fix (:read stream :all)
This commit is contained in:
Calvin Rose
2021-01-11 11:10:23 -06:00
parent 4df1ac5b23
commit f0dbc2e404
3 changed files with 36 additions and 13 deletions

View File

@@ -83,9 +83,16 @@
(assert-error "bad arity to ev/call" (ev/call inc 1 2 3))
(assert (os/execute [(dyn :executable) "-e" `(+ 1 2 3)`] :xp) "os/execute self")
# Subprocess
(let [p (os/spawn [(dyn :executable) "-e" `(file/read stdin :line)`] :px {:in :pipe})]
(:write (p :in) "hello!")
(assert-no-error "pipe stdin to process" (os/proc-wait p)))
(let [p (os/spawn [(dyn :executable) "-e" `(print "hello")`] :p {:out :pipe})]
(assert (deep= @"hello\n" (:read (p :out) :all)) "capture stdout from os/spawn")
(os/proc-wait p))
(os/proc-wait p)
(def x (:read (p :out) 1024))
(assert (deep= "hello" (string/trim x)) "capture stdout from os/spawn"))
(end-suite)