diff --git a/testsuite/tests/hpc/.hpc.T10138/Main.mix b/testsuite/tests/hpc/.hpc.T10138/Main.mix new file mode 100644 index 0000000000000000000000000000000000000000..26611fef243b96905ec125581274f01b3d53c0ce --- /dev/null +++ b/testsuite/tests/hpc/.hpc.T10138/Main.mix @@ -0,0 +1 @@ +Mix "T10138.hs" 2015-03-09 18:22:16.403500034 UTC 2143033233 8 [(1:15-1:16,ExpBox False),(1:8-1:16,ExpBox False),(1:1-1:16,TopLevelBox ["main"])] diff --git a/testsuite/tests/hpc/T10138.tix b/testsuite/tests/hpc/T10138.tix new file mode 100644 index 0000000000000000000000000000000000000000..f348f7089ea1fce249ed3d7f7f3f54e473088549 --- /dev/null +++ b/testsuite/tests/hpc/T10138.tix @@ -0,0 +1 @@ +Tix [ TixModule "Main" 2143033233 3 [0,1,1]] diff --git a/testsuite/tests/hpc/all.T b/testsuite/tests/hpc/all.T index d279018025157d9348927a0dbb931e250f8a156e..0289733b50d39beff69231bf339c4cb8e8401d78 100644 --- a/testsuite/tests/hpc/all.T +++ b/testsuite/tests/hpc/all.T @@ -1,8 +1,13 @@ +test('T10138', ignore_output, run_command, + # Using --hpcdir with an absolute path should work (exit code 0). + ['{hpc} report T10138.tix --hpcdir="`pwd`/.hpc.T10138"']) + +# Run tests below only for the hpc way. +# # Do not explicitly specify '-fhpc' in extra_hc_opts, unless 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']), ]) diff --git a/utils/hpc/HpcFlags.hs b/utils/hpc/HpcFlags.hs index 017030986ae00c142a3c2f2153bb4e341c5b1a17..dd1d9f7260adec8a0928dcbeb3e7974cca7cb603 100644 --- a/utils/hpc/HpcFlags.hs +++ b/utils/hpc/HpcFlags.hs @@ -8,6 +8,7 @@ import Data.Char import Trace.Hpc.Tix import Trace.Hpc.Mix import System.Exit +import System.FilePath data Flags = Flags { outputFile :: String @@ -154,7 +155,7 @@ unionModuleOpt = noArg "union" ------------------------------------------------------------------------------- readMixWithFlags :: Flags -> Either String TixModule -> IO Mix -readMixWithFlags flags modu = readMix [ dir ++ "/" ++ hpcDir +readMixWithFlags flags modu = readMix [ dir hpcDir | dir <- srcDirs flags , hpcDir <- hpcDirs flags ] modu diff --git a/utils/hpc/HpcMarkup.hs b/utils/hpc/HpcMarkup.hs index 1373bfbee5701426d2c4c2a83260aa13d1584753..31327fc991477b5f4b6c931ab5c402bed77a3319 100644 --- a/utils/hpc/HpcMarkup.hs +++ b/utils/hpc/HpcMarkup.hs @@ -13,6 +13,7 @@ import HpcFlags import HpcUtils import System.Directory +import System.FilePath import System.IO (localeEncoding) import Data.List import Data.Maybe(fromJust) @@ -78,9 +79,9 @@ markup_main flags (prog:modNames) = do let mods' = sortBy cmp mods unless (verbosity flags < Normal) $ - putStrLn $ "Writing: " ++ (filename ++ ".html") + putStrLn $ "Writing: " ++ (filename <.> "html") - writeFileUsing (dest_dir ++ "/" ++ filename ++ ".html") $ + writeFileUsing (dest_dir filename <.> "html") $ "" ++ "" ++ charEncodingTag ++ @@ -224,10 +225,10 @@ genHtmlFromMod dest_dir flags tix theFunTotals invertOutput = do let content' = markup tabStop info content let addLine n xs = "" ++ padLeft 5 ' ' (show n) ++ " " ++ xs let addLines = unlines . map (uncurry addLine) . zip [1 :: Int ..] . lines - let fileName = modName0 ++ ".hs.html" + let fileName = modName0 <.> "hs" <.> "html" unless (verbosity flags < Normal) $ putStrLn $ "Writing: " ++ fileName - writeFileUsing (dest_dir ++ "/" ++ fileName) $ + writeFileUsing (dest_dir fileName) $ unlines ["", "", charEncodingTag, diff --git a/utils/hpc/HpcUtils.hs b/utils/hpc/HpcUtils.hs index 4f98556176b8f024f9abb2de77b1207e453f033c..6ee44b1ae61945daa5ff56c7852ac8981d955979 100644 --- a/utils/hpc/HpcUtils.hs +++ b/utils/hpc/HpcUtils.hs @@ -2,6 +2,7 @@ module HpcUtils where import Trace.Hpc.Util import qualified Data.Map as Map +import System.FilePath dropWhileEndLE :: (a -> Bool) -> [a] -> [a] -- Spec: dropWhileEndLE p = reverse . dropWhile p . reverse @@ -30,6 +31,6 @@ readFileFromPath err filename path0 = readTheFile path0 readTheFile [] = err $ "could not find " ++ show filename ++ " in path " ++ show path0 readTheFile (dir:dirs) = - catchIO (do str <- readFile (dir ++ "/" ++ filename) + catchIO (do str <- readFile (dir filename) return str) (\ _ -> readTheFile dirs) diff --git a/utils/hpc/hpc-bin.cabal b/utils/hpc/hpc-bin.cabal index 8ec6e5b7904eb9bbe1cee2338717f11da0064002..0257fb99c7dfca29fdd712b10f03489fe3c39a31 100644 --- a/utils/hpc/hpc-bin.cabal +++ b/utils/hpc/hpc-bin.cabal @@ -43,6 +43,7 @@ Executable hpc if flag(base3) || flag(base4) Build-Depends: directory >= 1 && < 1.3, + filepath >= 1 && < 1.5, containers >= 0.1 && < 0.6, array >= 0.1 && < 0.6 Build-Depends: hpc