git.iko.soy/typeable/pandoc
on master help sign in
Use ANSI color to point to diffs in test output.
87aaa7eJohn MacFarlane
pandoc.cabal+2−1
@@ -344,7 +344,8 @@ Executable test-pandoc
344 test-framework-quickcheck2 >= 0.2.9 && < 0.3,
344 test-framework-quickcheck2 >= 0.2.9 && < 0.3,
345 QuickCheck == 2.4.*,
345 QuickCheck == 2.4.*,
346 HUnit >= 1.2 && < 1.3,
346 HUnit >= 1.2 && < 1.3,
347− template-haskell == 2.4.*
347+ template-haskell == 2.4.*,
348+ ansi-terminal == 0.5.*
348 Other-Modules: Tests.Old
349 Other-Modules: Tests.Old
349 Tests.Helpers
350 Tests.Helpers
350 Tests.Arbitrary
351 Tests.Arbitrary
tests/Tests/Helpers.hs+20−6
@@ -23,6 +23,8 @@ import Text.Pandoc.Writers.Native (writeNative)
23import Language.Haskell.TH.Quote
23import Language.Haskell.TH.Quote
24import Language.Haskell.TH.Syntax (Q, runIO)
24import Language.Haskell.TH.Syntax (Q, runIO)
25import qualified Test.QuickCheck.Property as QP
25import qualified Test.QuickCheck.Property as QP
26+import System.Console.ANSI
27+import Data.Algorithm.Diff
26
28
27lit :: QuasiQuoter
29lit :: QuasiQuoter
28lit = QuasiQuoter ((\a -> let b = rnl a in [|b|]) . filter (/= '\r')) $
30lit = QuasiQuoter ((\a -> let b = rnl a in [|b|]) . filter (/= '\r')) $
@@ -49,20 +51,32 @@ test :: (ToString a, ToString b, ToString c)
49 -> Test
51 -> Test
50test fn name (input, expected) =
52test fn name (input, expected) =
51 testCase name $ assertBool msg (actual' == expected')
53 testCase name $ assertBool msg (actual' == expected')
52− where msg = dashes "input" ++ input' ++
54+ where msg = nl ++ dashes "input" ++ nl ++ input' ++ nl ++
53− dashes "expected" ++ expected' ++
55+ dashes "expected" ++ nl ++ expected'' ++
54− dashes "got" ++ actual' ++
56+ dashes "got" ++ nl ++ actual'' ++
55 dashes ""
57 dashes ""
58+ nl = "\n"
56 input' = toString input
59 input' = toString input
57 actual' = toString $ fn input
60 actual' = toString $ fn input
58 expected' = toString expected
61 expected' = toString expected
62+ diff = getDiff (lines expected') (lines actual')
63+ expected'' = unlines $ map vividize $ filter (\(d,_) -> d /= S) diff
64+ actual'' = unlines $ map vividize $ filter (\(d,_) -> d /= F) diff
59− dashes "" = '\n' : replicate 72 '-'
65+ dashes "" = replicate 72 '-'
60− dashes x = '\n' : replicate (72 - length x - 5) '-' ++ " " ++
66+ dashes x = replicate (72 - length x - 5) '-' ++ " " ++ x ++ " ---"
61− x ++ " ---\n"
67+
68+vividize :: (DI,String) -> String
69+vividize (B,s) = s
70+vividize (_,s) = vivid s
62
71
63property :: QP.Testable a => TestName -> a -> Test
72property :: QP.Testable a => TestName -> a -> Test
64property = testProperty
73property = testProperty
65
74
75+vivid :: String -> String
76+vivid s = setSGRCode [SetColor Background Dull Red
77+ , SetColor Foreground Vivid White] ++ s
78+ ++ setSGRCode [Reset]
79+
66infix 6 =?>
80infix 6 =?>
67(=?>) :: a -> b -> (a,b)
81(=?>) :: a -> b -> (a,b)
68x =?> y = (x, y)
82x =?> y = (x, y)
tests/Tests/Writers/ConTeXt.hs+2−2
@@ -62,8 +62,8 @@ tests = [ testGroup "inline code"
62 next
62 next
63 \item
63 \item
64 \startitemize
64 \startitemize
65− \item
65+ \item
66− bot
66+ bot
67 \stopitemize
67 \stopitemize
68 \stopitemize
68 \stopitemize
69\stopitemize|]
69\stopitemize|]