Use getLocalBuildInfoM not getTestEnv
Fixes #9725 using getLocalBuildInfoM similar to the way it is done in the following snippet;
https://github.com/haskell/cabal/blob/2acae632a0d625cd5b54aeb257fc83188344fa03/cabal-testsuite/PackageTests/ExtraCompilationArtifacts/test.hs#L14-L19
The previous getTestEnv method was expecting a path that didn't include the ABI hash suffix.
When the test runs it logs the library path (unchanged by this fix);
library-dirs:
/.../CopyHie/setup.cabal.dist/usr/lib/x86_64-linux-ghc-9.8.1-eb95/hie-local-0.1.0.0
Include the following checklist in your PR:
- [x] Patches conform to the coding conventions.
- [ ] Is this a PR that fixes CI? If so, it will need to be backported to older cabal release branches (ask maintainers for directions).
Thanks @philderbeast, but working around this issue in this particular test doesn't seem to be the right solution. Shouldn't getTestEnv and the functions it depends on be updated to properly account for the abi tag?
If we look at testLibInstallDir then it seems that this should already account for the ABI tag so it seems we should investigate why that produces the wrong result.
I can reproduce this, it seems the issue is when you build the tests with 9.8.1.
How testCompiler is set should really depend on the version of the Cabal library the test is using, this is the reason for the mismatch because the path is computed using Cabal-3.10 but the test itself uses Cabal-3.11. Will be improved by my other patch which allows you to run the testsuite against different CAbal library versions.
Thanks for taking a look @mpickering.
getLocalBuildInfoMusesgetTestEnvbut it looks likeTestEnvdoesn't have the data read fromPackageTests/CopyHie/setup.cabal.dist/work/dist/setup-config- in
testLibInstallDir,showCompileIdWithAbiis taking theNoAbiTagbranch because that's whatScriptEnv0.hshas dist-newstyle/build/x86_64-linux/ghc-9.8.1/cabal-testsuite-3/build/global-autogen/Test/Cabal/ScriptEnv0.hsis where thecompilerAbiTagis read from as a field ofCompiler, isn't it?
https://github.com/haskell/cabal/blob/2acae632a0d625cd5b54aeb257fc83188344fa03/cabal-testsuite/src/Test/Cabal/Prelude.hs#L99-L102
https://github.com/haskell/cabal/blob/2acae632a0d625cd5b54aeb257fc83188344fa03/cabal-testsuite/src/Test/Cabal/Monad.hs#L560-L568
I'm going to park this for now. Feel free to close it if you feel it is the wrong approach.
Let me take the liberty of turning it into a draft so that next time I do a sweep, I don't panic it's bitrotting.