aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDavid Waern <david.waern@gmail.com>2009-09-06 21:11:38 +0000
committerDavid Waern <david.waern@gmail.com>2009-09-06 21:11:38 +0000
commit90d8c55f2416e9c04127596838e101c8a19580f8 (patch)
tree3fd94f1546d80b7198e5a5be5b8b79812afdb36e /tests
parentca0fb976d773c8bb1b4710ff1e32bb3363b6c4f0 (diff)
Use colordiff to display test results if available
Diffstat (limited to 'tests')
-rw-r--r--tests/runtests.hs12
1 files changed, 11 insertions, 1 deletions
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 "<A HREF=[^>]*>" False False) f "<A HREF=\"\">"
+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