Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is Cabal's Distribution.TestSuite.Progress datatype supposed to be used?

Tags:

haskell

cabal

I have a simple TestInstance in a detailed-0.9 test suite:

tests :: IO [Test]
tests = return [Test testInstance]

testInstance :: TestInstance
testInstance =
  TestInstance
    { run = ioProgress,
      name = "test 1",
      tags = [],
      options = [],
      setOption = \_ _ -> Left ""
    }

ioProgress :: IO Progress
ioProgress = progress 3
  where
    progress :: Int -> IO Progress
    progress 0 = return (Finished (Fail "failed"))
    progress n = return (Progress ("n == " ++ show n) (progress (n - 1)))

I thought that maybe I would see some output like

n == 3
n == 2
n == 1

whilst the test runs but I never see these strings, even with --test-show-details=always and --test-show-details=streaming.

like image 949
ljbw Avatar asked Oct 13 '25 01:10

ljbw


1 Answers

The String in the Progress constructor doesn't appear to be used for anything. (I was able to build the Cabal package from source after replacing it with an Int, for example.)

The code that implements testing for detailed-0.9 is in Distribution.Simple.Test.LibV09, and it just keeps unwrapping Progress constructors (ignoring the String field) until it finds a Finished:

stubRunTests tests = do
  ...
      where
        finish (Finished result) =
          return
            TestLog
              { testName = name t
              , testOptionsReturned = defaultOptions t
              , testResult = result
             }
        finish (Progress _ next) = next >>= finish
  ...
like image 127
K. A. Buhr Avatar answered Oct 14 '25 18:10

K. A. Buhr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!