test-framework icon indicating copy to clipboard operation
test-framework copied to clipboard

print something, even before the test result is known

Open dmwit opened this issue 10 years ago • 1 comments

For long-running tests, it is convenient to learn which test is running even before one knows any results of the test. The console runner does not print anything until the full result is known. The following code demonstrates this:

{-# LANGUAGE MultiParamTypeClasses #-}

import Control.Concurrent
import Control.Monad
import Data.Typeable
import System.IO.Unsafe
import Test.Framework.Runners.Console
import Test.Framework.Providers.API

instance TestResultlike () Bool where testSucceeded = id
instance Testlike       () Bool (IO a) where
  runTest _ act = do
    v <- unsafeInterleaveIO act
    return (Improving () (v `seq` Finished True), return ())
  testTypeName _ = "IO action"

main = defaultMain [Test "infinity" (forever (threadDelay 1000000) >> return ())]

When I run this program, I would like to see at least:

infinity:

but instead see no output.

dmwit avatar Jan 22 '15 03:01 dmwit

Implementing this will require some cleverness. The test runner appears to run tests concurrently, so to do this well I think you'd want either an alternate runner that separately prints when a test has started running and when it is finished (along with the outcome) or some clever console code to Show which tests are running and then dance the cursor around to fill in the outcome.

glguy avatar Sep 09 '15 05:09 glguy