On 18/07/10 20:55, Rogan Creswick wrote: > On Sun, Jul 18, 2010 at 12:23 PM, Magnus Therning <[email protected]> wrote: >> In my Cabal file I have defined a flag that controls whether tests are >> built or not. Now I'd like to hook it up a bit more so that './Setup.hs >> test' actually runs the tests. > > This will allow you to issue 'cabal test' to run the test suite, but > it may introduce other issues. I suspect that this won't work well > with dependencies or language extensions defined in the cabal file -- > I'm really not sure, as I haven't actually done this in "real" code. > I just wanted to see if it would work a few months back.
Yeah, that's why I want to set it up. However, I don't want the setup
you suggest.
In my Cabal file I have a flag which controls whether the test
executable gets built or not:
Executable utest
Main-Is : Main.hs
Hs-Source-Dirs : test_src src
Ghc-Options : -threaded
if flag(Test)
Build-Depends : HUnit, network
Buildable : True
Ghc-Options : -fhpc
else
Buildable : False
The main reason for this is that the test executable depends on some
packages that would never be used in the main part of the package. I
also do
not want my Setup.hs to depend on those packages.
In my Setup.hs I then define the following test hook:
runTestsBuild a b pd lbi = let
doWithExe e _ = let
_exe = "./dist/build/" ++ (exeName e) ++ "/" ++
(exeName e)
_runTest = do
putStrLn $ "** " ++ (exeName e) ++ ":"
ig $ system _exe
in
when (exeName e `elem` ["utest"]) _runTest
in do
(runTests simpleUserHooks) a b pd lbi
withExeLBI pd lbi doWithExe
And this is where the issue I *asked* about comes in. The building of the
test executable is controlled by the flag Test, but the flag doesn't seem to
be available in the test hook so instead I have to rely on the name of the
executable.
/M
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
