Commit f842aecd authored by Iustin Pop's avatar Iustin Pop
Browse files

Simplify a bit more the test harness



We can build the test groups directly in the `testSuite' helper,
instead of doing it (much later) in the test harness.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 44be51aa
......@@ -81,10 +81,10 @@ testSuite :: String -> [Name] -> Q [Dec]
testSuite tsname tdef = do
let fullname = mkName $ "test" ++ mapSlashes tsname
tests <- mapM run tdef
sigtype <- [t| (String, [Test]) |]
sigtype <- [t| Test |]
body <- [| testGroup $(litE $ stringL tsname) $(return $ ListE tests) |]
return [ SigD fullname sigtype
, ValD (VarP fullname) (NormalB (TupE [LitE (StringL tsname),
ListE tests])) []
, ValD (VarP fullname) (NormalB body) []
]
-- | Builds an arbitrary value for a given constructor. This doesn't
......
......@@ -69,7 +69,7 @@ defOpts = TestOptions
}
-- | All our defined tests.
allTests :: [(String, [Test])]
allTests :: [Test]
allTests =
[ testBasicTypes
, testCommon
......@@ -104,5 +104,4 @@ main :: IO ()
main = do
ropts <- getArgs >>= interpretArgsOrExit
let opts = maybe defOpts (defOpts `mappend`) $ ropt_test_options ropts
tests = map (uncurry testGroup) allTests
defaultMainWithOpts tests (ropts { ropt_test_options = Just opts })
defaultMainWithOpts allTests (ropts { ropt_test_options = Just opts })
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