Open RyanGlScott opened 1 year ago
I spent a couple of hours looking at this. To me it looks like the bug is in the addInternalBuildTools
function, which was not touched by #7688.
That function is taking the name of a executable component (toolName
) and declaring its location is buildDir lbi
which is the build directory of the component which needs the tool, i.e. the test component in this case.
You can see in the error above that cabal is looking for codegen-same-package-exe
in the build directory of the test component dist-newstyle/build/x86_64-linux/ghc-9.2.4/code-generators-issue-0.1/t/code-generators-issue-test/build
.
I tried few things but I cannot find a way to obtain the build directory of the tool exe component from generateCode
.
But that function has not been touched for years ... :thinking:
AH! That's correct, that function does not work with per-component builds. Run cabal test --disable-per-component
and it works (because now everything is in the same builddir).
Should we try to fix addInternalBuildTools
to handle per-component builds?
@gbaz
Should we try to fix
addInternalBuildTools
to handle per-component builds?
That would be awesome. I am not very familiar with that part, but if you do a bit of a brain dump (just here perhaps?) I can take note and do a bit of an investigation.
I don't have any more knowledge than you to brain-dump sadly. I'd add just that generateCode
is about generating the modules for the test suite. Its not about generating the tool exe component, which it presumes already exists.
I think maybe getAllInternalToolDependencies
is where we need to give more attention?
But it may be that addInternalBuildTools
in general is the right place to look -- perhaps it should make use of targetBuildDepends
-- not sure?
I recently attempted to make use of the
code-generators
feature that debuted inCabal-3.8
. Unfortunately, I ran into an apparent limitation in which the code generator executable cannot be defined in the same package as the test suite that makes use of it.To Reproduce
By default, this repo makes use of a code generator defined in a separate package, which is named
codegen-different-package
. To observe that this works as expected, runcabal v2-test
:To observe the bug, patch
code-generators-issue.cabal
to make use of a code generator defined in the same package (codegen-same-package
):Starting from a clean slate:
This time, if you run
cabal v2-test
, it fails:Expected behavior I would expect
cabal v2-test
to succeed regardless of which form of code generator is used.System information