Closed KristianBalaj closed 4 months ago
FWIW it does not run forever for me, but rather throws Exception: AsyncCancelled
.
#!/usr/bin/env cabal
{- cabal:
build-depends: tasty, tasty-hunit, base, stm
-}
module Main where
import Control.Exception
import Control.Monad
import Test.Tasty
import Test.Tasty.Runners
import Test.Tasty.HUnit
import Control.Concurrent.STM
main :: IO ()
main = do
defaultMainWithIngredients [myReporter] $
testGroup
"my suite"
[ testCase "" $ assertBool "" True
]
myReporter :: Ingredient
myReporter = TestReporter [] $
\opts tree -> Just $ \smap -> do
return $ \time -> do
foldM (\acc a -> fmap (acc &&) (getResultFromTVar a >>= processResult)) True smap
processResult :: Result -> IO Bool
processResult res = putStrLn (resultDescription res) >> pure True
getResultFromTVar :: TVar Status -> IO Result
getResultFromTVar var =
atomically $ do
status <- readTVar var
case status of
Done r -> return r
_ -> retry
It's already quite old, maybe I've used some broken tasty
version. I believe this is no longer relevant. Closing...
The following code runs forever even if it should not according to the documentation since the tasty runs the tests in case of
TestReporter
. It just wants to print resultDescription of every test.The
Done
case never happens in thegetResultFromTVar
and only the retry case is happening.