on master help sign in
Only use streaming show-details for cabal 1.20
commitc5e2a58f290bbc685dbd9d00fd4d424e37df1304 authorMichael Snoyman <michael@snoyman.com> dateMon 30 Jun 2014, 12:37 (12 years ago) parent4cf5685
1 file changed+28−8
Stackage/Test.hs+28−8
Stackage/Test.hs+28−8
@@ -9,6 +9,7 @@ import Control.Exception (Exception, SomeException, handle, throwIO)
99import Control.Monad (replicateM, unless, when)
1010import qualified Data.Map as Map
1111import qualified Data.Set as Set
12+import Data.Version (parseVersion, Version (Version))
1213import Data.Typeable (Typeable)
1314import Stackage.Types
1415import Stackage.Util
@@ -18,7 +19,8 @@ import System.Exit (ExitCode (ExitSuccess))
1819import System.FilePath ((<.>), (</>))
1920import System.IO (IOMode (WriteMode, AppendMode),
2021 withBinaryFile)
21−import System.Process (runProcess, waitForProcess)
22+import System.Process (readProcess, runProcess, waitForProcess)
23+import Text.ParserCombinators.ReadP (readP_to_S)
2224
2325runTestSuites :: BuildSettings -> BuildPlan -> IO ()
2426runTestSuites settings' bp = do
@@ -28,11 +30,23 @@ runTestSuites settings' bp = do
2830 let testdir = "runtests"
2931 rm_r testdir
3032 createDirectory testdir
31− allPass <- parFoldM (testWorkerThreads settings) (runTestSuite settings testdir) (&&) True $ Map.toList selected
33+ cabalVersion <- getCabalVersion
34+ allPass <- parFoldM (testWorkerThreads settings) (runTestSuite cabalVersion settings testdir) (&&) True $ Map.toList selected
3235 unless allPass $ error $ "There were failures, please see the logs in " ++ testdir
3336 where
3437 notSkipped p _ = p `Set.notMember` bpSkippedTests bp
3538
39+getCabalVersion :: IO CabalVersion
40+getCabalVersion = do
41+ output <- readProcess "cabal" ["--numeric-version"] ""
42+ case filter (null . snd) $ readP_to_S parseVersion $ filter notCRLF output of
43+ (Version (x:y:_) _, _):_ -> return $ CabalVersion x y
44+ _ -> error $ "Invalid cabal version: " ++ show output
45+ where
46+ notCRLF '\n' = False
47+ notCRLF '\r' = False
48+ notCRLF _ = True
49+
3650parFoldM :: Int -- ^ number of threads
3751 -> (b -> IO c)
3852 -> (a -> c -> a)
@@ -77,11 +91,15 @@ data TestException = TestException
7791 deriving (Show, Typeable)
7892instance Exception TestException
7993
80−runTestSuite :: BuildSettings
94+data CabalVersion = CabalVersion Int Int
95+ deriving (Eq, Ord, Show)
96+
97+runTestSuite :: CabalVersion
98+ -> BuildSettings
8199 -> FilePath
82100 -> (PackageName, SelectedPackageInfo)
83101 -> IO Bool
84−runTestSuite settings testdir (packageName, SelectedPackageInfo {..}) = do
102+runTestSuite cabalVersion settings testdir (packageName, SelectedPackageInfo {..}) = do
85103 -- Set up a new environment that includes the sandboxed bin folder in PATH.
86104 env' <- getModifiedEnv settings
87105 let menv addGPP
@@ -116,10 +134,12 @@ runTestSuite settings testdir (packageName, SelectedPackageInfo {..}) = do
116134 getHandle AppendMode $ run "cabal" (addCabalArgs settings BSTest ["configure", "--enable-tests"]) dir
117135 when spiHasTests $ do
118136 getHandle AppendMode $ run "cabal" ["build"] dir
119− getHandle AppendMode $ runGhcPackagePath "cabal"
120− [ "test"
121− , "--show-details=streaming" -- FIXME temporary workaround for https://github.com/haskell/cabal/issues/1810
122− ] dir
137+ getHandle AppendMode $ runGhcPackagePath "cabal" (concat
138+ [ ["test"]
139+ , if cabalVersion >= CabalVersion 1 20
140+ then ["--show-details=streaming"] -- FIXME temporary workaround for https://github.com/haskell/cabal/issues/1810
141+ else []
142+ ]) dir
123143 when (buildDocs settings) $
124144 getHandle AppendMode $ run "cabal" ["haddock"] dir
125145 return True