@@ -835,6 +835,7 @@ singleTest topts ac ee task =
835
835
836
836
when needHpc $ forM_ (lastMay testsToRun) $ \ testName -> do
837
837
let pkgName = packageNameText (packageName package)
838
+ pkgId = packageIdentifierText (packageIdentifier package)
838
839
when (not $ null $ tail testsToRun) $ $ logWarn $ T. concat
839
840
[ " Error: The --coverage flag does not yet support multiple test suites in a single cabal file. "
840
841
, " All of the tests have been run, however, the HPC report will only supply coverage info for "
@@ -843,7 +844,7 @@ singleTest topts ac ee task =
843
844
, testName
844
845
, " ."
845
846
]
846
- generateHpcReport pkgDir pkgName testName
847
+ generateHpcReport pkgDir pkgName pkgId testName
847
848
848
849
bs <- liftIO $
849
850
case mlogFile of
@@ -877,15 +878,22 @@ compareTestsComponents comps tests2 =
877
878
_ -> Set. empty
878
879
879
880
-- | Generate the HTML report and show a textual coverage summary.
880
- generateHpcReport :: M env m => Path Abs Dir -> Text -> Text -> m ()
881
- generateHpcReport pkgDir pkgName testName = do
881
+ generateHpcReport :: M env m => Path Abs Dir -> Text -> Text -> Text -> m ()
882
+ generateHpcReport pkgDir pkgName pkgId testName = do
882
883
let whichTest = pkgName <> " 's test-suite \" " <> testName <> " \" "
883
884
hpcDir <- hpcDirFromDir pkgDir
884
885
hpcRelDir <- (</> dotHpc) <$> hpcRelativeDir
885
886
pkgDirs <- Map. keys . bcPackages <$> asks getBuildConfig
886
887
let args =
888
+ -- Use index files from all packages (allows cross-package
889
+ -- coverage results).
887
890
concatMap (\ x -> [" --srcdir" , toFilePath x]) pkgDirs ++
888
- [" --hpcdir" , toFilePath hpcRelDir, " --reset-hpcdirs" ]
891
+ -- Look for index files in the correct dir (relative to
892
+ -- each pkgdir).
893
+ [" --hpcdir" , toFilePath hpcRelDir, " --reset-hpcdirs"
894
+ -- Restrict to just the current library code (see #634 -
895
+ -- this will likely be customizable in the future)
896
+ ," --include" , T. unpack (pkgId <> " :" )]
889
897
tixFile <- parseRelFile (T. unpack testName ++ " .tix" )
890
898
let tixFileAbs = hpcDir </> tixFile
891
899
tixFileExists <- fileExists tixFileAbs
0 commit comments