Search code examples
haskellhspec

How to tell HSpec where to look for the source files to be tested


I'm new to Haskell and I wanted to add tests to my first project. I chose HSpec for this. My only spec file doesn't contain anything special so far. I just copied the example from the HSpec website and added import statements for my own modules to be tested. When I try to run it via runhaskell test/XSpec.hs it complains that it "could not find module X". How do I tell it about the load paths it should take a look into before complaining?


Solution

  • Adding -isrc helped, so the call looks like this:

    runhaskell -isrc test/Spec.hs
    

    Additionally, it is important to note, that a module's file name should match the module name, including the case. I.e. the filename of the module Foo should be Foo.hs.