Skip to content

Fail more gracefully when tests can't be run #2844

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

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cabal/Distribution/Simple/Program/Find.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import Distribution.Simple.Utils
import Distribution.System
( OS(..), buildOS )
import System.Directory
( findExecutable )
( canonicalizePath, findExecutable )
import Distribution.Compat.Environment
( getEnvironment )
import System.FilePath
Expand Down Expand Up @@ -109,7 +109,7 @@ findProgramOnSearchPath verbosity searchpath prog = do
findFirstExe (f:fs) = do
isExe <- doesExecutableExist f
if isExe
then return (Just f)
then Just `fmap` canonicalizePath f
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is needed, this function already returns an absolute path.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It only returns absolute paths if all of the ProgramSearchPathDirs are absolute. That's the whole point. You'll notice my change is the only call to canonicalizePath in the function.

else findFirstExe fs

-- | Interpret a 'ProgramSearchPath' to construct a new @$PATH@ env var.
Expand Down
10 changes: 6 additions & 4 deletions cabal-install/tests/IntegrationTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Distribution.Simple.Program.Builtin (ghcPkgProgram)
import Distribution.Simple.Program.Db
(defaultProgramDb, requireProgram, setProgramSearchPath)
import Distribution.Simple.Program.Find
(ProgramSearchPathEntry(ProgramSearchPathDir), defaultProgramSearchPath)
(ProgramSearchPathEntry(ProgramSearchPathDir))
import Distribution.Simple.Program.Types
( Program(..), simpleProgram, programPath)
import Distribution.Simple.Setup ( Flag(..) )
Expand Down Expand Up @@ -256,9 +256,11 @@ main :: IO ()
main = do
-- Find executables and build directories, etc.
distPref <- findDistPrefOrDefault NoFlag
buildDir <- canonicalizePath (distPref </> "build/cabal")
let programSearchPath = ProgramSearchPathDir buildDir : defaultProgramSearchPath
(cabal, _) <- requireProgram normal cabalProgram (setProgramSearchPath programSearchPath defaultProgramDb)
let programSearchPath = [ProgramSearchPathDir $ distPref </> "build/cabal"]
-- This throws an error if the cabal executable hasn't been built yet,
-- because test suites can't depend on executables.
(cabal, _) <- requireProgram normal cabalProgram
(setProgramSearchPath programSearchPath defaultProgramDb)
(ghcPkg, _) <- requireProgram normal ghcPkgProgram defaultProgramDb
baseDirectory <- canonicalizePath $ "tests" </> "IntegrationTests"
-- Set up environment variables for test scripts
Expand Down