Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cabal Test Suite with type detailed example

I'm searching for a cabal package using the detailed Test-Suite interface to learn how to structure the code.

like image 859
Zhen Avatar asked Nov 25 '11 09:11

Zhen


2 Answers

The cabal documentation contains examples for both the detailed-1.0 and exitcode-stdio-1.0 test interfaces. However, note that the detailed test interface isn't supported yet. Only the simpler exitcode-stdio-1.0 interface is currently supported.

From a recent mail thread on the cabal-devel list (dated September 5, 2011):

Ah, a rare case of premature documentation. That is, documentation for a feature that is due, but not released yet. [...] No released version supports the detailed interface yet. Just recently we think we've settled on the final interface and will hopefully get that implemented in the darcs version soon.

like image 136
hammar Avatar answered Oct 21 '22 21:10

hammar


Since I have been stumbling over this question quite a few times: With Cabal 1.20(1.18 ?), detailed-0.9 is supported, see for example https://github.com/michaxm/test-detailed-example. But since there has been quite some time witout it, the infrastructure around exitcode-stdio-1.0 (+ one of the supporting libs, e. g. hspec, hunit, ...) may still be superior.

See How to use detailed-0.9 in cabal testing as well.

Example of minimal .cabal contents for a detailed-0.9 test (using names of a default stack project) :

name:                test-detailed-example
version:             0.1.0.0
build-type:          Simple
cabal-version:       >=1.20

library
  hs-source-dirs:      src
  exposed-modules:     Lib
  build-depends:       base >= 4.7 && < 5
  default-language:    Haskell2010

test-suite test-detailed-example-test
  type:                detailed-0.9
  hs-source-dirs:      test
  test-module:         Spec
  build-depends:       base >= 4.7,
                       Cabal >= 1.20
  default-language:    Haskell2010
like image 37
axm Avatar answered Oct 21 '22 23:10

axm