samedi 25 juillet 2020

Import a test utils module from the test package with cabal

I have the following project structure:

project
+ src
|___ Func.hs
+ test
|___ ASpec.hs
|___ BSpec.hs
|___ Spec.hs
|___ Utils.hs

I would like to import Utils module from ASpec and BSpec, sadly by default it seems to not be possible. I have also tried to create a second library section in my cabal file, but I cannot depend on it. How should I express that in my cabal file?

name:                project
version:             0.1.0.0
synopsis:            something
-- description:
homepage:            https://github.com/xx/project#readme
license:             BSD2
license-file:        LICENSE
author:              me
maintainer:          me@domail.tld
copyright:           2020 Me
category:            Text
build-type:          Simple
extra-source-files:  README.md
cabal-version:       >=1.10

library
  hs-source-dirs:      src
  ghc-options:         -Werror -fwarn-missing-methods
  exposed-modules:     Func
  build-depends:       base >= 4.12 && < 5
  default-language:    Haskell2010

test-suite project-test
  type:                exitcode-stdio-1.0
  hs-source-dirs:      test
  other-modules:       ASpec
                     , BSpec
  main-is:             Spec.hs
  build-depends:       base
                     , project
                     , hspec
  ghc-options:         -threaded -rtsopts -with-rtsopts=-N
  default-language:    Haskell2010

source-repository head
  type:     git
  location: https://github.com/xx/project

Aucun commentaire:

Enregistrer un commentaire