@@ -4058,7 +4058,7 @@ setupHsConfigureFlags
4058
4058
Just _ -> error " non-library dependency"
4059
4059
Nothing -> LMainLibName
4060
4060
4061
- configCoverageFor = determineCoverageFor elabPkgSourceId plan
4061
+ configCoverageFor = determineCoverageFor elab plan
4062
4062
4063
4063
setupHsConfigureArgs
4064
4064
:: ElaboratedConfiguredPackage
@@ -4469,13 +4469,14 @@ inplaceBinRoot layout config package =
4469
4469
4470
4470
-- The list of non-pre-existing libraries without module holes, i.e. the
4471
4471
-- main library and sub-libraries components of all the local packages in
4472
- -- the project that do not require instantiations or are instantiations.
4472
+ -- the project that are dependencies of the components being built and that do
4473
+ -- not require instantiations or are instantiations.
4473
4474
determineCoverageFor
4474
- :: PackageId
4475
- -- ^ The 'PackageId' of the package or component being configured
4475
+ :: ElaboratedConfiguredPackage
4476
+ -- ^ The package or component being configured
4476
4477
-> ElaboratedInstallPlan
4477
4478
-> Flag [UnitId ]
4478
- determineCoverageFor configuredPkgSourceId plan =
4479
+ determineCoverageFor configuredPkg plan =
4479
4480
Flag
4480
4481
$ mapMaybe
4481
4482
( \ case
@@ -4488,15 +4489,18 @@ determineCoverageFor configuredPkgSourceId plan =
4488
4489
$ Graph. toList
4489
4490
$ InstallPlan. toGraph plan
4490
4491
where
4491
- shouldCoverPkg elab@ ElaboratedConfiguredPackage {elabModuleShape, elabPkgSourceId, elabLocalToProject} =
4492
+ libDeps = elabLibDependencies configuredPkg
4493
+ shouldCoverPkg elab@ ElaboratedConfiguredPackage {elabModuleShape, elabPkgSourceId = pkgSID, elabLocalToProject} =
4492
4494
elabLocalToProject
4493
4495
&& not (isIndefiniteOrInstantiation elabModuleShape)
4494
4496
-- TODO(#9493): We can only cover libraries in the same package
4495
4497
-- as the testsuite
4496
- && configuredPkgSourceId == elabPkgSourceId
4498
+ && elabPkgSourceId configuredPkg == pkgSID
4497
4499
-- Libraries only! We don't cover testsuite modules, so we never need
4498
4500
-- the paths to their mix dirs. Furthermore, we do not install testsuites...
4499
4501
&& maybe False (\ case CLibName {} -> True ; CNotLibName {} -> False ) (elabComponentName elab)
4502
+ -- We only want coverage for libraries which are dependencies of the given one
4503
+ && pkgSID `elem` map (confSrcId . fst ) libDeps
4500
4504
4501
4505
isIndefiniteOrInstantiation :: ModuleShape -> Bool
4502
4506
isIndefiniteOrInstantiation = not . Set. null . modShapeRequires
0 commit comments