test-pandoc: More diff-like diffs in case of test failure.
This commit is contained in:
parent
eb1d014859
commit
715e33705f
1 changed files with 5 additions and 5 deletions
|
@ -27,18 +27,18 @@ pandocPath = ".." </> "dist" </> "build" </> "pandoc" </> "pandoc"
|
||||||
|
|
||||||
data TestResult = TestPassed
|
data TestResult = TestPassed
|
||||||
| TestError ExitCode
|
| TestError ExitCode
|
||||||
| TestFailed [(DI, String)]
|
| TestFailed FilePath [(DI, String)]
|
||||||
deriving (Eq)
|
deriving (Eq)
|
||||||
|
|
||||||
instance Show TestResult where
|
instance Show TestResult where
|
||||||
show TestPassed = "PASSED"
|
show TestPassed = "PASSED"
|
||||||
show (TestError ec) = "ERROR " ++ show ec
|
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 :: [(DI, String)] -> String
|
||||||
showDiff [] = ""
|
showDiff [] = ""
|
||||||
showDiff ((F, ln) : ds) = "|TEST| " ++ ln ++ "\n" ++ showDiff ds
|
showDiff ((F, ln) : ds) = "- " ++ ln ++ "\n" ++ showDiff ds
|
||||||
showDiff ((S, ln) : ds) = "|NORM| " ++ ln ++ "\n" ++ showDiff ds
|
showDiff ((S, ln) : ds) = "+ " ++ ln ++ "\n" ++ showDiff ds
|
||||||
showDiff ((B, _ ) : ds) = showDiff ds
|
showDiff ((B, _ ) : ds) = showDiff ds
|
||||||
|
|
||||||
tests :: [Test]
|
tests :: [Test]
|
||||||
|
@ -183,7 +183,7 @@ testWithNormalize normalizer testname opts inp norm = testCase testname $ do
|
||||||
normContents <- readFile' normPath >>= return . filter (/='\r') . normalizer
|
normContents <- readFile' normPath >>= return . filter (/='\r') . normalizer
|
||||||
if outputContents == normContents
|
if outputContents == normContents
|
||||||
then return TestPassed
|
then return TestPassed
|
||||||
else return $ TestFailed $ getDiff (lines outputContents) (lines normContents)
|
else return $ TestFailed normPath $ getDiff (lines outputContents) (lines normContents)
|
||||||
else return $ TestError ec
|
else return $ TestError ec
|
||||||
removeFile outputPath
|
removeFile outputPath
|
||||||
assertBool (show result) (result == TestPassed)
|
assertBool (show result) (result == TestPassed)
|
||||||
|
|
Loading…
Reference in a new issue