on master help sign in
Skip building test suites when they are not available
1ae9332Michael Snoyman
Stackage/InstallInfo.hs+1
@@ -29,6 +29,7 @@ getInstallInfo = do
29 { iiCore = totalCore
29 { iiCore = totalCore
30 , iiPackages = Map.map fst final
30 , iiPackages = Map.map fst final
31 , iiOptionalCore = Map.fromList $ map (\(PackageIdentifier p v) -> (p, v)) $ Set.toList $ hplibs hp
31 , iiOptionalCore = Map.fromList $ map (\(PackageIdentifier p v) -> (p, v)) $ Set.toList $ hplibs hp
32+ , iiPackageDB = pdb
32 }
33 }
33
34
34showDep :: (PackageName, (Version, [PackageName])) -> String
35showDep :: (PackageName, (Version, [PackageName])) -> String
Stackage/LoadDatabase.hs+10−7
@@ -58,21 +58,24 @@ loadPackageDB core deps = do
58 | not $ withinRange v vrange -> return pdb
58 | not $ withinRange v vrange -> return pdb
59 _ ->
59 _ ->
60 case Tar.entryContent e of
60 case Tar.entryContent e of
61+ Tar.NormalFile bs _ -> do
62+ let (deps', hasTests) = parseDeps bs
61− Tar.NormalFile bs _ -> return $ mappend pdb $ PackageDB $ Map.singleton p PackageInfo
63+ return $ mappend pdb $ PackageDB $ Map.singleton p PackageInfo
62− { piVersion = v
64+ { piVersion = v
63− , piDeps = parseDeps bs
65+ , piDeps = deps'
66+ , piHasTests = hasTests
64− }
67+ }
65 _ -> return pdb
68 _ -> return pdb
66
69
67 parseDeps lbs =
70 parseDeps lbs =
68 case parsePackageDescription $ L8.unpack lbs of
71 case parsePackageDescription $ L8.unpack lbs of
69− ParseOk _ gpd -> mconcat
72+ ParseOk _ gpd -> (mconcat
70 [ maybe mempty (go gpd) $ condLibrary gpd
73 [ maybe mempty (go gpd) $ condLibrary gpd
71 , mconcat $ map (go gpd . snd) $ condExecutables gpd
74 , mconcat $ map (go gpd . snd) $ condExecutables gpd
72 , mconcat $ map (go gpd . snd) $ condTestSuites gpd
75 , mconcat $ map (go gpd . snd) $ condTestSuites gpd
73 , mconcat $ map (go gpd . snd) $ condBenchmarks gpd
76 , mconcat $ map (go gpd . snd) $ condBenchmarks gpd
74− ]
77+ ], not $ null $ condTestSuites gpd)
75− _ -> mempty
78+ _ -> (mempty, defaultHasTestSuites)
76 where
79 where
77 go gpd tree
80 go gpd tree
78 = Set.unions
81 = Set.unions
Stackage/Test.hs+5−3
@@ -16,16 +16,18 @@ import System.FilePath ((<.>), (</>))
16import System.IO (IOMode (WriteMode, AppendMode),
16import System.IO (IOMode (WriteMode, AppendMode),
17 withBinaryFile)
17 withBinaryFile)
18import System.Process (runProcess, waitForProcess)
18import System.Process (runProcess, waitForProcess)
19−import Distribution.Text
20−import Data.Maybe
21
19
22runTestSuites :: InstallInfo -> IO ()
20runTestSuites :: InstallInfo -> IO ()
23runTestSuites ii = do
21runTestSuites ii = do
24 let testdir = "runtests"
22 let testdir = "runtests"
25 rm_r testdir
23 rm_r testdir
26 createDirectory testdir
24 createDirectory testdir
27− allPass <- foldM (runTestSuite testdir) True $ Map.toList $ iiPackages ii
25+ allPass <- foldM (runTestSuite testdir) True $ filter hasTestSuites $ Map.toList $ iiPackages ii
28 unless allPass $ error $ "There were failures, please see the logs in " ++ testdir
26 unless allPass $ error $ "There were failures, please see the logs in " ++ testdir
27+ where
28+ PackageDB pdb = iiPackageDB ii
29+
30+ hasTestSuites (name, _) = maybe defaultHasTestSuites piHasTests $ Map.lookup name pdb
29
31
30-- | Separate for the PATH environment variable
32-- | Separate for the PATH environment variable
31pathSep :: Char
33pathSep :: Char
Stackage/Types.hs+4−2
@@ -25,8 +25,9 @@ instance Monoid PackageDB where
25 | otherwise = pi2
25 | otherwise = pi2
26
26
27data PackageInfo = PackageInfo
27data PackageInfo = PackageInfo
28− { piVersion :: Version
28+ { piVersion :: Version
29− , piDeps :: Set PackageName
29+ , piDeps :: Set PackageName
30+ , piHasTests :: Bool
30 }
31 }
31 deriving (Show, Eq, Ord)
32 deriving (Show, Eq, Ord)
32
33
@@ -46,4 +47,5 @@ data InstallInfo = InstallInfo
46 -- ^ This is intended to hold onto packages which might be automatically
47 -- ^ This is intended to hold onto packages which might be automatically
47 -- provided in the global package database. In practice, this would be
48 -- provided in the global package database. In practice, this would be
48 -- Haskell Platform packages provided by distributions.
49 -- Haskell Platform packages provided by distributions.
50+ , iiPackageDB :: PackageDB
49 }
51 }
Stackage/Util.hs+7
@@ -61,3 +61,10 @@ getPackageVersion e = do
61 Just (package, version)
61 Just (package, version)
62 where
62 where
63 fp = TarEntry.fromTarPathToPosixPath $ TarEntry.entryTarPath e
63 fp = TarEntry.fromTarPathToPosixPath $ TarEntry.entryTarPath e
64+
65+-- | If a package cannot be parsed or is not found, the default value for
66+-- whether it has a test suite. We default to @True@ since, worst case
67+-- scenario, this just means a little extra time trying to run a suite that's
68+-- not there. Defaulting to @False@ would result in silent failures.
69+defaultHasTestSuites :: Bool
70+defaultHasTestSuites = True