Commit 174c1f5b authored by Mart Lubbers's avatar Mart Lubbers

add tests for System.Process

parent de9abe45
Pipeline #41933 passed with stage
in 2 minutes
......@@ -26,7 +26,7 @@ COCLLIBS:=\
-I $(COCLPATH)/main\
-I $(COCLPATH)/main/Unix
BINARIES:=checktest test commentstest gentest snappytest tartest
BINARIES:=systemprocesstest checktest test commentstest gentest snappytest tartest
RUN_BINARIES:=$(addprefix run_,$(BINARIES))
all: $(RUN_BINARIES)
......
module systemprocesstest
import StdEnv
import System.CommandLine
import System.Process
import Data.Error
import Data.Func
import Text
pty = runProcessPty "/bin/sh" ["-c", "sleep 1 && echo bork"] Nothing defaultPtyOptions
pio = runProcessIO "/bin/sh" ["-c", "sleep 1 && echo bork"] Nothing
test msg expected rpf pf world
# (Ok (handle,io),world) = pf world
# (Ok output,world) = rpf io.stdOut world
# (Ok out,world) = waitForProcess handle world
# (Ok _,world) = closeProcessIO io world
# f = if (expected <> trim output)
(setReturnCode 1 o snd o fclose (stderr <<< msg <<< "Expected: '" <<< expected <<< "', Got: '" <<< trim output <<< "'\n"))
id
= f world
Start world
= test "ptynb: " "" readPipeNonBlocking pty
$ test "pty b: " "bork" readPipeBlocking pio
$ test "pionb: " "" readPipeNonBlocking pio
$ test "pio b: " "bork" readPipeBlocking pio
$ world
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment