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 <ezyang@cs.stanford.edu>
parent fc26cef2
......@@ -55,9 +55,8 @@ import GHC.IO.Encoding.Failure
#endif
#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
#endif
-- | 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)
#endif
return ret
......
......@@ -43,7 +43,6 @@ Extra-Source-Files:
tests/IntegrationTests/custom/custom_dep/custom/A.hs
tests/IntegrationTests/custom/custom_dep/custom/Setup.hs
tests/IntegrationTests/custom/custom_dep/custom/custom.cabal
tests/IntegrationTests/custom/plain.err
tests/IntegrationTests/custom/plain.sh
tests/IntegrationTests/custom/plain/A.hs
tests/IntegrationTests/custom/plain/Setup.hs
......
. ./common.sh
# On Travis OSX, Cabal shipped with GHC 7.8 does not work
# with error "setup: /usr/bin/ar: permission denied"; see
# also https://github.com/haskell/cabal/issues/3938
# This is a hack to make the test not run in this case.
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
require_ghc_ge 710
fi
cd custom_dep
cabal sandbox init
cabal sandbox add-source custom
......
. ./common.sh
# On Travis OSX, Cabal shipped with GHC 7.8 does not work
# with error "setup: /usr/bin/ar: permission denied"; see
# also https://github.com/haskell/cabal/issues/3938
# This is a hack to make the test not run in this case.
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
require_ghc_ge 710
fi
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 >= 2.7.1.0
-- Uncomment to allow picking up extra local unpacked deps:
--optional-packages: */
......
......@@ -9,6 +9,8 @@
. ./travis-common.sh
CABAL_STORE_DB="${HOME}/.cabal/store/ghc-${GHCVER}/package.db"
CABAL_LOCAL_DB="${PWD}/dist-newstyle/packagedb/ghc-${GHCVER}"
CABAL_BDIR="${PWD}/dist-newstyle/build/Cabal-${CABAL_VERSION}"
CABAL_INSTALL_BDIR="${PWD}/dist-newstyle/build/cabal-install-${CABAL_VERSION}"
CABAL_INSTALL_SETUP="${CABAL_INSTALL_BDIR}/setup/setup"
......@@ -53,7 +55,7 @@ timed cabal new-build Cabal Cabal:package-tests Cabal:unit-tests
# http://stackoverflow.com/questions/14970663/why-doesnt-bash-flag-e-exit-when-a-subshell-fails
# 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!)
......
Markdown is supported
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