Skip to content

Commit

Permalink
Merge pull request #5766 from 23Skidoo/travis-fixes-from-2.4
Browse files Browse the repository at this point in the history
[WIP] Port Travis fixes from the 2.4 branch
  • Loading branch information
23Skidoo authored Dec 4, 2018
2 parents ec6966e + b4ea814 commit e8a8287
Show file tree
Hide file tree
Showing 11 changed files with 132 additions and 34 deletions.
7 changes: 6 additions & 1 deletion Cabal/Distribution/Compat/Directory.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ makeAbsolute p | Path.isAbsolute p = return p
#if !MIN_VERSION_directory(1,2,7)

doesPathExist :: FilePath -> IO Bool
doesPathExist path = (||) <$> doesDirectoryExist path <*> doesFileExist path
doesPathExist path = do
-- not using Applicative, as this way we can do less IO
e <- doesDirectoryExist path
if e
then return True
else doesFileExist path

#endif

24 changes: 12 additions & 12 deletions cabal-install/cabal-install.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -305,31 +305,31 @@ executable cabal
Paths_cabal_install

build-depends:
async >= 2.0 && < 3,
async >= 2.0 && < 2.3,
array >= 0.4 && < 0.6,
base >= 4.6 && < 5,
base >= 4.8 && < 4.13,
base16-bytestring >= 0.1.1 && < 0.2,
binary >= 0.7 && < 0.9,
bytestring >= 0.10.2 && < 1,
binary >= 0.7.3 && < 0.9,
bytestring >= 0.10.6.0 && < 0.11,
Cabal == 2.5.*,
containers >= 0.5 && < 0.7,
containers >= 0.5.6.2 && < 0.7,
cryptohash-sha256 >= 0.11 && < 0.12,
deepseq >= 1.3 && < 1.5,
deepseq >= 1.4.1.1 && < 1.5,
directory >= 1.2.2.0 && < 1.4,
echo >= 0.1.3 && < 0.2,
edit-distance >= 0.2.2 && < 0.3,
filepath >= 1.3 && < 1.5,
hashable >= 1.0 && < 2,
filepath >= 1.4.0.0 && < 1.5,
hashable >= 1.0 && < 1.3,
HTTP >= 4000.1.5 && < 4000.4,
mtl >= 2.0 && < 3,
mtl >= 2.0 && < 2.3,
network-uri >= 2.6.0.2 && < 2.7,
network >= 2.6 && < 2.9,
pretty >= 1.1 && < 1.2,
process >= 1.1.0.2 && < 1.7,
process >= 1.2.3.0 && < 1.7,
random >= 1 && < 1.2,
stm >= 2.0 && < 3,
stm >= 2.0 && < 2.6,
tar >= 0.5.0.3 && < 0.6,
time >= 1.4 && < 1.10,
time >= 1.5.0.1 && < 1.10,
zlib >= 0.5.3 && < 0.7,
hackage-security >= 0.5.2.2 && < 0.6,
text >= 1.2.3 && < 1.3,
Expand Down
24 changes: 12 additions & 12 deletions cabal-install/cabal-install.cabal.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,31 @@
#
%def CABAL_BUILDDEPENDS
build-depends:
async >= 2.0 && < 3,
async >= 2.0 && < 2.3,
array >= 0.4 && < 0.6,
base >= 4.6 && < 5,
base >= 4.8 && < 4.13,
base16-bytestring >= 0.1.1 && < 0.2,
binary >= 0.7 && < 0.9,
bytestring >= 0.10.2 && < 1,
binary >= 0.7.3 && < 0.9,
bytestring >= 0.10.6.0 && < 0.11,
Cabal == 2.5.*,
containers >= 0.5 && < 0.7,
containers >= 0.5.6.2 && < 0.7,
cryptohash-sha256 >= 0.11 && < 0.12,
deepseq >= 1.3 && < 1.5,
deepseq >= 1.4.1.1 && < 1.5,
directory >= 1.2.2.0 && < 1.4,
echo >= 0.1.3 && < 0.2,
edit-distance >= 0.2.2 && < 0.3,
filepath >= 1.3 && < 1.5,
hashable >= 1.0 && < 2,
filepath >= 1.4.0.0 && < 1.5,
hashable >= 1.0 && < 1.3,
HTTP >= 4000.1.5 && < 4000.4,
mtl >= 2.0 && < 3,
mtl >= 2.0 && < 2.3,
network-uri >= 2.6.0.2 && < 2.7,
network >= 2.6 && < 2.9,
pretty >= 1.1 && < 1.2,
process >= 1.1.0.2 && < 1.7,
process >= 1.2.3.0 && < 1.7,
random >= 1 && < 1.2,
stm >= 2.0 && < 3,
stm >= 2.0 && < 2.6,
tar >= 0.5.0.3 && < 0.6,
time >= 1.4 && < 1.10,
time >= 1.5.0.1 && < 1.10,
zlib >= 0.5.3 && < 0.7,
hackage-security >= 0.5.2.2 && < 0.6,
text >= 1.2.3 && < 1.3,
Expand Down
3 changes: 2 additions & 1 deletion cabal-testsuite/PackageTests/Exec/sandbox-hc-pkg.test.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import Test.Cabal.Prelude
import Data.Maybe
import System.Directory
import Distribution.Compat.Directory
import Control.Monad.IO.Class

