Skip to content
Snippets Groups Projects
Commit 3f99cc0c authored by barmston's avatar barmston
Browse files

cabal-install tests use locally built cabal

When running the cabal-install tests, we want to run against the locally built
cabal executable, not any other cabal executable which may be installed.

If we are 1) following the advice of building cabal with `cabal build` (as
opposed to installing it into a sandbox with `cabal install`) and 2) not using
a non-default build directory, the locally built cabal will be located at
`dist/build/cabal/cabal`.

By adding the directory `dist/build/cabal` to the program search path we will
pick up any cabal executable there in preference to any other on the $PATH.

For most users, I expect that this will remove any surprises with an
unexpected cabal executable being selected for running the tests. It will be
sufficient to allow the tests to run on Travis.

For users who have been installing cabal into a sandbox, this change could
result in an older cabal executable being selected. It's not clear to me how
to solve this issue or whether anyone will experience this.
parent 4b364b93
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,10 @@ module Main
-- Modules from Cabal.
import Distribution.Simple.Program.Builtin (ghcPkgProgram)
import Distribution.Simple.Program.Db (defaultProgramDb, requireProgram)
import Distribution.Simple.Program.Db
(defaultProgramDb, requireProgram, setProgramSearchPath)
import Distribution.Simple.Program.Find
(ProgramSearchPathEntry(ProgramSearchPathDir), defaultProgramSearchPath)
import Distribution.Simple.Program.Types
( Program(..), simpleProgram, programPath)
import Distribution.Simple.Utils ( findProgramVersion )
......@@ -16,7 +19,8 @@ import Distribution.Verbosity (normal)
-- Third party modules.
import qualified Control.Exception.Extensible as E
import System.Directory (getCurrentDirectory, setCurrentDirectory)
import System.Directory
(canonicalizePath, getCurrentDirectory, setCurrentDirectory)
import Test.Framework (Test, defaultMain, testGroup)
-- Modules containing the tests.
......@@ -38,10 +42,14 @@ cabalProgram = (simpleProgram "cabal") {
main :: IO ()
main = do
(cabal, _) <- requireProgram normal cabalProgram defaultProgramDb
(ghcPkg, _) <- requireProgram normal ghcPkgProgram defaultProgramDb
buildDir <- canonicalizePath "dist/build/cabal"
let programSearchPath = ProgramSearchPathDir buildDir : defaultProgramSearchPath
(cabal, _) <- requireProgram normal cabalProgram
(setProgramSearchPath programSearchPath defaultProgramDb)
let cabalPath = programPath cabal
ghcPkgPath = programPath ghcPkg
(ghcPkg, _) <- requireProgram normal ghcPkgProgram defaultProgramDb
let ghcPkgPath = programPath ghcPkg
putStrLn $ "Using cabal: " ++ cabalPath
putStrLn $ "Using ghc-pkg: " ++ ghcPkgPath
cwd <- getCurrentDirectory
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment