diff options
author | John MacFarlane <jgm@berkeley.edu> | 2011-01-11 18:29:38 -0800 |
---|---|---|
committer | Nathan Gass <gass@search.ch> | 2011-01-12 11:35:49 +0100 |
commit | 530e3edc0f734dea454c7a542ca4e59a03cbe3fe (patch) | |
tree | ba1a17e0a181d734a42ac7c8453f1d81d014408e /tests | |
parent | 046c9c7d3b1c928b003497e05038e1cdaee85e50 (diff) | |
download | pandoc-530e3edc0f734dea454c7a542ca4e59a03cbe3fe.tar.gz |
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.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-pandoc.hs | 11 |
1 files changed, 7 insertions, 4 deletions
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) |