From 90d8c55f2416e9c04127596838e101c8a19580f8 Mon Sep 17 00:00:00 2001 From: David Waern Date: Sun, 6 Sep 2009 21:11:38 +0000 Subject: Use colordiff to display test results if available --- tests/runtests.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'tests/runtests.hs') diff --git a/tests/runtests.hs b/tests/runtests.hs index 6cec7cb4..e4d676b3 100644 --- a/tests/runtests.hs +++ b/tests/runtests.hs @@ -9,7 +9,9 @@ import Control.Monad import Text.Printf import Text.Regex import Distribution.Simple.Utils +import Distribution.Simple.Program import Distribution.Verbosity +import Data.Maybe main = do @@ -22,6 +24,11 @@ haddockEq file1 file2 = stripLinks file1 == stripLinks file2 stripLinks f = subRegex (mkRegexWithOpts "]*>" False False) f "" +programOnPath p = do + result <- findProgramOnPath p silent + return (isJust result) + + check modules strict = do forM_ modules $ \mod -> do let outfile = "output" (dropExtension mod ++ ".html") @@ -35,7 +42,10 @@ check modules strict = do if not $ haddockEq out ref then do putStrLn $ "Output for " ++ mod ++ " has changed! Exiting with diff:" - system $ "diff " ++ reffile ++ " " ++ outfile + b <- programOnPath "colordiff" + if b + then system $ "colordiff " ++ reffile ++ " " ++ outfile + else system $ "diff " ++ reffile ++ " " ++ outfile if strict then exitFailure else return () else do putStrLn $ "Pass: " ++ mod -- cgit v1.2.3