@@ -73,20 +73,16 @@ mixDir
7373 -- ^ \"dist/\" prefix
7474 -> Way
7575 -> FilePath
76- -- ^ Component name
77- -> FilePath
7876 -- ^ Directory containing test suite's .mix files
79- mixDir distPref way name = hpcDir distPref way </> " mix" </> name
77+ mixDir distPref way = hpcDir distPref way </> " mix"
8078
8179tixDir
8280 :: FilePath
8381 -- ^ \"dist/\" prefix
8482 -> Way
8583 -> FilePath
86- -- ^ Component name
87- -> FilePath
8884 -- ^ Directory containing test suite's .tix files
89- tixDir distPref way name = hpcDir distPref way </> " tix" </> name
85+ tixDir distPref way = hpcDir distPref way </> " tix"
9086
9187-- | Path to the .tix file containing a test suite's sum statistics.
9288tixFilePath
@@ -97,17 +93,15 @@ tixFilePath
9793 -- ^ Component name
9894 -> FilePath
9995 -- ^ Path to test suite's .tix file
100- tixFilePath distPref way name = tixDir distPref way name </> name <.> " tix"
96+ tixFilePath distPref way name = tixDir distPref way </> name <.> " tix"
10197
10298htmlDir
10399 :: FilePath
104100 -- ^ \"dist/\" prefix
105101 -> Way
106102 -> FilePath
107- -- ^ Component name
108- -> FilePath
109103 -- ^ Path to test suite's HTML markup directory
110- htmlDir distPref way name = hpcDir distPref way </> " html" </> name
104+ htmlDir distPref way = hpcDir distPref way </> " html"
111105
112106-- | Attempt to guess the way the test suites in this package were compiled
113107-- and linked with the library so the correct module interfaces are found.
@@ -139,7 +133,7 @@ markupTest verbosity lbi testDistPref libraryName suite library = do
139133 hpcProgram
140134 anyVersion
141135 (withPrograms lbi)
142- let htmlDir_ = htmlDir testDistPref way testName'
136+ let htmlDir_ = htmlDir testDistPref way
143137 markup
144138 hpc
145139 hpcVer
@@ -156,8 +150,9 @@ markupTest verbosity lbi testDistPref libraryName suite library = do
156150 way = guessWay lbi
157151 testName' = unUnqualComponentName $ testName suite
158152 mixDirs =
159- [ mixDir testDistPref way testName'
160- , mixDir (pathToMainLibHpc testDistPref) way libraryName
153+ [ mixDir testDistPref way
154+ , mixDir (pathToLibHpc testDistPref (PD. libName library)) way
155+ -- nonIndefiniteLibraries
161156 ]
162157
163158-- | Generate the HTML markup for all of a package's test suites.
@@ -169,8 +164,8 @@ markupPackage
169164 -> PD. PackageDescription
170165 -> [TestSuite ]
171166 -> IO ()
172- markupPackage verbosity lbi distPref pkg_descr suites = do
173- let tixFiles = map (tixFilePath distPref way) testNames
167+ markupPackage verbosity lbi testDistPref pkg_descr suites = do
168+ let tixFiles = map (tixFilePath testDistPref way) testNames
174169 tixFilesExist <- traverse doesFileExist tixFiles
175170 when (and tixFilesExist) $ do
176171 -- behaviour of 'markup' depends on version, so we need *a* version
@@ -181,8 +176,8 @@ markupPackage verbosity lbi distPref pkg_descr suites = do
181176 hpcProgram
182177 anyVersion
183178 (withPrograms lbi)
184- let outFile = tixFilePath distPref way libraryName
185- htmlDir' = htmlDir distPref way libraryName
179+ let outFile = tixFilePath testDistPref way libraryName
180+ htmlDir' = htmlDir testDistPref way
186181 excluded = concatMap testModules suites ++ [main]
187182 createDirectoryIfMissing True $ takeDirectory outFile
188183 union hpc verbosity tixFiles outFile excluded
@@ -194,19 +189,19 @@ markupPackage verbosity lbi distPref pkg_descr suites = do
194189 where
195190 way = guessWay lbi
196191 testNames = fmap (unUnqualComponentName . testName) suites
197- mixDirs = mixDir (pathToMainLibHpc distPref) way libraryName : map (mixDir distPref way) testNames
198- included = concatMap (exposedModules) $ PD. allLibraries pkg_descr
192+ mixDirs = mixDir testDistPref way : map (( ` mixDir` way) . pathToLibHpc testDistPref . PD. libName) ( PD. allLibraries pkg_descr)
193+ included = concatMap (exposedModules) $ nonIndefiniteLibraries pkg_descr
199194 libraryName = prettyShow $ PD. package pkg_descr
200195
201- -- | A (non-exported) hack to determine the path to the main-lib hpc directory
202- -- given the testsuite's dist prefix.
196+ -- | A (non-exported) hack to determine the path to the main and internal libs
197+ -- directory given the testsuite's dist prefix.
203198--
204199-- We use this function when constructing calls to `hpc markup` since otherwise
205- -- having cabal-install communicate the path to the main lib dist-dir when
206- -- building the test component, via the Setup.hs interface, is far more
207- -- complicated.
208- pathToMainLibHpc :: FilePath -> FilePath
209- pathToMainLibHpc distPref = distPrefBuild
200+ -- having cabal-install communicate the path to the main and sub libraries
201+ -- dist-dir when building the test component, via the Setup.hs interface, is
202+ -- far more complicated.
203+ pathToLibHpc :: FilePath -> PD. LibraryName -> FilePath
204+ pathToLibHpc testDistPref libname = distPrefLib
210205 where
211206 -- This is a hack for HPC over test suites, needed to match the directory
212207 -- where HPC saves and reads .mix files when the main library of the same
@@ -218,16 +213,26 @@ pathToMainLibHpc distPref = distPrefBuild
218213 -- both @hpc@ and @ghc@. For non-default optimization levels, the path
219214 -- suffix is one element longer and the extra path element needs
220215 -- to be preserved.
221- distPrefElements = splitDirectories distPref
222- distPrefBuild = case drop (length distPrefElements - 3 ) distPrefElements of
216+ distPrefElements = splitDirectories testDistPref
217+ distPrefLib = case drop (length distPrefElements - 3 ) distPrefElements of
223218 [" t" , _, " noopt" ] ->
224219 joinPath $
225220 take (length distPrefElements - 3 ) distPrefElements
221+ ++ [distSuffixInternalLib]
226222 ++ [" noopt" ]
227223 [" t" , _, " opt" ] ->
228224 joinPath $
229225 take (length distPrefElements - 3 ) distPrefElements
226+ ++ [distSuffixInternalLib]
230227 ++ [" opt" ]
231228 [_, " t" , _] ->
232- joinPath $ take (length distPrefElements - 2 ) distPrefElements
233- _ -> distPref
229+ joinPath $
230+ take (length distPrefElements - 2 ) distPrefElements
231+ ++ [distSuffixInternalLib]
232+ _ -> error " pathToLibHpc: Expecting `testDirPref` to be the dist prefix of a test-suite component"
233+ distSuffixInternalLib = case libname of
234+ PD. LMainLibName -> " "
235+ PD. LSubLibName slname -> " l" </> unUnqualComponentName slname
236+
237+ nonIndefiniteLibraries :: PD. PackageDescription -> [Library ]
238+ nonIndefiniteLibraries = PD. allLibraries
0 commit comments