You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cabal should pass filenames, not module names, to GHC #4350
So here's the problem: suppose you want to have the source files for your unit tests next to the source files for your library. e.g. Foo.Bar is the library module, and Foo.Bar.Tests is a test suite source file. If you have a lot of source files in a deep hierarchy, this layout makes sense, because you don't have to duplicate the directory hierarchy.
You've already listed all the modules in the .cabal file, and the sets of modules for the library are disjoint from those for the test suite. Cabal knows exactly which source files correspond to each module.
But, when we invoke GHC, we do it like this:
ghc -i. Foo.Bar.Tests -package foo
and GHC finds Foo.Bar on the search path instead of in the compiled foo package. Furthermore, it complains that you haven't added Foo.Bar to the other-modules field in the test suite. But there's no need for this, we could instead do
ghc -i Foo/Bar/Tests.hs -package foo
and everything would be fine. It would be less fragile too: if you forgot to list some modules in other-modules, GHC won't find them.
One concern is that this is a BC-breaking change; for example, cabal-install used to rely on the fact that you would rebuild the modules picked up from the source dirs to run the library with assertions enabled, even if the "real" library hadn't been built with assertions. Maybe we can figure out some feature switch to toggle this behavior (cabal-version? Something else?)
Activity
ezyang commentedon Feb 21, 2017
It is a bit funny because we recently merged http://ghc.haskell.org/trac/ghc/ticket/13129 to help detect when a module isn't listed in
other-modules, but it's definitely true that clearing the import list and then explicitly saying where all the files are would work too. This would require Cabal to know how to search the include directories for the source files, but it already knows that.One concern is that this is a BC-breaking change; for example, cabal-install used to rely on the fact that you would rebuild the modules picked up from the source dirs to run the library with assertions enabled, even if the "real" library hadn't been built with assertions. Maybe we can figure out some feature switch to toggle this behavior (
cabal-version? Something else?)Move tests to tests and exes to exe