Fix problems with build tool test suite cycles

This commit is contained in:
Michael Snoyman 2014-03-13 09:23:37 +02:00
parent 81f2917f77
commit f228b0f9b9
3 changed files with 17 additions and 11 deletions

View File

@ -155,12 +155,13 @@ loadPackageDB settings coreMap core deps = do
| otherwise = loop rest | otherwise = loop rest
addPackage p v lbs pdb = do addPackage p v lbs pdb = do
let (deps', hasTests, buildTools', mgpd, execs, mgithub) = parseDeps p lbs let (deps', hasTests, buildToolsExe', buildToolsOther', mgpd, execs, mgithub) = parseDeps p lbs
return $ mappend pdb $ PackageDB $ Map.singleton p PackageInfo return $ mappend pdb $ PackageDB $ Map.singleton p PackageInfo
{ piVersion = v { piVersion = v
, piDeps = deps' , piDeps = deps'
, piHasTests = hasTests , piHasTests = hasTests
, piBuildTools = buildTools' , piBuildToolsExe = buildToolsExe'
, piBuildToolsAll = buildToolsExe' `Set.union` buildToolsOther'
, piGPD = mgpd , piGPD = mgpd
, piExecs = execs , piExecs = execs
, piGithubUser = mgithub , piGithubUser = mgithub
@ -176,25 +177,29 @@ loadPackageDB settings coreMap core deps = do
else mconcat $ map (go gpd . snd) $ condTestSuites gpd else mconcat $ map (go gpd . snd) $ condTestSuites gpd
, mconcat $ map (go gpd . snd) $ condBenchmarks gpd , mconcat $ map (go gpd . snd) $ condBenchmarks gpd
], not $ null $ condTestSuites gpd ], not $ null $ condTestSuites gpd
, Set.fromList $ map depName $ allBuildInfo gpd , Set.fromList $ map depName $ libExeBuildInfo gpd
, Set.fromList $ map depName $ testBenchBuildInfo gpd
, Just gpd , Just gpd
, Set.fromList $ map (Executable . fst) $ condExecutables gpd , Set.fromList $ map (Executable . fst) $ condExecutables gpd
, listToMaybe $ catMaybes , listToMaybe $ catMaybes
$ parseGithubUserHP (homepage $ packageDescription gpd) $ parseGithubUserHP (homepage $ packageDescription gpd)
: map parseGithubUserSR (sourceRepos $ packageDescription gpd) : map parseGithubUserSR (sourceRepos $ packageDescription gpd)
) )
_ -> (mempty, defaultHasTestSuites, Set.empty, Nothing, Set.empty, Nothing) _ -> (mempty, defaultHasTestSuites, Set.empty, Set.empty, Nothing, Set.empty, Nothing)
where where
allBuildInfo gpd = concat allBuildInfo gpd = libExeBuildInfo gpd ++ testBenchBuildInfo gpd
libExeBuildInfo gpd = concat
[ maybe mempty (goBI libBuildInfo) $ condLibrary gpd [ maybe mempty (goBI libBuildInfo) $ condLibrary gpd
, concat $ map (goBI buildInfo . snd) $ condExecutables gpd , concat $ map (goBI buildInfo . snd) $ condExecutables gpd
, if skipTests p ]
testBenchBuildInfo gpd = concat
[ if skipTests p
then [] then []
else concat $ map (goBI testBuildInfo . snd) $ condTestSuites gpd else concat $ map (goBI testBuildInfo . snd) $ condTestSuites gpd
, concat $ map (goBI benchmarkBuildInfo . snd) $ condBenchmarks gpd , concat $ map (goBI benchmarkBuildInfo . snd) $ condBenchmarks gpd
] ]
where goBI f x = buildTools $ f $ condTreeData x
goBI f x = buildTools $ f $ condTreeData x
depName (Dependency (PackageName pn) _) = Executable pn depName (Dependency (PackageName pn) _) = Executable pn
go gpd tree go gpd tree
= Map.filterWithKey (\k _ -> not $ ignoredDep k) = Map.filterWithKey (\k _ -> not $ ignoredDep k)

View File

@ -77,7 +77,7 @@ iiBuildTools InstallInfo { iiPackageDB = PackageDB m, iiPackages = packages } =
$ mapMaybe (flip Map.lookup buildToolMap) $ mapMaybe (flip Map.lookup buildToolMap)
$ Set.toList $ Set.toList
$ Set.unions $ Set.unions
$ map piBuildTools $ map piBuildToolsAll
$ Map.elems $ Map.elems
$ Map.filterWithKey isSelected m $ Map.filterWithKey isSelected m
where where
@ -108,7 +108,7 @@ iiBuildTools InstallInfo { iiPackageDB = PackageDB m, iiPackages = packages } =
Just pi -> Set.fromList Just pi -> Set.fromList
$ mapMaybe (flip Map.lookup buildToolMap) $ mapMaybe (flip Map.lookup buildToolMap)
$ Set.toList $ Set.toList
$ piBuildTools pi $ piBuildToolsExe pi
topSort :: (Show a, Ord a) => [(a, Set a)] -> Either String [a] topSort :: (Show a, Ord a) => [(a, Set a)] -> Either String [a]
topSort orig = topSort orig =

View File

@ -30,7 +30,8 @@ data PackageInfo = PackageInfo
{ piVersion :: Version { piVersion :: Version
, piDeps :: Map PackageName VersionRange , piDeps :: Map PackageName VersionRange
, piHasTests :: Bool , piHasTests :: Bool
, piBuildTools :: Set Executable , piBuildToolsExe :: Set Executable -- ^ required just for building executable/lib
, piBuildToolsAll :: Set Executable -- ^ required for all stanzas
, piGPD :: Maybe GenericPackageDescription , piGPD :: Maybe GenericPackageDescription
, piExecs :: Set Executable , piExecs :: Set Executable
, piGithubUser :: Maybe String , piGithubUser :: Maybe String