-incIORef :: IORef Int -> IO ()
-incIORef ir = atomicModifyIORef ir (\x -> (x + 1, ()))
-
--- | Wrapper over a test runner with error counting.
-wrapTest :: IORef Int
- -> (Args -> IO Result, String)
- -> Args
- -> IO (Result, Char, String)
-wrapTest ir (test, desc) opts = do
- r <- test opts
- c <- case r of
- Success {} -> return '.'
- GaveUp {} -> return '?'
- Failure {} -> incIORef ir >> return '#'
- NoExpectedFailure {} -> incIORef ir >> return '*'
- return (r, c, desc)
-
-runTests :: String
- -> Args
- -> [Args -> IO (Result, Char, String)]
- -> Int
- -> IO [(Result, String)]
-
-runTests name opts tests max_count = do
- _ <- printf "%25s : " name
- hFlush stdout
- results <- mapM (\t -> do
- (r, c, desc) <- t opts
- putChar c
- hFlush stdout
- return (r, desc)
- ) tests
- let alldone = sum . map (numTests . fst) $ results
- _ <- printf "%*s(%d)\n" (max_count - length tests + 1) " " alldone
- mapM_ (\(r, desc) ->
- case r of
- Failure { output = o, usedSeed = u, usedSize = size } ->
- printf "Test %s failed (seed was %s, test size %d): %s\n"
- desc (show u) size o
- GaveUp { numTests = passed } ->
- printf "Test %s incomplete: gave up with only %d\
- \ passes after discarding %d tests\n"
- desc passed (maxDiscard opts)
- _ -> return ()
- ) results
- return results
-
-allTests :: [(Args, (String, [(Args -> IO Result, String)]))]