Skip to content

Commit

Permalink
Use runnerPackageDbStack if --with-ghc is the same as cabal-testsuite…
Browse files Browse the repository at this point in the history
… is compiled with

This makes e.g. LibV09 test work properly
  • Loading branch information
phadej committed Dec 12, 2019
1 parent d036ca9 commit 6a2a5aa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
13 changes: 12 additions & 1 deletion cabal-testsuite/Test/Cabal/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,24 @@ runTestM mode m = withSystemTempDirectory "cabal-testsuite" $ \tmp_dir -> do
-- them up we must configure them
program_db <- configureAllKnownPrograms verbosity program_db3

let ghcAndRunnedGhcAreTheSame :: Bool
ghcAndRunnedGhcAreTheSame = fromMaybe False $ do
ghc_program <- lookupProgram ghcProgram program_db
runner_ghc_program <- lookupProgram ghcProgram (runnerProgramDb senv)
return $ programPath ghc_program == programPath runner_ghc_program

let db_stack =
case argGhcPath (testCommonArgs args) of
Nothing -> runnerPackageDbStack senv -- NB: canonicalized
-- Can't use the build package db stack since they
-- are all for the wrong versions! TODO: Make
-- this configurable
Just _ -> [GlobalPackageDB]
--
-- Oleg: if runner ghc and provided ghc are the same,
-- use runnerPackageDbStack. See 'hasCabalForGhc' check.
Just _
| ghcAndRunnedGhcAreTheSame -> runnerPackageDbStack senv
| otherwise -> [GlobalPackageDB]
env = TestEnv {
testSourceDir = script_dir,
testTmpDir = tmp_dir,
Expand Down
5 changes: 5 additions & 0 deletions cabal-testsuite/Test/Cabal/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -830,9 +830,14 @@ hasCabalForGhc = do
(testVerbosity env)
ghcProgram
(runnerProgramDb (testScriptEnv env))

-- TODO: I guess, to be more robust what we should check for
-- specifically is that the Cabal library we want to use
-- will be picked up by the package db stack of ghc-program

-- liftIO $ putStrLn $ "ghc_program: " ++ show ghc_program
-- liftIO $ putStrLn $ "runner_ghc_program: " ++ show runner_ghc_program

return (programPath ghc_program == programPath runner_ghc_program)

-- | If you want to use a Custom setup with new-build, it needs to
Expand Down

0 comments on commit 6a2a5aa

Please sign in to comment.