tasty icon indicating copy to clipboard operation
tasty copied to clipboard

Simple TestReporter ingredient makes the testsuite hang

Open KristianBalaj opened this issue 2 years ago • 0 comments

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.

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

The Done case never happens in the getResultFromTVar and only the retry case is happening.

KristianBalaj avatar May 21 '22 17:05 KristianBalaj