[commit: packages/hpc] wip/T9619: Allow same `Mix` file in different dirs (#9619) (6857115)
git at git.haskell.org
git at git.haskell.org
Mon Mar 9 19:07:45 UTC 2015
Repository : ssh://git@git.haskell.org/hpc
On branch : wip/T9619
Link : http://git.haskell.org/packages/hpc.git/commitdiff/6857115fb24862cb5ac11615fe14849dc869f42f
>---------------------------------------------------------------
commit 6857115fb24862cb5ac11615fe14849dc869f42f
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date: Thu Mar 5 21:43:36 2015 +0100
Allow same `Mix` file in different dirs (#9619)
>---------------------------------------------------------------
6857115fb24862cb5ac11615fe14849dc869f42f
Trace/Hpc/Mix.hs | 12 ++++++++----
tests/simple/tixs/{.hpc => .hpc.copy}/Main.mix | 0
tests/simple/tixs/test.T | 4 ++++
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/Trace/Hpc/Mix.hs b/Trace/Hpc/Mix.hs
index 4a7fc74..f4025d9 100644
--- a/Trace/Hpc/Mix.hs
+++ b/Trace/Hpc/Mix.hs
@@ -49,7 +49,7 @@ data Mix = Mix
Hash -- hash of mix entry + timestamp
Int -- tab stop value.
[MixEntry] -- entries
- deriving (Show,Read)
+ deriving (Show,Read,Eq)
type MixEntry = (HpcPos, BoxLabel)
@@ -104,9 +104,13 @@ readMix dirNames mod' = do
| dirName <- dirNames
]
case catMaybes res of
- [r] -> return r
- xs@(_:_) -> error $ "found " ++ show(length xs) ++ " instances of " ++ modName ++ " in " ++ show dirNames
- _ -> error $ "can not find " ++ modName ++ " in " ++ show dirNames
+ xs@(x:_:_) | any (/= x) (tail xs) ->
+ -- Only complain if multiple *different* `Mix` files with the
+ -- same name are found (#9619).
+ error $ "found " ++ show(length xs) ++ " different instances of "
+ ++ modName ++ " in " ++ show dirNames
+ (x:_) -> return x
+ _ -> error $ "can not find " ++ modName ++ " in " ++ show dirNames
mixName :: FilePath -> String -> String
mixName dirName name = dirName </> name <.> "mix"
diff --git a/tests/simple/tixs/.hpc/Main.mix b/tests/simple/tixs/.hpc.copy/Main.mix
similarity index 100%
copy from tests/simple/tixs/.hpc/Main.mix
copy to tests/simple/tixs/.hpc.copy/Main.mix
diff --git a/tests/simple/tixs/test.T b/tests/simple/tixs/test.T
index 48ca67f..8e98d0e 100644
--- a/tests/simple/tixs/test.T
+++ b/tests/simple/tixs/test.T
@@ -67,3 +67,7 @@ test('hpc_hand_overlay',
"{hpc} report total3.tix"])
test('hpc_bad_001', exit_code(1), run_command, ["{hpc} bad arguments"])
+
+test('T9619', ignore_output, run_command,
+ # Having the same mix file in two different hpcdirs should work.
+ ["{hpc} report hpc_sample.tix --hpcdir=.hpc --hpcdir=.hpc.copy"])
More information about the ghc-commits
mailing list