-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtasty-auto.hs
29 lines (27 loc) · 1.2 KB
/
tasty-auto.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import Control.Monad (when)
import Data.List (foldl')
import System.Console.GetOpt (getOpt, usageInfo, ArgDescr(..), ArgOrder(..), OptDescr(..))
import System.Environment (getArgs)
import System.Exit (exitFailure)
import System.IO (hPutStrLn, stderr)
import Test.Tasty.Auto
options :: [OptDescr ((String, [String], Bool) -> (String, [String], Bool))]
options =
[ Option [] ["module"] (ReqArg (\x (_, b, c) -> (x, b, c)) "MODULE") "Qualified module name"
, Option [] ["ingredient"] (ReqArg (\x (a, b, c) -> (a, b ++ [x], c)) "INGREDIENT") "Qualified ingredient name"
, Option [] ["debug"] (NoArg (\ (a, b, _) -> (a, b, True))) "Debug output"
]
main :: IO ()
main = do
args <- getArgs
case args of
src : _ : dst : optargs
| (opts, [], []) <- getOpt Permute options optargs -> do
tests <- findTests src
let output = showTestDriver modname ingredients src tests ""
(modname, ingredients, debug) = foldl' (flip id) ("Main", [], False) opts
when debug $ hPutStrLn stderr output
writeFile dst output
_ -> do
hPutStrLn stderr $ usageInfo "Usage: tasty-auto src _ dst [OPTION...]" options
exitFailure