cabal icon indicating copy to clipboard operation
cabal copied to clipboard

Use getLocalBuildInfoM not getTestEnv

Open philderbeast opened this issue 6 months ago • 6 comments

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).

philderbeast avatar Feb 18 '24 21:02 philderbeast

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?

alt-romes avatar Feb 19 '24 08:02 alt-romes

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.

mpickering avatar Feb 19 '24 11:02 mpickering

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.

mpickering avatar Feb 19 '24 13:02 mpickering

Thanks for taking a look @mpickering.

  • getLocalBuildInfoM uses getTestEnv but it looks like TestEnv doesn't have the data read from PackageTests/CopyHie/setup.cabal.dist/work/dist/setup-config
  • in testLibInstallDir, showCompileIdWithAbi is taking the NoAbiTag branch because that's what ScriptEnv0.hs has
  • dist-newstyle/build/x86_64-linux/ghc-9.8.1/cabal-testsuite-3/build/global-autogen/Test/Cabal/ScriptEnv0.hs is where the compilerAbiTag is read from as a field of Compiler, 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

philderbeast avatar Feb 19 '24 13:02 philderbeast

I'm going to park this for now. Feel free to close it if you feel it is the wrong approach.

philderbeast avatar Feb 19 '24 13:02 philderbeast

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.

Mikolaj avatar May 01 '24 10:05 Mikolaj