main = cabalTest $ do
withPackageDb $ do
withSandbox $ do
Expand Down
6 changes: 6 additions & 0 deletions cabal-testsuite/Test/Cabal/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,15 @@ initServer s0 = do
#else
pid <- withProcessHandle (serverProcessHandle s0) $ \ph ->
case ph of
#if MIN_VERSION_process(1,2,0)
OpenHandle x -> return (show x)
-- TODO: handle OpenExtHandle?
_ -> return (serverProcessId s0)
#else
OpenHandle x -> return (ph, show x)
-- TODO: handle OpenExtHandle?
_ -> return (ph, serverProcessId s0)
#endif
#endif
let s = s0 { serverProcessId = pid }
-- We will read/write a line at a time, including for
Expand Down
34 changes: 32 additions & 2 deletions cabal-testsuite/main/cabal-tests.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE NondecreasingIndentation #-}
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE ScopedTypeVariables #-}
Expand All @@ -20,13 +21,25 @@ import Control.Monad
import qualified Control.Exception as E
import GHC.Conc (numCapabilities)
import Data.List
import Data.Monoid (mempty, (<>))
import Text.Printf
import qualified System.Clock as Clock
import System.IO
import System.FilePath
import System.Exit
import System.Process (callProcess, showCommandForUser)
import System.Process (
#if MIN_VERSION_process(1,2,0)
callProcess,
#else
proc, createProcess, waitForProcess, terminateProcess,
#endif
showCommandForUser)

#if !MIN_VERSION_base(4,12,0)
import Data.Monoid ((<>))
#endif
#if !MIN_VERSION_base(4,8,0)
import Data.Monoid (mempty)
#endif

-- | Record for arguments that can be passed to @cabal-tests@ executable.
data MainArgs = MainArgs {
Expand Down Expand Up @@ -298,3 +311,20 @@ getTime = do
t <- Clock.getTime Clock.Monotonic
let ns = realToFrac $ Clock.toNanoSecs t
return $ ns / 10 ^ (9 :: Int)

-------------------------------------------------------------------------------
-- compat
-------------------------------------------------------------------------------

#if !MIN_VERSION_process(1,2,0)
callProcess :: FilePath -> [String] -> IO ()
callProcess cmd args = do
exit_code <- bracket (createProcess (proc cmd args)) cleanupProcess
$ \(_, _, _, ph) -> waitForProcess ph
case exit_code of
ExitSuccess -> return ()
ExitFailure r -> fail $ "processFailedException " ++ show (cmd, args, r)
where
cleanupProcess (_, _, _, ph) = terminateProcess ph

#endif
1 change: 0 additions & 1 deletion cabal.project
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
packages: Cabal/ cabal-testsuite/ cabal-install/ solver-benchmarks/ pretty-show-1.6.16/
constraints: unix >= 2.7.1.0

-- Uncomment to allow picking up extra local unpacked deps:
--optional-packages: */
Expand Down
32 changes: 32 additions & 0 deletions cabal.project.local.travis
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
-- Force error messages to be better
-- Parallel new-build error messages are non-existent.
-- Turn off parallelization to get good errors.
jobs: 1

-- We vendor a copy of hackage-repo-tool so that we can
-- build it reliably. If we eventually get new-install
-- in the bootstrap, this can go away.
optional-packages: hackage-repo-tool-*/
-- hackage-repo-tool has upper bound on time
allow-newer: hackage-repo-tool:time

-- The -fno-warn-orphans is a hack to make Cabal-1.24
-- build properly (unfortunately the flags here get applied
-- to the dependencies too!)
package Cabal
ghc-options: -Werror -fno-warn-orphans

constraints:
binary installed,
bytestring installed,
containers installed,
deepseq installed,
directory installed,
filepath installed,
pretty installed,
process installed,
time installed,
unix installed

package cabal-install
ghc-options: -Werror
24 changes: 24 additions & 0 deletions cabal.project.travis.libonly
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
-- A copy of cabal.project, but with a trimmed down 'packages'
-- field. Needed for LIB_ONLY configurations that can't build cabal-install,
-- only lib:Cabal.

packages: Cabal/ cabal-testsuite/

-- Uncomment to allow picking up extra local unpacked deps:
--optional-packages: */

program-options
-- So us hackers get all the assertion failures early:
--
-- NOTE: currently commented out, see
-- https://github.com/haskell/cabal/issues/3911
--
-- ghc-options: -fno-ignore-asserts
--
-- as a workaround we specify it for each package individually:
package Cabal
ghc-options: -fno-ignore-asserts
package cabal-testsuite
ghc-options: -fno-ignore-asserts
package cabal-install
ghc-options: -fno-ignore-asserts
4 changes: 1 addition & 3 deletions cabal.project.validate
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
packages: Cabal/ cabal-testsuite/ cabal-install/
packages: Cabal/ cabal-testsuite/

package Cabal
ghc-options: -Werror -fno-ignore-asserts
package cabal-testsuite
ghc-options: -Werror -fno-ignore-asserts
package cabal-install
ghc-options: -Werror -fno-ignore-asserts
7 changes: 5 additions & 2 deletions travis-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,13 @@ timed cabal update
# ---------------------------------------------------------------------

make cabal-install-monolithic
cp cabal.project.travis cabal.project.local
if [ "x$CABAL_LIB_ONLY" = "xYES" ]; then
cp cabal.project.travis.libonly cabal.project
fi
cp cabal.project.local.travis cabal.project.local

# hackage-repo-tool is a bit touchy to install on GHC 8.0, so instead we
# do it via new-build. See also cabal.project.travis. The downside of
# do it via new-build. See also cabal.project.local.travis. The downside of
# doing it this way is that the build product cannot be cached, but
# hackage-repo-tool is a relatively small package so it's good.
timed cabal unpack hackage-repo-tool-${HACKAGE_REPO_TOOL_VERSION}
Expand Down

0 comments on commit e8a8287

Please sign in to comment.