Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error while creating test suites: "cannot satisfy -package-id"

Tags:

haskell

cabal

I'm attempting to create a test suite for my project, HaskSplit in my .cabal configuration:

-- Initial HaskSplit.cabal generated by cabal init.  For further 
-- documentation, see http://haskell.org/cabal/users-guide/

name:                HaskSplit
version:             0.1.0.0
synopsis:            Haskell Implementation of Shamir's Secret Sharing Scheme
-- description:         
license:             MIT
license-file:        LICENSE
author:              
maintainer:          
-- copyright:           
category:            Security
build-type:          Simple
-- extra-source-files:  
cabal-version:       >=1.10

executable HaskSplit
  main-is:             Main.hs
  default-language:    Haskell2010
  -- other-modules:       
  other-extensions:    TemplateHaskell, NoImplicitPrelude, RankNTypes, OverloadedStrings
  build-depends:       base >=4.6 && <4.7,
                       resourcet >=1.1 && <1.2,
                       bytestring >=0.10 && <0.11,
                       conduit-extra >=1.1 && <1.2,
                       vector >=0.10 && <0.11,
                       conduit >=1.1 && <1.2,
                       conduit-combinators >=0.2 && <0.3,
                       mono-traversable >=0.5 && <0.6,
                       safe >=0.3 && <0.4,
                       transformers >=0.3 && <0.4,
                       filepath >= 1.3,
                       directory >=1.2,
                       Glob >= 0.7.4,
                       errors >= 1.4,
                       optparse-applicative >= 0.8
  hs-source-dirs:      src
  default-language:    Haskell2010
  ghc-options:         -Wall -fno-warn-orphans

test-suite tests
  type:                exitcode-stdio-1.0
  default-language:    Haskell2010
  hs-source-dirs:      tests
  main-is:             Test.hs
  ghc-options:         -Wall -fno-warn-orphans
  build-depends:       base == 4.*,
                       QuickCheck >=2.6 && <2.7,
                       test-framework-quickcheck2 >= 0.3.0.3,
                       HaskSplit

Looking at an example test-suite setup here, I noticed that they're specifying their own package as one of the build-depends module. Therefore I did the same, so that I can keep my build-depends list for my test-suite short.

However when I try cabal repl test:tests in commandline, I'm getting the following error:

<command line>: cannot satisfy -package-id HaskSplit-0.1.0.0-inplace

I'm not too sure what I'm missing here, can anyone help me out? Is it cyclic dependencies happening around here? Or do I need to create a library instance of my package for the build-depends to work?

Thanks!

like image 451
Jacob Wang Avatar asked May 22 '14 10:05

Jacob Wang


2 Answers

The build-depends section can only contain libraries, not modules. I suggest you add a library to your cabal file. The exposed-modules section of the library should list all of the modules that your test (or any other user of the library) might need to reference.

As an alternative to creating a library, you could simply add the modules you need to the other-modules part of the test-suite section. If you want to include a lot of modules, though, I think the library approach is nicer.

like image 151
mhwombat Avatar answered Sep 19 '22 12:09

mhwombat


After some more tweaking, here's what I got, for completeness sake:

-- Initial HaskSplit.cabal generated by cabal init.  For further 
-- documentation, see http://haskell.org/cabal/users-guide/

name:                HaskSplit
version:             0.1.0.0
synopsis:            Haskell Implementation of Shamir's Secret Sharing Scheme
-- description:         
license:             MIT
license-file:        LICENSE
author:              
maintainer:          
-- copyright:           
category:            Security
build-type:          Simple
-- extra-source-files:  
cabal-version:       >=1.10

executable HaskSplit
  main-is:             Main.hs
  default-language:    Haskell2010
  -- other-modules:       
  other-extensions:    RankNTypes
  build-depends:       base >=4.6 && <4.7,
                       resourcet >=1.1 && <1.2,
                       bytestring >=0.10 && <0.11,
                       conduit-extra >=1.1 && <1.2,
                       conduit >=1.1 && <1.2,
                       conduit-combinators >=0.2 && <0.3,
                       mono-traversable >=0.5 && <0.6,
                       safe >=0.3 && <0.4,
                       transformers >=0.3 && <0.4,
                       filepath >= 1.3,
                       directory >=1.2,
                       Glob >= 0.7.4,
                       errors >= 1.4,
                       optparse-applicative >= 0.8,
                       random == 1.*,
                       HaskSplit
  hs-source-dirs:      src/exe
  default-language:    Haskell2010
  ghc-options:         -Wall -fno-warn-orphans

library
  Exposed-modules:     HaskSplit.Algorithm,
                       HaskSplit.Util,
                       FiniteField.GF256,
                       FiniteField.PGF256
  default-language:    Haskell2010
  hs-source-dirs:      src/lib
  build-depends:       base >=4.6 && <4.7,
                       vector >=0.10 && <0.11,
                       random == 1.*

test-suite tests
  type:                exitcode-stdio-1.0
  default-language:    Haskell2010
  hs-source-dirs:      tests
  main-is:             Test.hs
  other-extensions:    TemplateHaskell
  ghc-options:         -Wall -fno-warn-orphans
  build-depends:       base == 4.*,
                       QuickCheck >=2.6 && <2.7,
                       test-framework-quickcheck2 >= 0.3.0.3,
                       HaskSplit
like image 26
Jacob Wang Avatar answered Sep 22 '22 12:09

Jacob Wang