on master help sign in
Skip building test suites when they are not available
commit1ae93324d35a3260da046ad5236ba5b53046fdc8 authorMichael Snoyman <michael@snoyman.com> dateMon 26 Nov 2012, 14:44 (14 years ago) parent6eb18c2
5 files changed+27−12
Stackage/InstallInfo.hs+1 Stackage/LoadDatabase.hs+10−7 Stackage/Test.hs+5−3 Stackage/Types.hs+4−2 Stackage/Util.hs+7
Stackage/InstallInfo.hs+1
@@ -29,6 +29,7 @@ getInstallInfo = do
2929 { iiCore = totalCore
3030 , iiPackages = Map.map fst final
3131 , iiOptionalCore = Map.fromList $ map (\(PackageIdentifier p v) -> (p, v)) $ Set.toList $ hplibs hp
32+ , iiPackageDB = pdb
3233 }
3334
3435showDep :: (PackageName, (Version, [PackageName])) -> String
Stackage/LoadDatabase.hs+10−7
@@ -58,21 +58,24 @@ loadPackageDB core deps = do
5858 | not $ withinRange v vrange -> return pdb
5959 _ ->
6060 case Tar.entryContent e of
61− Tar.NormalFile bs _ -> return $ mappend pdb $ PackageDB $ Map.singleton p PackageInfo
62− { piVersion = v
63− , piDeps = parseDeps bs
64− }
61+ Tar.NormalFile bs _ -> do
62+ let (deps', hasTests) = parseDeps bs
63+ return $ mappend pdb $ PackageDB $ Map.singleton p PackageInfo
64+ { piVersion = v
65+ , piDeps = deps'
66+ , piHasTests = hasTests
67+ }
6568 _ -> return pdb
6669
6770 parseDeps lbs =
6871 case parsePackageDescription $ L8.unpack lbs of
69− ParseOk _ gpd -> mconcat
72+ ParseOk _ gpd -> (mconcat
7073 [ maybe mempty (go gpd) $ condLibrary gpd
7174 , mconcat $ map (go gpd . snd) $ condExecutables gpd
7275 , mconcat $ map (go gpd . snd) $ condTestSuites gpd
7376 , mconcat $ map (go gpd . snd) $ condBenchmarks gpd
74− ]
75− _ -> mempty
77+ ], not $ null $ condTestSuites gpd)
78+ _ -> (mempty, defaultHasTestSuites)
7679 where
7780 go gpd tree
7881 = Set.unions
Stackage/Test.hs+5−3
@@ -16,16 +16,18 @@ import System.FilePath ((<.>), (</>))
1616import System.IO (IOMode (WriteMode, AppendMode),
1717 withBinaryFile)
1818import System.Process (runProcess, waitForProcess)
19−import Distribution.Text
20−import Data.Maybe
2119
2220runTestSuites :: InstallInfo -> IO ()
2321runTestSuites ii = do
2422 let testdir = "runtests"
2523 rm_r testdir
2624 createDirectory testdir
27− allPass <- foldM (runTestSuite testdir) True $ Map.toList $ iiPackages ii
25+ allPass <- foldM (runTestSuite testdir) True $ filter hasTestSuites $ Map.toList $ iiPackages ii
2826 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
2931
3032-- | Separate for the PATH environment variable
3133pathSep :: Char
Stackage/Types.hs+4−2
@@ -25,8 +25,9 @@ instance Monoid PackageDB where
2525 | otherwise = pi2
2626
2727data PackageInfo = PackageInfo
28− { piVersion :: Version
29− , piDeps :: Set PackageName
28+ { piVersion :: Version
29+ , piDeps :: Set PackageName
30+ , piHasTests :: Bool
3031 }
3132 deriving (Show, Eq, Ord)
3233
@@ -46,4 +47,5 @@ data InstallInfo = InstallInfo
4647 -- ^ This is intended to hold onto packages which might be automatically
4748 -- provided in the global package database. In practice, this would be
4849 -- Haskell Platform packages provided by distributions.
50+ , iiPackageDB :: PackageDB
4951 }
Stackage/Util.hs+7
@@ -61,3 +61,10 @@ getPackageVersion e = do
6161 Just (package, version)
6262 where
6363 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