Skip to content

Commit

Permalink
Merge pull request #3942 from 23Skidoo/issue-3938
Browse files Browse the repository at this point in the history
cabal.project: Add a constraint on unix.
  • Loading branch information
ezyang committed Oct 6, 2016
2 parents fc26cef + 2ed454e commit ff08346
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 13 deletions.
9 changes: 4 additions & 5 deletions cabal-install/Distribution/Client/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion cabal-install/cabal-install.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions cabal-install/tests/IntegrationTests/custom/custom_dep.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
. ./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
Expand Down
2 changes: 0 additions & 2 deletions cabal-install/tests/IntegrationTests/custom/plain.err

This file was deleted.

15 changes: 13 additions & 2 deletions cabal-install/tests/IntegrationTests/custom/plain.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
. ./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
15 changes: 13 additions & 2 deletions cabal-install/tests/IntegrationTests2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
packages: Cabal/ cabal-install/
constraints: unix >= 2.7.1.0

-- Uncomment to allow picking up extra local unpacked deps:
--optional-packages: */
Expand Down
4 changes: 3 additions & 1 deletion travis-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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!)
Expand Down

0 comments on commit ff08346

Please sign in to comment.