[Nix-dev] Building Haskell Package with Tests and Data Files.
Peter Simons
simons at cryp.to
Tue Dec 22 21:32:05 CET 2015
Hi Bas,
> I have a Haskell library that contains a test-suite. The test
> requires a data file of the package. When building the package with
> nix-build the test is run but fails because the path to the data file
> is wrong.
"cabal test" executes test suites with the current working directory set
to the top-level directory of your source code, i.e. the same place
where the "myLib.cabal" file is. Therefore, your test code can refer to
the data file reliably as "data/Lenna.png".
If you ever want to release that project on Hackage, make sure to
add an attribute like
extra-source-files: data/*
in your Cabal file, otherwise those data files will not be included in
the generated release tarball. If you're fine with those files being
*installed*, then the attribute
data-files: data/*
is preferable, of course.
Best regards,
Peter
More information about the nix-dev
mailing list