@@ -177,12 +177,7 @@ listPackageSourcesOrdinary verbosity pkg_descr pps =
177177 case testInterface t of
178178 TestSuiteExeV10 _ mainPath -> do
179179 biSrcs <- allSourcesBuildInfo bi pps []
180- srcMainFile <- do
181- ppFile <- findFileWithExtension (ppSuffixes pps)
182- (hsSourceDirs bi) (dropExtension mainPath)
183- case ppFile of
184- Nothing -> findFile (hsSourceDirs bi) mainPath
185- Just pp -> return pp
180+ srcMainFile <- findMainExeFile bi pps mainPath
186181 return (srcMainFile: biSrcs)
187182 TestSuiteLibV09 _ m ->
188183 allSourcesBuildInfo bi pps [m]
@@ -196,12 +191,7 @@ listPackageSourcesOrdinary verbosity pkg_descr pps =
196191 case benchmarkInterface bm of
197192 BenchmarkExeV10 _ mainPath -> do
198193 biSrcs <- allSourcesBuildInfo bi pps []
199- srcMainFile <- do
200- ppFile <- findFileWithExtension (ppSuffixes pps)
201- (hsSourceDirs bi) (dropExtension mainPath)
202- case ppFile of
203- Nothing -> findFile (hsSourceDirs bi) mainPath
204- Just pp -> return pp
194+ srcMainFile <- findMainExeFile bi pps mainPath
205195 return (srcMainFile: biSrcs)
206196 BenchmarkUnsupported tp -> die $ " Unsupported benchmark type: "
207197 ++ show tp
@@ -427,6 +417,9 @@ allSourcesBuildInfo bi pps modules = do
427417 let searchDirs = hsSourceDirs bi
428418 sources <- fmap concat $ sequenceA $
429419 [ let file = ModuleName. toFilePath module_
420+ -- NB: *Not* findFileWithExtension, because the same source
421+ -- file may show up in multiple paths due to a conditional;
422+ -- we need to package all of them. See #367.
430423 in findAllFilesWithExtension suffixes searchDirs file
431424 >>= nonEmpty (notFound module_) return
432425 | module_ <- modules ++ otherModules bi ]
0 commit comments