リンクしたウェブサイトのコードはrunCommand
です。ストリームへのアクセスを提供する同等物はrunInteractiveCommand
です。その後、hGetContents
を使用してストリームから読み取ることができます。
-- | Run @echo [email protected] and tests whether the output is what we expect.
testOne :: IO Bool
testOne =
runInteractiveCommand "echo 10" >>= \(_stdin, stdout, _stderr, _proc) ->
hGetContents stdout >>= \out ->
return (out == "10\n")
その後、我々はすべての結果のブールとを取るために、結果の上にそれを実行するためにasync
パッケージから100同時に回、およびfmap (all id)
をreplicateConcurrently
を使用することができます。
-- | Run 'testOne' 100 times concurrently, return whether all tests succeeded.
testMany :: IO Bool
testMany =
all id <$> replicateConcurrently 100 testOne