Skip to content

Commit 7cd791e

Browse files
committed
Fix test coverage bug on windows
Caught due to the multi-test integration test
1 parent 1d18803 commit 7cd791e

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

src/Stack/Build/Execute.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ singleTest runInBase topts testsToRun ac ee task installedMap = do
12531253
-- directory into the hpc work dir, for
12541254
-- tidiness.
12551255
when needHpc $
1256-
updateTixFile (packageName package) tixPath
1256+
updateTixFile (packageName package) tixPath testName'
12571257
return $ case ec of
12581258
ExitSuccess -> Map.empty
12591259
_ -> Map.singleton testName $ Just ec

src/Stack/Coverage.hs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,24 +66,21 @@ deleteHpcReports = do
6666
-- | Move a tix file into a sub-directory of the hpc report directory. Deletes the old one if one is
6767
-- present.
6868
updateTixFile :: (MonadIO m,MonadReader env m,HasConfig env,MonadLogger m,MonadBaseControl IO m,MonadCatch m,HasEnvConfig env)
69-
=> PackageName -> Path Abs File -> m ()
70-
updateTixFile pkgName tixSrc = do
71-
case stripSuffix ".tix" (toFilePath (filename tixSrc)) of
72-
Nothing -> error "Invariant violated: updateTixFile expected a tix filepath."
73-
Just testName -> do
74-
exists <- fileExists tixSrc
75-
when exists $ do
76-
tixDest <- tixFilePath pkgName testName
77-
removeFileIfExists tixDest
78-
createTree (parent tixDest)
79-
-- Remove exe modules because they are problematic. This could be revisited if there's a GHC
80-
-- version that fixes https://ghc.haskell.org/trac/ghc/ticket/1853
81-
mtix <- readTixOrLog tixSrc
82-
case mtix of
83-
Nothing -> $logError $ "Failed to read " <> T.pack (toFilePath tixSrc)
84-
Just tix -> do
85-
liftIO $ writeTix (toFilePath tixDest) (removeExeModules tix)
86-
removeFileIfExists tixSrc
69+
=> PackageName -> Path Abs File -> String -> m ()
70+
updateTixFile pkgName tixSrc testName = do
71+
exists <- fileExists tixSrc
72+
when exists $ do
73+
tixDest <- tixFilePath pkgName testName
74+
removeFileIfExists tixDest
75+
createTree (parent tixDest)
76+
-- Remove exe modules because they are problematic. This could be revisited if there's a GHC
77+
-- version that fixes https://ghc.haskell.org/trac/ghc/ticket/1853
78+
mtix <- readTixOrLog tixSrc
79+
case mtix of
80+
Nothing -> $logError $ "Failed to read " <> T.pack (toFilePath tixSrc)
81+
Just tix -> do
82+
liftIO $ writeTix (toFilePath tixDest) (removeExeModules tix)
83+
removeFileIfExists tixSrc
8784

8885
testExeName :: (MonadReader env m,HasConfig env) => String -> m String
8986
testExeName testName = do

0 commit comments

Comments
 (0)