Commit 2ed454ee authored by Mikhail Glushenkov's avatar Mikhail Glushenkov Committed by Edward Z. Yang
Browse files

Fix CI on Mac OS X with GHC 7.8 and earlier.

On recent OS X, Cabal does not work correctly because it assumes
that a permission denied error when reading permissions on
executables, resulting in errors like "Setup: /usr/bin/ar: permission denied".

The proximal fix for this is to add a constraint on unix when we build
Cabal/cabal-install to avoid building with the buggy version of unix.
But this causes other problems:

- Bumping the version of unix means that our local build of Cabal
  will depend on things from the store.  But we weren't passing
  this to GHC when compiled Setup.hs for Cabal's package-tests.
  Set CABAL_PACKAGETESTS_DB_STACK env var explicitly to point
  to the right locations.

- The new configuration of versions exposed some bugs in some
  macro expanded code in cabal-install; we qualified those
  imports to squash unused warnings.

- The cabal-install integration-tests occasionally use Cabal from
  the system GHC.  Since this will never work on OS X, we just
  skip the tests in those cases.

Signed-off-by: default avatarEdward Z. Yang <>
parent fc26cef2
......@@ -55,9 +55,8 @@ import GHC.IO.Encoding.Failure
#if defined(mingw32_HOST_OS) || MIN_VERSION_directory(1,2,3)
import Prelude hiding (ioError)
import System.Directory (doesDirectoryExist)
import System.IO.Error (ioError, mkIOError, doesNotExistErrorType)
import qualified System.Directory as Dir
import qualified System.IO.Error as IOError
-- | Generic merging utility. For sorted input lists this is a full outer join.
......@@ -244,9 +243,9 @@ tryCanonicalizePath :: FilePath -> IO FilePath
tryCanonicalizePath path = do
ret <- canonicalizePath path
#if defined(mingw32_HOST_OS) || MIN_VERSION_directory(1,2,3)
exists <- liftM2 (||) (doesFileExist ret) (doesDirectoryExist ret)
exists <- liftM2 (||) (doesFileExist ret) (Dir.doesDirectoryExist ret)
unless exists $
ioError $ mkIOError doesNotExistErrorType "canonicalizePath"
IOError.ioError $ IOError.mkIOError IOError.doesNotExistErrorType "canonicalizePath"
Nothing (Just ret)
return ret
......@@ -43,7 +43,6 @@ Extra-Source-Files:
. ./
# On Travis OSX, Cabal shipped with GHC 7.8 does not work
# with error "setup: /usr/bin/ar: permission denied"; see
# also
# This is a hack to make the test not run in this case.
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
require_ghc_ge 710
cd custom_dep
cabal sandbox init
cabal sandbox add-source custom
. ./
# On Travis OSX, Cabal shipped with GHC 7.8 does not work
# with error "setup: /usr/bin/ar: permission denied"; see
# also
# This is a hack to make the test not run in this case.
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
require_ghc_ge 710
cd plain
cabal configure
cabal build
cabal configure 2> log
grep Custom log
cabal build 2> log
grep Custom log
......@@ -14,6 +14,8 @@ import Distribution.Package
import Distribution.PackageDescription
import Distribution.InstalledPackageInfo (InstalledPackageInfo)
import Distribution.Simple.Setup (toFlag)
import Distribution.Simple.Compiler
import Distribution.System
import Distribution.Version
import Distribution.Verbosity
import Distribution.Text
......@@ -130,8 +132,17 @@ testExceptionInBuildStep config = do
testSetupScriptStyles :: ProjectConfig -> (String -> IO ()) -> Assertion
testSetupScriptStyles config reportSubCase = do
reportSubCase (show SetupCustomExplicitDeps)
(plan1, res1) <- executePlan =<< planProject testdir1 config
reportSubCase (show SetupCustomExplicitDeps)
plan0@(_,_,sharedConfig,_,_) <- planProject testdir1 config
let isOSX (Platform _ OSX) = True
isOSX _ = False
-- Skip the Custom tests when the shipped Cabal library is buggy
unless (isOSX (pkgConfigPlatform sharedConfig)
&& compilerVersion (pkgConfigCompiler sharedConfig) < mkVersion [7,10]) $ do
(plan1, res1) <- executePlan plan0
(pkg1, _) <- expectPackageInstalled plan1 res1 pkgidA
elabSetupScriptStyle pkg1 @?= SetupCustomExplicitDeps
hasDefaultSetupDeps pkg1 @?= Just False
packages: Cabal/ cabal-install/
constraints: unix >=
-- Uncomment to allow picking up extra local unpacked deps:
--optional-packages: */
......@@ -9,6 +9,8 @@
. ./
......@@ -53,7 +55,7 @@ timed cabal new-build Cabal Cabal:package-tests Cabal:unit-tests
# Run tests
(cd Cabal && timed ${CABAL_BDIR}/build/package-tests/package-tests $TEST_OPTIONS) || exit $?
(export CABAL_PACKAGETESTS_DB_STACK="clear:global:${CABAL_STORE_DB}:${CABAL_LOCAL_DB}"; cd Cabal && timed ${CABAL_BDIR}/build/package-tests/package-tests $TEST_OPTIONS) || exit $?
(cd Cabal && timed ${CABAL_BDIR}/build/unit-tests/unit-tests $TEST_OPTIONS) || exit $?
# Run haddock (hack: use the Setup script from package-tests!)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment