Created
June 12, 2012 06:34
-
-
Save kazu-yamamoto/2915624 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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