[Haskell-cafe] Recipes for organizing HUnit tests

2007-10-28 Thread Mushfeq Khan
I'm new to Haskell and am trying to find a good way to organize my HUnit
tests. Having used some of the other XUnit frameworks, I tended towards
trying to organize them all in a parallel test folder structure, but this
seems to be a bad fit for Haskell, since the test modules cannot see the
source modules unless they are either in the same folder or a folder above
it. That's without modifying the module search path when I run the tests,
which I would like to avoid.

So I tried looking for examples of HUnit-tested source code out there and
found that the cryptographic library Crypto has some unit tests. However,
Crypto seems to place all its test code at the top of the folder hierarchy
for the reasons I mentioned above. This turns out to be fine for Crypto
since there are few tests. But I can foresee the tests for my project
multiplying to the point where it would become very unsightly to put them
all in the top-level folder.

My questions to you are: how do you organize your HUnit/QuickCheck tests? Is
there a convention? Is there some library out there that embodies this
convention?

Mushfeq.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Recipes for organizing HUnit tests

2007-10-28 Thread Isaac Dupree

Mushfeq Khan wrote:

I'm new to Haskell and am trying to find a good way to organize my HUnit
tests. Having used some of the other XUnit frameworks, I tended towards
trying to organize them all in a parallel test folder structure, but this
seems to be a bad fit for Haskell, since the test modules cannot see the
source modules unless they are either in the same folder or a folder above
it. That's without modifying the module search path when I run the tests,
which I would like to avoid.


Well, it's certainly possible to use parallel directory structures -- 
this is one way to do it:


Xyzzy/Gizmo.hs:
module Xyzzy.Gizmo where
...

Test/Gizmo.hs:
module Test.Gizmo where
import Xyzzy.Gizmo
main = ...

ghc --make -main-is Test.Gizmo.main Test/Gizmo.hs

Or without -main-is,

Tests.hs:
module Main where
import Test.Gizmo
import Test.Bar
...
main = testGizmo, testBar ...

ghc --make Tests


Isaac
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Recipes for organizing HUnit tests

2007-10-28 Thread Berlin Brown

Isaac Dupree wrote:

Mushfeq Khan wrote:

I'm new to Haskell and am trying to find a good way to organize my HUnit
tests. Having used some of the other XUnit frameworks, I tended towards
trying to organize them all in a parallel test folder structure, 
but this

seems to be a bad fit for Haskell, since the test modules cannot see the
source modules unless they are either in the same folder or a folder 
above
it. That's without modifying the module search path when I run the 
tests,

which I would like to avoid.


Well, it's certainly possible to use parallel directory structures -- 
this is one way to do it:


Xyzzy/Gizmo.hs:
module Xyzzy.Gizmo where
...

Test/Gizmo.hs:
module Test.Gizmo where
import Xyzzy.Gizmo
main = ...

ghc --make -main-is Test.Gizmo.main Test/Gizmo.hs

Or without -main-is,

Tests.hs:
module Main where
import Test.Gizmo
import Test.Bar
...
main = testGizmo, testBar ...

ghc --make Tests


Isaac
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
I asked the same question a while back. Yea, you want the parallel 
directory structure and you use the -iMyPack -iHUnit option when 
compiling you haskell code.


You can kind of see what I did with this project.  I have HUnit source 
in one module and Tests in a different module, different directory.


http://octanemech.googlecode.com/svn/trunk/octanemech/src/
http://octanemech.googlecode.com/svn/trunk/octanemech/src/Makefile


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe