[commit: packages/hpc] wip/T9619: Allow same `Mix` file in different dirs (#9619) (361a019)
git at git.haskell.org
git at git.haskell.org
Fri Mar 6 19:50:46 UTC 2015
Repository : ssh://git@git.haskell.org/hpc
On branch : wip/T9619
Link : http://git.haskell.org/packages/hpc.git/commitdiff/361a0196569d5a013ad73fb607ec50ca896af2a2
>---------------------------------------------------------------
commit 361a0196569d5a013ad73fb607ec50ca896af2a2
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date: Thu Mar 5 21:43:36 2015 +0100
Allow same `Mix` file in different dirs (#9619)
>---------------------------------------------------------------
361a0196569d5a013ad73fb607ec50ca896af2a2
Trace/Hpc/Mix.hs | 12 ++++++++----
tests/T9619.hs | 1 +
tests/all.T | 16 ++++++++++++++++
3 files changed, 25 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/T9619.hs b/tests/T9619.hs
new file mode 100644
index 0000000..b3549c2
--- /dev/null
+++ b/tests/T9619.hs
@@ -0,0 +1 @@
+main = return ()
diff --git a/tests/all.T b/tests/all.T
new file mode 100644
index 0000000..b0bb743
--- /dev/null
+++ b/tests/all.T
@@ -0,0 +1,16 @@
+# Do not explicitly specify '-fhpc' in extra_hc_opts, without also setting
+# '-hpcdir' to a different value for each test. Only the `hpc` way does this
+# automatically. This way the tests in this directory can be run concurrently
+# (Main.mix might overlap otherwise).
+
+setTestOpts([only_compiler_types(['ghc']),
+ only_ways(['hpc']),
+ ])
+
+def T9619(cmd):
+ # Having the same mix file in two different hpcdirs should work (exit code 0).
+ return(cmd + " && cp -R .hpc.T9619 .hpc.T9619b && " +
+ "{hpc} report T9619.tix --hpcdir=.hpc.T9619 --hpcdir=.hpc.T9619b")
+test('T9619', [cmd_wrapper(T9619), ignore_output,
+ extra_clean(['.hpc.T9619b/Main.mix', '.hpc.T9619b'])],
+ compile_and_run, [''])
More information about the ghc-commits
mailing list