Open samuel-gelineau-at-well-dot opened 3 months ago
Thanks for the detailed report ❤️
I think that with Cabal, running tests from a sub-directory with its own .cabal
file might affect how paths are resolved.
This could link error outputs directly to the source files in the sub-directory, potentially explaining the detailed error reporting when tests are run from $PROJECT_ROOT/my-package
.
However, I couldn’t find specific documentation confirming this exact behavior, so it might very well be possible to fix this inside hedgehog itself.
it might very well be possible to fix this inside hedgehog itself.
I am guessing that hedgehog records the relative path of the source code at compile time, and thus whether this relative path resolves to a file or not depends on the $PWD
. recording the absolute path instead of the relative path should fix the problem.
Sounds reasonable and pull requests welcome 💯 👍
recording the absolute path instead of the relative path should fix the problem.
I think this would require Template Haskell, I'm not aware of a way to achieve this with the HasCallStack
-machinery.
Maybe just open a Cabal issue instead. When cabal test
executes the test executable it could easily set the CWD to the package root. Better address it once at the root than requiring every test library to hack its way around it.
Agreed with @sol, if it's possible to fix this upstream it'll be better so that the whole community may benefit for this.
in multi-package projects, it is common for each package to be placed in a separate sub-directory. the quality of the output depends on whether the tests are run from the root of the project or from the sub-directory of the package which contains the tests:
vs the much better looking:
For easy reproducibility, here is the file structure I have used to produce the output above. The only thing which matters is that my
toy.cabal
file is in$PROJECT_ROOT/my-package
instead of$PROJECT_ROOT
.