[Haskell-cafe] how to write cabal package file for executable with unit tests?

Roman Cheplyaka roma at ro-che.info
Mon Feb 17 07:23:51 UTC 2014


Can you upload your code somewhere (e.g. github)? It would be much
easier for us to troubleshoot.

But please don't attach archives to mailing list messages.

* Richard Cobbe <cobbe at ccs.neu.edu> [2014-02-16 20:26:18-0500]
> On Mon, Feb 17, 2014 at 12:52:41AM +0200, Roman Cheplyaka wrote:
> > If you don't want a separate library, use the second Erik's suggestion
> > from that thread.
> 
> I tried that, and I seem to still be missing something.
> 
> With
> 
>     Test-Suite sample-tests
>       main-is: RunTests.hs
>       hs-source-dirs: test-src, src
>       other-modules: Ast, Parser, Scanner
>       type: exitcode-stdio-1.0
>       default-language: Haskell2010
>       build-depends: base, array, containers, HUnit
> 
> then "cabal configure --enable-tests && cabal build" results in the
> following error:
> 
>     test-src/RunTests.hs:8:8:
>         Could not find module `Parser'
>         It is a member of the hidden package `ghc-7.6.3'.
>         Perhaps you need to add `ghc' to the build-depends in your .cabal file.
>         Use -v to see a list of the files searched for.
> 
> If I remove "src" from the hs-source-dirs line, then cabal complains that
> it can't find source for Ast.
> 
> If I put "src" back and remove the other-modules line, I get the same
> "Could not find module 'Parser'" error message from above.
> 
>                                  * * * * *
> 
> These seem to be pretty basic questions to me, but they also don't seem to
> be in the Cabal manual anywhere.  Is there somewhere else I should be
> looking?
> 
> Richard
> 
> > * Richard Cobbe <cobbe at ccs.neu.edu> [2014-02-16 17:15:25-0500]
> > > What's the preferred way to write a cabal configuration file for a package
> > > that contains an executable and a test suite?  The only thing I've found
> > > that seems to work is to put a thin wrapper Main.hs into the executable,
> > > put all of the actual code into the library, and then have the test-suite
> > > include the library in its build-depends list.
> > >
> > > This works, but I find it mildly annoying that I have to separate the code
> > > out in this fashion -- especially since the unit tests require me to expose
> > > modules in my library that aren't really part of the library's public
> > > interface.
> 
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140217/583e1064/attachment.sig>


More information about the Haskell-Cafe mailing list