Skip to content

Instantly share code, notes, and snippets.

@wjlroe
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wjlroe/6262c5c773be7b82cbaf to your computer and use it in GitHub Desktop.
Save wjlroe/6262c5c773be7b82cbaf to your computer and use it in GitHub Desktop.
Problem using cabal test, detailed and Test.Framework

To run this:

  • cabal sandbox init
  • cabal install --only-dependencies --enable-tests
  • cabal test

Which results in:

Building problem-0.0.0.1...
Preprocessing library problem-0.0.0.1...
In-place registering problem-0.0.0.1...
Preprocessing test suite 'test' for problem-0.0.0.1...
In-place registering test-0.0.0.1...
[1 of 1] Compiling Main             ( dist/build/testStub/testStub-tmp/testStub.hs, dist/build/testStub/testStub-tmp/Main.o )

dist/build/testStub/testStub-tmp/testStub.hs:5:17:
    Couldn't match expected type ‘IO [Distribution.TestSuite.Test]’
                with actual type ‘[test-framework-0.8.0.3:Test.Framework.Core.Test]’
    In the first argument of ‘stubMain’, namely ‘tests’
    In the expression: stubMain tests

I don't understand:

  • Why does Cabal complain when I use detailed-1.0 as the docs stipulate? What's up with that?
  • Is this supposed to work? All the examples on the web are really old, using exitcode rather than detailed for some reason.
  • How can I make Test.Framework tests work with what detailed stubMain expects?
main :: IO ()
main = do
putStrLn "I have no idea what I'm doing"
name: problem
version: 0.0.0.1
build-type: Simple
cabal-version: >=1.9.2
executable problem
main-is: Main.hs
build-depends: base
Test-Suite test
type: detailed-0.9
test-module: Problems
build-depends: base
, Cabal >= 1.9.2
, test-framework
, test-framework-quickcheck2
{-# LANGUAGE FlexibleInstances #-}
module Problems where
import Test.Framework as TF (defaultMain, testGroup, Test)
import Test.Framework.Providers.QuickCheck2 (testProperty)
prop_reverseReverse :: [Char] -> Bool
prop_reverseReverse s = (reverse . reverse) s == s
tests = [
testGroup "random shit" [
testProperty "prop_reverseReverse" prop_reverseReverse
]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment