From 715e33705f9c857c1bfd82f1f333b381d62feed4 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 11 Jan 2011 18:02:50 -0800 Subject: [PATCH] test-pandoc: More diff-like diffs in case of test failure. --- tests/test-pandoc.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/test-pandoc.hs b/tests/test-pandoc.hs index c7ec67705..0c70760dc 100644 --- a/tests/test-pandoc.hs +++ b/tests/test-pandoc.hs @@ -27,18 +27,18 @@ pandocPath = ".." "dist" "build" "pandoc" "pandoc" data TestResult = TestPassed | TestError ExitCode - | TestFailed [(DI, String)] + | TestFailed FilePath [(DI, String)] deriving (Eq) instance Show TestResult where show TestPassed = "PASSED" show (TestError ec) = "ERROR " ++ show ec - show (TestFailed d) = "FAILED\n" ++ showDiff d + show (TestFailed f d) = f ++ "\n--- expected test result\n+++ actual test result\n" ++ showDiff d showDiff :: [(DI, String)] -> String showDiff [] = "" -showDiff ((F, ln) : ds) = "|TEST| " ++ ln ++ "\n" ++ showDiff ds -showDiff ((S, ln) : ds) = "|NORM| " ++ ln ++ "\n" ++ showDiff ds +showDiff ((F, ln) : ds) = "- " ++ ln ++ "\n" ++ showDiff ds +showDiff ((S, ln) : ds) = "+ " ++ ln ++ "\n" ++ showDiff ds showDiff ((B, _ ) : ds) = showDiff ds tests :: [Test] @@ -183,7 +183,7 @@ testWithNormalize normalizer testname opts inp norm = testCase testname $ do normContents <- readFile' normPath >>= return . filter (/='\r') . normalizer if outputContents == normContents then return TestPassed - else return $ TestFailed $ getDiff (lines outputContents) (lines normContents) + else return $ TestFailed normPath $ getDiff (lines outputContents) (lines normContents) else return $ TestError ec removeFile outputPath assertBool (show result) (result == TestPassed)