Skip to content

Use getLocalBuildInfoM not getTestEnv #9726

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

philderbeast
Copy link
Collaborator

Fixes #9725 using getLocalBuildInfoM similar to the way it is done in the following snippet;

lbi <- getLocalBuildInfoM
let installedLibPath = libdir $ absoluteInstallDirs (localPkgDescr lbi) lbi NoCopyDest
shouldExist $ installedLibPath </> "extra-compilation-artifacts" </> "ghc-plugin-X" </> "data-dir" </> "content-A.txt"
shouldExist $ installedLibPath </> "extra-compilation-artifacts" </> "ghc-plugin-X" </> "data-dir" </> "content-B.txt"
shouldExist $ installedLibPath </> "extra-compilation-artifacts" </> "ghc-plugin-Y" </> "content-Y.txt"

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:

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

@alt-romes
Copy link
Collaborator

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?

@mpickering
Copy link
Collaborator

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
Copy link
Collaborator

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.

@philderbeast
Copy link
Collaborator Author

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?

getLocalBuildInfoM :: TestM LocalBuildInfo
getLocalBuildInfoM = do
env <- getTestEnv
liftIO $ getPersistBuildConfig (testDistDir env)

-- | The absolute path where library installs go.
testLibInstallDir :: TestEnv -> FilePath
testLibInstallDir env = libDir </> compilerDir
where
platform@(Platform _ os) = testPlatform env
libDir = case os of
Windows -> testPrefixDir env
_ -> testPrefixDir env </> "lib"
compilerDir = prettyShow platform ++ "-" ++ showCompilerIdWithAbi (testCompiler env)

@philderbeast
Copy link
Collaborator Author

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

@Mikolaj
Copy link
Member

Mikolaj commented May 1, 2024

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 Mikolaj marked this pull request as draft May 1, 2024 10:29
@philderbeast philderbeast force-pushed the test/ghc-abi-hash-expectation-9725 branch from 99498be to ee612a7 Compare April 19, 2025 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Copy .hie test fails with ghc-9.8.1
5 participants