@@ -73,20 +73,16 @@ mixDir
73
73
-- ^ \"dist/\" prefix
74
74
-> Way
75
75
-> FilePath
76
- -- ^ Component name
77
- -> FilePath
78
76
-- ^ 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"
80
78
81
79
tixDir
82
80
:: FilePath
83
81
-- ^ \"dist/\" prefix
84
82
-> Way
85
83
-> FilePath
86
- -- ^ Component name
87
- -> FilePath
88
84
-- ^ 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"
90
86
91
87
-- | Path to the .tix file containing a test suite's sum statistics.
92
88
tixFilePath
@@ -97,17 +93,15 @@ tixFilePath
97
93
-- ^ Component name
98
94
-> FilePath
99
95
-- ^ 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"
101
97
102
98
htmlDir
103
99
:: FilePath
104
100
-- ^ \"dist/\" prefix
105
101
-> Way
106
102
-> FilePath
107
- -- ^ Component name
108
- -> FilePath
109
103
-- ^ 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"
111
105
112
106
-- | Attempt to guess the way the test suites in this package were compiled
113
107
-- and linked with the library so the correct module interfaces are found.
@@ -139,7 +133,7 @@ markupTest verbosity lbi testDistPref libraryName suite library = do
139
133
hpcProgram
140
134
anyVersion
141
135
(withPrograms lbi)
142
- let htmlDir_ = htmlDir testDistPref way testName'
136
+ let htmlDir_ = htmlDir testDistPref way
143
137
markup
144
138
hpc
145
139
hpcVer
@@ -156,8 +150,9 @@ markupTest verbosity lbi testDistPref libraryName suite library = do
156
150
way = guessWay lbi
157
151
testName' = unUnqualComponentName $ testName suite
158
152
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
161
156
]
162
157
163
158
-- | Generate the HTML markup for all of a package's test suites.
@@ -169,8 +164,8 @@ markupPackage
169
164
-> PD. PackageDescription
170
165
-> [TestSuite ]
171
166
-> 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
174
169
tixFilesExist <- traverse doesFileExist tixFiles
175
170
when (and tixFilesExist) $ do
176
171
-- behaviour of 'markup' depends on version, so we need *a* version
@@ -181,8 +176,8 @@ markupPackage verbosity lbi distPref pkg_descr suites = do
181
176
hpcProgram
182
177
anyVersion
183
178
(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
186
181
excluded = concatMap testModules suites ++ [main]
187
182
createDirectoryIfMissing True $ takeDirectory outFile
188
183
union hpc verbosity tixFiles outFile excluded
@@ -194,19 +189,19 @@ markupPackage verbosity lbi distPref pkg_descr suites = do
194
189
where
195
190
way = guessWay lbi
196
191
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
199
194
libraryName = prettyShow $ PD. package pkg_descr
200
195
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.
203
198
--
204
199
-- 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
210
205
where
211
206
-- This is a hack for HPC over test suites, needed to match the directory
212
207
-- where HPC saves and reads .mix files when the main library of the same
@@ -218,16 +213,26 @@ pathToMainLibHpc distPref = distPrefBuild
218
213
-- both @hpc@ and @ghc@. For non-default optimization levels, the path
219
214
-- suffix is one element longer and the extra path element needs
220
215
-- 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
223
218
[" t" , _, " noopt" ] ->
224
219
joinPath $
225
220
take (length distPrefElements - 3 ) distPrefElements
221
+ ++ [distSuffixInternalLib]
226
222
++ [" noopt" ]
227
223
[" t" , _, " opt" ] ->
228
224
joinPath $
229
225
take (length distPrefElements - 3 ) distPrefElements
226
+ ++ [distSuffixInternalLib]
230
227
++ [" opt" ]
231
228
[_, " 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