Skip to content

Commit

Permalink
Merge pull request #5730 from haskell/remove-unix-constraiant
Browse files Browse the repository at this point in the history
Remove unix constraint from cabal.project

(cherry picked from commit 6797a9e)
  • Loading branch information
phadej authored and 23Skidoo committed Dec 3, 2018
1 parent 547066b commit b4ea814
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 8 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

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
12 changes: 12 additions & 0 deletions cabal.project.local.travis
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,17 @@ allow-newer: hackage-repo-tool:time
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
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

0 comments on commit b4ea814

Please sign in to comment.