From 530e3edc0f734dea454c7a542ca4e59a03cbe3fe Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 11 Jan 2011 18:29:38 -0800 Subject: test-pandoc: More informative diff output on test failure. Now the test suite tells you the exact command that was run, and the file containing the expected output. --- tests/test-pandoc.hs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'tests/test-pandoc.hs') diff --git a/tests/test-pandoc.hs b/tests/test-pandoc.hs index ad581307b..586b807c2 100644 --- a/tests/test-pandoc.hs +++ b/tests/test-pandoc.hs @@ -27,13 +27,14 @@ pandocPath = ".." "dist" "build" "pandoc" "pandoc" data TestResult = TestPassed | TestError ExitCode - | TestFailed FilePath [(DI, String)] + | TestFailed String FilePath [(DI, String)] deriving (Eq) instance Show TestResult where show TestPassed = "PASSED" show (TestError ec) = "ERROR " ++ show ec - show (TestFailed f d) = f ++ "\n--- expected test result\n+++ actual test result\n" ++ showDiff d + show (TestFailed cmd file d) = cmd ++ "\n--- expected (" ++ file ++ ")" ++ + "\n+++ actual\n" ++ showDiff d showDiff :: [(DI, String)] -> String showDiff [] = "" @@ -173,7 +174,9 @@ testWithNormalize normalizer testname opts inp norm = testCase testname $ do (outputPath, hOut) <- openTempFile "" "pandoc-test" let inpPath = inp let normPath = norm - ph <- runProcess pandocPath ([inpPath] ++ ["--data-dir", ".."] ++ opts) Nothing + let options = ["--data-dir", ".."] ++ [inpPath] ++ opts + let cmd = pandocPath ++ " " ++ unwords options + ph <- runProcess pandocPath options Nothing (Just [("LANG","en_US.UTF-8"),("HOME", "./")]) Nothing (Just hOut) (Just stderr) ec <- waitForProcess ph result <- if ec == ExitSuccess @@ -183,7 +186,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 normPath $ getDiff (lines outputContents) (lines normContents) + else return $ TestFailed cmd normPath $ getDiff (lines outputContents) (lines normContents) else return $ TestError ec removeFile outputPath assertBool (show result) (result == TestPassed) -- cgit v1.2.3