Skip to content

Commit

Permalink
fix HPC tests with GHC 7.10
Browse files Browse the repository at this point in the history
Starting with version 7.10, GHC puts the module interface (.mix) files
for each project in a subdirectory of -hpcdir named for the package
key. We must adjust the search path accordingly when checking for the
.mix file.
  • Loading branch information
ttuegel committed Mar 15, 2015
1 parent 25807be commit 1bda428
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions Cabal/tests/PackageTests/TestSuiteExeV10/Check.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ import Test.Framework (testGroup)
import Test.Framework.Providers.HUnit (hUnitTestToTests)
import Test.HUnit hiding ( path )

import Distribution.Compiler (CompilerFlavor(..), CompilerId(..))
import Distribution.PackageDescription (package)
import Distribution.Simple.Compiler (compilerId)
import Distribution.Simple.Configure (getPersistBuildConfig)
import Distribution.Simple.LocalBuildInfo (compiler, localPkgDescr, pkgKey)
import Distribution.Simple.Hpc
import Distribution.Simple.Program.Builtin (hpcProgram)
import Distribution.Simple.Program.Db
( emptyProgramDb, configureProgram, requireProgramVersion )
import Distribution.Text (display)
import qualified Distribution.Verbosity as Verbosity
import Distribution.Version (Version(..), orLaterVersion)

Expand Down Expand Up @@ -70,16 +75,20 @@ checkTestWithHpc :: FilePath -> String -> [String] -> Test
checkTestWithHpc ghcPath name extraOpts = TestCase $ do
isCorrectVersion <- correctHpcVersion
when isCorrectVersion $ do
let distPref' = dir </> "dist-" ++ name
buildAndTest ghcPath name [] ("--enable-coverage" : extraOpts)
lbi <- getPersistBuildConfig (dir </> "dist-" ++ name)
lbi <- getPersistBuildConfig distPref'
let way = guessWay lbi
CompilerId comp version = compilerId (compiler lbi)
subdir
| comp == GHC && version >= Version [7, 10] [] =
display (pkgKey lbi)
| otherwise = display (package $ localPkgDescr lbi)
mapM_ shouldExist
[ mixDir (dir </> "dist-" ++ name) way "my-0.1"
</> "my-0.1" </> "Foo.mix"
, mixDir (dir </> "dist-" ++ name) way "test-Foo" </> "Main.mix"
, tixFilePath (dir </> "dist-" ++ name) way "test-Foo"
, htmlDir (dir </> "dist-" ++ name) way "test-Foo"
</> "hpc_index.html"
[ mixDir distPref' way "my-0.1" </> subdir </> "Foo.mix"
, mixDir distPref' way "test-Foo" </> "Main.mix"
, tixFilePath distPref' way "test-Foo"
, htmlDir distPref' way "test-Foo" </> "hpc_index.html"
]

-- | Ensures that even if -fhpc is manually provided no .tix file is output.
Expand Down

0 comments on commit 1bda428

Please sign in to comment.