@@ -76,31 +76,7 @@ mixDir
76
76
-- ^ Component name
77
77
-> FilePath
78
78
-- ^ Directory containing test suite's .mix files
79
- mixDir distPref way name = hpcDir distPrefBuild way </> " mix" </> name
80
- where
81
- -- This is a hack for HPC over test suites, needed to match the directory
82
- -- where HPC saves and reads .mix files when the main library of the same
83
- -- package is being processed, perhaps in a previous cabal run (#5213).
84
- -- E.g., @distPref@ may be
85
- -- @./dist-newstyle/build/x86_64-linux/ghc-9.0.1/cabal-gh5213-0.1/t/tests@
86
- -- but the path where library mix files reside has two less components
87
- -- at the end (@t/tests@) and this reduced path needs to be passed to
88
- -- both @hpc@ and @ghc@. For non-default optimization levels, the path
89
- -- suffix is one element longer and the extra path element needs
90
- -- to be preserved.
91
- distPrefElements = splitDirectories distPref
92
- distPrefBuild = case drop (length distPrefElements - 3 ) distPrefElements of
93
- [" t" , _, " noopt" ] ->
94
- joinPath $
95
- take (length distPrefElements - 3 ) distPrefElements
96
- ++ [" noopt" ]
97
- [" t" , _, " opt" ] ->
98
- joinPath $
99
- take (length distPrefElements - 3 ) distPrefElements
100
- ++ [" opt" ]
101
- [_, " t" , _] ->
102
- joinPath $ take (length distPrefElements - 2 ) distPrefElements
103
- _ -> distPref
79
+ mixDir distPref way name = hpcDir distPref way </> " mix" </> name
104
80
105
81
tixDir
106
82
:: FilePath
@@ -146,14 +122,14 @@ markupTest
146
122
:: Verbosity
147
123
-> LocalBuildInfo
148
124
-> FilePath
149
- -- ^ \"dist/\" prefix
125
+ -- ^ Testsuite \"dist/\" prefix
150
126
-> String
151
127
-- ^ Library name
152
128
-> TestSuite
153
129
-> Library
154
130
-> IO ()
155
- markupTest verbosity lbi distPref libraryName suite library = do
156
- tixFileExists <- doesFileExist $ tixFilePath distPref way $ testName'
131
+ markupTest verbosity lbi testDistPref libraryName suite library = do
132
+ tixFileExists <- doesFileExist $ tixFilePath testDistPref way $ testName'
157
133
when tixFileExists $ do
158
134
-- behaviour of 'markup' depends on version, so we need *a* version
159
135
-- but no particular one
@@ -163,12 +139,12 @@ markupTest verbosity lbi distPref libraryName suite library = do
163
139
hpcProgram
164
140
anyVersion
165
141
(withPrograms lbi)
166
- let htmlDir_ = htmlDir distPref way testName'
142
+ let htmlDir_ = htmlDir testDistPref way testName'
167
143
markup
168
144
hpc
169
145
hpcVer
170
146
verbosity
171
- (tixFilePath distPref way testName')
147
+ (tixFilePath testDistPref way testName')
172
148
mixDirs
173
149
htmlDir_
174
150
(exposedModules library)
@@ -179,14 +155,17 @@ markupTest verbosity lbi distPref libraryName suite library = do
179
155
where
180
156
way = guessWay lbi
181
157
testName' = unUnqualComponentName $ testName suite
182
- mixDirs = map (mixDir distPref way) [testName', libraryName]
158
+ mixDirs =
159
+ [ mixDir testDistPref way testName'
160
+ , mixDir (pathToMainLibHpc testDistPref) way libraryName
161
+ ]
183
162
184
163
-- | Generate the HTML markup for all of a package's test suites.
185
164
markupPackage
186
165
:: Verbosity
187
166
-> LocalBuildInfo
188
167
-> FilePath
189
- -- ^ \"dist/\" prefix
168
+ -- ^ Testsuite \"dist/\" prefix
190
169
-> PD. PackageDescription
191
170
-> [TestSuite ]
192
171
-> IO ()
@@ -215,6 +194,40 @@ markupPackage verbosity lbi distPref pkg_descr suites = do
215
194
where
216
195
way = guessWay lbi
217
196
testNames = fmap (unUnqualComponentName . testName) suites
218
- mixDirs = map (mixDir distPref way) $ libraryName : testNames
197
+ mixDirs = mixDir (pathToMainLibHpc distPref) way libraryName : map (mixDir distPref way) testNames
219
198
included = concatMap (exposedModules) $ PD. allLibraries pkg_descr
220
199
libraryName = prettyShow $ PD. package pkg_descr
200
+
201
+ -- | A (non-exported) hack to determine the path to the main-lib hpc directory
202
+ -- given the testsuite's dist prefix.
203
+ --
204
+ -- 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
210
+ where
211
+ -- This is a hack for HPC over test suites, needed to match the directory
212
+ -- where HPC saves and reads .mix files when the main library of the same
213
+ -- package is being processed, perhaps in a previous cabal run (#5213).
214
+ -- E.g., @distPref@ may be
215
+ -- @./dist-newstyle/build/x86_64-linux/ghc-9.0.1/cabal-gh5213-0.1/t/tests@
216
+ -- but the path where library mix files reside has two less components
217
+ -- at the end (@t/tests@) and this reduced path needs to be passed to
218
+ -- both @hpc@ and @ghc@. For non-default optimization levels, the path
219
+ -- suffix is one element longer and the extra path element needs
220
+ -- to be preserved.
221
+ distPrefElements = splitDirectories distPref
222
+ distPrefBuild = case drop (length distPrefElements - 3 ) distPrefElements of
223
+ [" t" , _, " noopt" ] ->
224
+ joinPath $
225
+ take (length distPrefElements - 3 ) distPrefElements
226
+ ++ [" noopt" ]
227
+ [" t" , _, " opt" ] ->
228
+ joinPath $
229
+ take (length distPrefElements - 3 ) distPrefElements
230
+ ++ [" opt" ]
231
+ [_, " t" , _] ->
232
+ joinPath $ take (length distPrefElements - 2 ) distPrefElements
233
+ _ -> distPref
0 commit comments