mirror of
https://github.com/commercialhaskell/stackage.git
synced 2026-01-19 18:51:58 +01:00
Only use streaming show-details for cabal 1.20
This commit is contained in:
parent
4cf56850f4
commit
c5e2a58f29
@ -9,6 +9,7 @@ import Control.Exception (Exception, SomeException, handle, throwIO)
|
|||||||
import Control.Monad (replicateM, unless, when)
|
import Control.Monad (replicateM, unless, when)
|
||||||
import qualified Data.Map as Map
|
import qualified Data.Map as Map
|
||||||
import qualified Data.Set as Set
|
import qualified Data.Set as Set
|
||||||
|
import Data.Version (parseVersion, Version (Version))
|
||||||
import Data.Typeable (Typeable)
|
import Data.Typeable (Typeable)
|
||||||
import Stackage.Types
|
import Stackage.Types
|
||||||
import Stackage.Util
|
import Stackage.Util
|
||||||
@ -18,7 +19,8 @@ import System.Exit (ExitCode (ExitSuccess))
|
|||||||
import System.FilePath ((<.>), (</>))
|
import System.FilePath ((<.>), (</>))
|
||||||
import System.IO (IOMode (WriteMode, AppendMode),
|
import System.IO (IOMode (WriteMode, AppendMode),
|
||||||
withBinaryFile)
|
withBinaryFile)
|
||||||
import System.Process (runProcess, waitForProcess)
|
import System.Process (readProcess, runProcess, waitForProcess)
|
||||||
|
import Text.ParserCombinators.ReadP (readP_to_S)
|
||||||
|
|
||||||
runTestSuites :: BuildSettings -> BuildPlan -> IO ()
|
runTestSuites :: BuildSettings -> BuildPlan -> IO ()
|
||||||
runTestSuites settings' bp = do
|
runTestSuites settings' bp = do
|
||||||
@ -28,11 +30,23 @@ runTestSuites settings' bp = do
|
|||||||
let testdir = "runtests"
|
let testdir = "runtests"
|
||||||
rm_r testdir
|
rm_r testdir
|
||||||
createDirectory testdir
|
createDirectory testdir
|
||||||
allPass <- parFoldM (testWorkerThreads settings) (runTestSuite settings testdir) (&&) True $ Map.toList selected
|
cabalVersion <- getCabalVersion
|
||||||
|
allPass <- parFoldM (testWorkerThreads settings) (runTestSuite cabalVersion settings testdir) (&&) True $ Map.toList selected
|
||||||
unless allPass $ error $ "There were failures, please see the logs in " ++ testdir
|
unless allPass $ error $ "There were failures, please see the logs in " ++ testdir
|
||||||
where
|
where
|
||||||
notSkipped p _ = p `Set.notMember` bpSkippedTests bp
|
notSkipped p _ = p `Set.notMember` bpSkippedTests bp
|
||||||
|
|
||||||
|
getCabalVersion :: IO CabalVersion
|
||||||
|
getCabalVersion = do
|
||||||
|
output <- readProcess "cabal" ["--numeric-version"] ""
|
||||||
|
case filter (null . snd) $ readP_to_S parseVersion $ filter notCRLF output of
|
||||||
|
(Version (x:y:_) _, _):_ -> return $ CabalVersion x y
|
||||||
|
_ -> error $ "Invalid cabal version: " ++ show output
|
||||||
|
where
|
||||||
|
notCRLF '\n' = False
|
||||||
|
notCRLF '\r' = False
|
||||||
|
notCRLF _ = True
|
||||||
|
|
||||||
parFoldM :: Int -- ^ number of threads
|
parFoldM :: Int -- ^ number of threads
|
||||||
-> (b -> IO c)
|
-> (b -> IO c)
|
||||||
-> (a -> c -> a)
|
-> (a -> c -> a)
|
||||||
@ -77,11 +91,15 @@ data TestException = TestException
|
|||||||
deriving (Show, Typeable)
|
deriving (Show, Typeable)
|
||||||
instance Exception TestException
|
instance Exception TestException
|
||||||
|
|
||||||
runTestSuite :: BuildSettings
|
data CabalVersion = CabalVersion Int Int
|
||||||
|
deriving (Eq, Ord, Show)
|
||||||
|
|
||||||
|
runTestSuite :: CabalVersion
|
||||||
|
-> BuildSettings
|
||||||
-> FilePath
|
-> FilePath
|
||||||
-> (PackageName, SelectedPackageInfo)
|
-> (PackageName, SelectedPackageInfo)
|
||||||
-> IO Bool
|
-> IO Bool
|
||||||
runTestSuite settings testdir (packageName, SelectedPackageInfo {..}) = do
|
runTestSuite cabalVersion settings testdir (packageName, SelectedPackageInfo {..}) = do
|
||||||
-- Set up a new environment that includes the sandboxed bin folder in PATH.
|
-- Set up a new environment that includes the sandboxed bin folder in PATH.
|
||||||
env' <- getModifiedEnv settings
|
env' <- getModifiedEnv settings
|
||||||
let menv addGPP
|
let menv addGPP
|
||||||
@ -116,10 +134,12 @@ runTestSuite settings testdir (packageName, SelectedPackageInfo {..}) = do
|
|||||||
getHandle AppendMode $ run "cabal" (addCabalArgs settings BSTest ["configure", "--enable-tests"]) dir
|
getHandle AppendMode $ run "cabal" (addCabalArgs settings BSTest ["configure", "--enable-tests"]) dir
|
||||||
when spiHasTests $ do
|
when spiHasTests $ do
|
||||||
getHandle AppendMode $ run "cabal" ["build"] dir
|
getHandle AppendMode $ run "cabal" ["build"] dir
|
||||||
getHandle AppendMode $ runGhcPackagePath "cabal"
|
getHandle AppendMode $ runGhcPackagePath "cabal" (concat
|
||||||
[ "test"
|
[ ["test"]
|
||||||
, "--show-details=streaming" -- FIXME temporary workaround for https://github.com/haskell/cabal/issues/1810
|
, if cabalVersion >= CabalVersion 1 20
|
||||||
] dir
|
then ["--show-details=streaming"] -- FIXME temporary workaround for https://github.com/haskell/cabal/issues/1810
|
||||||
|
else []
|
||||||
|
]) dir
|
||||||
when (buildDocs settings) $
|
when (buildDocs settings) $
|
||||||
getHandle AppendMode $ run "cabal" ["haddock"] dir
|
getHandle AppendMode $ run "cabal" ["haddock"] dir
|
||||||
return True
|
return True
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user