Skip to content

Instantly share code, notes, and snippets.

@kazu-yamamoto
Created June 12, 2012 06:34
Show Gist options
  • Save kazu-yamamoto/2915624 to your computer and use it in GitHub Desktop.
Save kazu-yamamoto/2915624 to your computer and use it in GitHub Desktop.
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
module Spec (main) where
import Test.HUnit
import System.Process
import System.IO
subprocess = concat $
[ "module Main where\n"
, "import System.IO\n"
, "main = do\n"
, " hPutStr stderr \"foo\"\n"
, " hFlush stderr\n"
, " hPutStrLn stdout \"bar\"\n"
, " hFlush stdout\n"
]
main = runTestTT $ TestCase $ do
(Just hin, Just hout, Nothing, _) <-
createProcess $ (shell "runhaskell 2>&1") {
std_in = CreatePipe
, std_out = CreatePipe
, std_err = Inherit
}
hPutStrLn hin subprocess
hClose hin
line <- hGetLine hout
line @?= "foobar"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment