on master help sign in
Allow selective running of tests

--HG-- extra : convert_revision : a3058df9a73e96880ee7bfd847fb2fc1b2f2b548

commitf2565d2906d4a131c0a683286d931caf33c60db0 authorBryan O'Sullivan <bos@serpentine.com> dateSun 8 Mar 2009, 01:13 (18 years ago) parentd91636c
1 file changed+7−5
tests/Properties.hs+7−5
tests/Properties.hs+7−5
@@ -324,11 +324,13 @@ main = run tests =<< getArgs
324324
325325run :: [(String, Int -> IO (Bool,Int))] -> [String] -> IO ()
326326run tests args = do
327− let n = case args of
328− [s] -> read s
329− [] -> 100
330− _ -> error "too many arguments"
331− (results,passed) <- unzip <$> mapM (\(s,a) -> printf "%-40s: " s >> a n) tests
327+ let (n,names) = case args of
328+ (k:ts) -> (read k,ts)
329+ [] -> (100,[])
330+ (results,passed) <- fmap unzip . forM tests $ \(s,a) ->
331+ if null names || s `elem` names
332+ then printf "%-40s: " s >> a n
333+ else return (True,0)
332334 printf "Passed %d tests!\n" (sum passed)
333335 when (not . and $ results) $
334336 fail "Not all tests passed!"