git.iko.soy/typeable/pandoc
on master help sign in
Use tasty for tests rather than test-framework.
commit6ecc5b96a9854382682fd1c9231133c08dae7b17 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 14 Mar 2017, 17:05 (10 years ago) parent0b4ae3a
29 files changed+137−142
Makefile+2−2 pandoc.cabal+3−3 test/Tests/Command.hs+9−9 test/Tests/Helpers.hs+7−11 test/Tests/Old.hs+10−11 test/Tests/Readers/Docx.hs+15−15 test/Tests/Readers/EPUB.hs+3−4 test/Tests/Readers/HTML.hs+2−2 test/Tests/Readers/LaTeX.hs+5−5 test/Tests/Readers/Markdown.hs+4−4 test/Tests/Readers/Odt.hs+9−8 test/Tests/Readers/Org.hs+3−3 test/Tests/Readers/RST.hs+3−3 test/Tests/Readers/Txt2Tags.hs+3−3 test/Tests/Shared.hs+4−5 test/Tests/Writers/AsciiDoc.hs+2−2 test/Tests/Writers/ConTeXt.hs+5−4 test/Tests/Writers/Docbook.hs+3−3 test/Tests/Writers/Docx.hs+9−8 test/Tests/Writers/HTML.hs+3−3 test/Tests/Writers/LaTeX.hs+3−3 test/Tests/Writers/Markdown.hs+6−6 test/Tests/Writers/Muse.hs+3−3 test/Tests/Writers/Native.hs+5−4 test/Tests/Writers/Org.hs+3−3 test/Tests/Writers/Plain.hs+3−3 test/Tests/Writers/RST.hs+3−3 test/Tests/Writers/TEI.hs+3−3 test/test-pandoc.hs+4−6
Makefile+2−2
@@ -4,14 +4,14 @@ sourcefiles=$(shell find pandoc.hs src test -name '*.hs')
44BRANCH?=master
55
66quick:
7− stack install --flag 'pandoc:embed_data_files' --fast --test --test-arguments='-j4'
7+ stack install --flag 'pandoc:embed_data_files' --fast --test --test-arguments='-j4 --hide-successes'
88
99full:
1010 stack install --flag 'pandoc:embed_data_files' --test --test-arguments='-j4' --pedantic
1111 stack haddock
1212
1313test:
14− stack test --test-arguments='-j4'
14+ stack test --flag 'pandoc:embed_data_files' --fast --test-arguments='-j4 --hide-successes'
1515
1616bench:
1717 stack bench
pandoc.cabal+3−3
@@ -510,9 +510,9 @@ Test-Suite test-pandoc
510510 process >= 1.2.3 && < 1.5,
511511 skylighting >= 0.3.1 && < 0.4,
512512 Diff >= 0.2 && < 0.4,
513− test-framework >= 0.3 && < 0.9,
514− test-framework-hunit >= 0.2 && < 0.4,
515− test-framework-quickcheck2 >= 0.2.9 && < 0.4,
513+ tasty >= 0.11 && < 0.12,
514+ tasty-hunit >= 0.9 && < 0.10,
515+ tasty-quickcheck >= 0.8 && < 0.9,
516516 QuickCheck >= 2.4 && < 2.10,
517517 HUnit >= 1.2 && < 1.6,
518518 containers >= 0.1 && < 0.6,
test/Tests/Command.hs+9−9
@@ -8,20 +8,20 @@ import System.Directory
88import System.Exit
99import System.FilePath (joinPath, splitDirectories, takeDirectory, (</>))
1010import System.Process
11−import Test.Framework
12−import Test.Framework.Providers.HUnit
13−import Test.HUnit (assertBool)
11+import Test.Tasty
12+import Test.Tasty.HUnit
1413import Tests.Helpers
1514import Text.Pandoc
1615import Text.Pandoc.Shared (trimr)
1716import qualified Text.Pandoc.UTF8 as UTF8
17+import System.IO.Unsafe (unsafePerformIO) -- TODO temporary
1818
1919-- | Run a test with normalize function, return True if test passed.
2020runTest :: String -- ^ Title of test
2121 -> String -- ^ Shell command
2222 -> String -- ^ Input text
2323 -> String -- ^ Expected output
24− -> Test
24+ -> TestTree
2525runTest testname cmd inp norm = testCase testname $ do
2626 let cmd' = cmd ++ " --quiet --data-dir ../data"
2727 let findDynlibDir [] = Nothing
@@ -48,8 +48,8 @@ runTest testname cmd inp norm = testCase testname $ do
4848 else return $ TestError ec
4949 assertBool (show result) (result == TestPassed)
5050
51−tests :: Test
52−tests = buildTest $ do
51+tests :: TestTree
52+tests = unsafePerformIO $ do
5353 files <- filter (".md" `isSuffixOf`) <$>
5454 getDirectoryContents "command"
5555 let cmds = map extractCommandTest files
@@ -67,7 +67,7 @@ dropPercent :: String -> String
6767dropPercent ('%':xs) = dropWhile (== ' ') xs
6868dropPercent xs = xs
6969
70−runCommandTest :: FilePath -> (Int, String) -> IO Test
70+runCommandTest :: FilePath -> (Int, String) -> IO TestTree
7171runCommandTest pandocpath (num, code) = do
7272 let codelines = lines code
7373 let (continuations, r1) = span ("\\" `isSuffixOf`) codelines
@@ -80,8 +80,8 @@ runCommandTest pandocpath (num, code) = do
8080 let shcmd = trimr $ takeDirectory pandocpath </> cmd
8181 return $ runTest ("#" ++ show num) shcmd input norm
8282
83−extractCommandTest :: FilePath -> Test
84−extractCommandTest fp = buildTest $ do
83+extractCommandTest :: FilePath -> TestTree
84+extractCommandTest fp = unsafePerformIO $ do
8585 pandocpath <- findPandoc
8686 contents <- UTF8.readFile ("command" </> fp)
8787 Pandoc _ blocks <- runIOorExplode (readMarkdown
test/Tests/Helpers.hs+7−11
@@ -8,7 +8,6 @@ module Tests.Helpers ( test
88 , findPandoc
99 , (=?>)
1010 , purely
11− , property
1211 , ToString(..)
1312 , ToPandoc(..)
1413 )
@@ -20,11 +19,8 @@ import System.Directory
2019import System.Environment.Executable (getExecutablePath)
2120import System.Exit
2221import System.FilePath
23−import Test.Framework
24−import Test.Framework.Providers.HUnit
25−import Test.Framework.Providers.QuickCheck2
26−import Test.HUnit (assertBool)
27−import qualified Test.QuickCheck.Property as QP
22+import Test.Tasty
23+import Test.Tasty.HUnit
2824import Text.Pandoc.Builder (Blocks, Inlines, doc, plain)
2925import Text.Pandoc.Class
3026import Text.Pandoc.Definition
@@ -37,14 +33,17 @@ test :: (ToString a, ToString b, ToString c)
3733 => (a -> b) -- ^ function to test
3834 -> String -- ^ name of test case
3935 -> (a, c) -- ^ (input, expected value)
40− -> Test
36+ -> TestTree
4137test fn name (input, expected) =
42− testCase name $ assertBool msg (actual' == expected')
38+ testCase name' $ assertBool msg (actual' == expected')
4339 where msg = nl ++ dashes "input" ++ nl ++ input' ++ nl ++
4440 dashes "result" ++ nl ++
4541 unlines (map vividize diff) ++
4642 dashes ""
4743 nl = "\n"
44+ name' = if length name > 54
45+ then take 52 name ++ "..." -- avoid wide output
46+ else name
4847 input' = toString input
4948 actual' = lines $ toString $ fn input
5049 expected' = lines $ toString expected
@@ -95,9 +94,6 @@ vividize (Both s _) = " " ++ s
9594vividize (First s) = "- " ++ s
9695vividize (Second s) = "+ " ++ s
9796
98−property :: QP.Testable a => TestName -> a -> Test
99−property = testProperty
100−
10197purely :: (b -> PandocPure a) -> b -> a
10298purely f = either (error . show) id . runPure . f
10399
test/Tests/Old.hs+10−11
@@ -7,13 +7,12 @@ import System.Exit
77import System.FilePath (joinPath, splitDirectories, (<.>), (</>))
88import System.IO (openTempFile, stderr)
99import System.Process (runProcess, waitForProcess)
10−import Test.Framework (Test, testGroup)
11−import Test.Framework.Providers.HUnit
12−import Test.HUnit (assertBool)
10+import Test.Tasty (TestTree, testGroup)
11+import Test.Tasty.HUnit
1312import Tests.Helpers hiding (test)
1413import qualified Text.Pandoc.UTF8 as UTF8
1514
16−tests :: [Test]
15+tests :: [TestTree]
1716tests = [ testGroup "markdown"
1817 [ testGroup "writer"
1918 $ writerTests "markdown" ++ lhsWriterTests "markdown"
@@ -152,7 +151,7 @@ readFile' :: FilePath -> IO String
152151readFile' f = do s <- UTF8.readFile f
153152 return $! (length s `seq` s)
154153
155−lhsWriterTests :: String -> [Test]
154+lhsWriterTests :: String -> [TestTree]
156155lhsWriterTests format
157156 = [ t "lhs to normal" format
158157 , t "lhs to lhs" (format ++ "+lhs")
@@ -161,7 +160,7 @@ lhsWriterTests format
161160 t n f = test n ["--wrap=preserve", "-r", "native", "-s", "-w", f]
162161 "lhs-test.native" ("lhs-test" <.> f)
163162
164−lhsReaderTest :: String -> Test
163+lhsReaderTest :: String -> TestTree
165164lhsReaderTest format =
166165 test "lhs" ["-r", format, "-w", "native"]
167166 ("lhs-test" <.> format) norm
@@ -169,7 +168,7 @@ lhsReaderTest format =
169168 then "lhs-test-markdown.native"
170169 else "lhs-test.native"
171170
172−writerTests :: String -> [Test]
171+writerTests :: String -> [TestTree]
173172writerTests format
174173 = [ test "basic" (opts ++ ["-s"]) "testsuite.native" ("writer" <.> format)
175174 , test "tables" opts "tables.native" ("tables" <.> format)
@@ -178,13 +177,13 @@ writerTests format
178177 opts = ["-r", "native", "-w", format, "--columns=78",
179178 "--variable", "pandoc-version="]
180179
181−s5WriterTest :: String -> [String] -> String -> Test
180+s5WriterTest :: String -> [String] -> String -> TestTree
182181s5WriterTest modifier opts format
183182 = test (format ++ " writer (" ++ modifier ++ ")")
184183 (["-r", "native", "-w", format] ++ opts)
185184 "s5.native" ("s5-" ++ modifier <.> "html")
186185
187−fb2WriterTest :: String -> [String] -> String -> String -> Test
186+fb2WriterTest :: String -> [String] -> String -> String -> TestTree
188187fb2WriterTest title opts inputfile normfile =
189188 testWithNormalize (ignoreBinary . formatXML)
190189 title (["-t", "fb2"]++opts) inputfile normfile
@@ -202,7 +201,7 @@ test :: String -- ^ Title of test
202201 -> [String] -- ^ Options to pass to pandoc
203202 -> String -- ^ Input filepath
204203 -> FilePath -- ^ Norm (for test results) filepath
205− -> Test
204+ -> TestTree
206205test = testWithNormalize id
207206
208207-- | Run a test with normalize function, return True if test passed.
@@ -211,7 +210,7 @@ testWithNormalize :: (String -> String) -- ^ Normalize function for output
211210 -> [String] -- ^ Options to pass to pandoc
212211 -> String -- ^ Input filepath
213212 -> FilePath -- ^ Norm (for test results) filepath
214− -> Test
213+ -> TestTree
215214testWithNormalize normalizer testname opts inp norm = testCase testname $ do
216215 -- find pandoc executable relative to test-pandoc
217216 -- First, try in same directory (e.g. if both in ~/.cabal/bin)
test/Tests/Readers/Docx.hs+15−15
@@ -3,13 +3,13 @@ module Tests.Readers.Docx (tests) where
33import Codec.Archive.Zip
44import qualified Data.ByteString.Lazy as B
55import qualified Data.Map as M
6−import Test.Framework
7−import Test.Framework.Providers.HUnit
8−import Test.HUnit (assertBool)
6+import Test.Tasty
7+import Test.Tasty.HUnit
98import Tests.Helpers
109import Text.Pandoc
1110import qualified Text.Pandoc.Class as P
1211import Text.Pandoc.MediaBag (MediaBag, lookupMedia, mediaDirectory)
12+import System.IO.Unsafe -- TODO temporary
1313
1414-- We define a wrapper around pandoc that doesn't normalize in the
1515-- tests. Since we do our own normalization, we want to make sure
@@ -45,30 +45,30 @@ compareOutput opts docxFile nativeFile = do
4545 df' <- runIOorExplode $ readNative def nf
4646 return $ (noNorm p, noNorm df')
4747
48−testCompareWithOptsIO :: ReaderOptions -> String -> FilePath -> FilePath -> IO Test
48+testCompareWithOptsIO :: ReaderOptions -> String -> FilePath -> FilePath -> IO TestTree
4949testCompareWithOptsIO opts name docxFile nativeFile = do
5050 (dp, np) <- compareOutput opts docxFile nativeFile
5151 return $ test id name (dp, np)
5252
53−testCompareWithOpts :: ReaderOptions -> String -> FilePath -> FilePath -> Test
53+testCompareWithOpts :: ReaderOptions -> String -> FilePath -> FilePath -> TestTree
5454testCompareWithOpts opts name docxFile nativeFile =
55− buildTest $ testCompareWithOptsIO opts name docxFile nativeFile
55+ unsafePerformIO $ testCompareWithOptsIO opts name docxFile nativeFile
5656
57−testCompare :: String -> FilePath -> FilePath -> Test
57+testCompare :: String -> FilePath -> FilePath -> TestTree
5858testCompare = testCompareWithOpts defopts
5959
60−testForWarningsWithOptsIO :: ReaderOptions -> String -> FilePath -> [String] -> IO Test
60+testForWarningsWithOptsIO :: ReaderOptions -> String -> FilePath -> [String] -> IO TestTree
6161testForWarningsWithOptsIO opts name docxFile expected = do
6262 df <- B.readFile docxFile
6363 logs <- runIOorExplode (readDocx opts df >> P.getLog)
6464 let warns = [m | DocxParserWarning m <- logs]
6565 return $ test id name (unlines warns, unlines expected)
6666
67−testForWarningsWithOpts :: ReaderOptions -> String -> FilePath -> [String] -> Test
67+testForWarningsWithOpts :: ReaderOptions -> String -> FilePath -> [String] -> TestTree
6868testForWarningsWithOpts opts name docxFile expected =
69− buildTest $ testForWarningsWithOptsIO opts name docxFile expected
69+ unsafePerformIO $ testForWarningsWithOptsIO opts name docxFile expected
7070
71−-- testForWarnings :: String -> FilePath -> [String] -> Test
71+-- testForWarnings :: String -> FilePath -> [String] -> TestTree
7272-- testForWarnings = testForWarningsWithOpts defopts
7373
7474getMedia :: FilePath -> FilePath -> IO (Maybe B.ByteString)
@@ -100,17 +100,17 @@ compareMediaBagIO docxFile = do
100100 (mediaDirectory mb)
101101 return $ and bools
102102
103−testMediaBagIO :: String -> FilePath -> IO Test
103+testMediaBagIO :: String -> FilePath -> IO TestTree
104104testMediaBagIO name docxFile = do
105105 outcome <- compareMediaBagIO docxFile
106106 return $ testCase name (assertBool
107107 ("Media didn't match media bag in file " ++ docxFile)
108108 outcome)
109109
110−testMediaBag :: String -> FilePath -> Test
111−testMediaBag name docxFile = buildTest $ testMediaBagIO name docxFile
110+testMediaBag :: String -> FilePath -> TestTree
111+testMediaBag name docxFile = unsafePerformIO $ testMediaBagIO name docxFile
112112
113−tests :: [Test]
113+tests :: [TestTree]
114114tests = [ testGroup "inlines"
115115 [ testCompare
116116 "font formatting"
test/Tests/Readers/EPUB.hs+3−4
@@ -1,9 +1,8 @@
11module Tests.Readers.EPUB (tests) where
22
33import qualified Data.ByteString.Lazy as BL
4−import Test.Framework
5−import Test.Framework.Providers.HUnit
6−import Test.HUnit (assertBool)
4+import Test.Tasty
5+import Test.Tasty.HUnit
76import qualified Text.Pandoc.Class as P
87import Text.Pandoc.MediaBag (MediaBag, mediaDirectory)
98import Text.Pandoc.Options
@@ -30,7 +29,7 @@ featuresBag = [("img/check.gif","image/gif",1340)
3029 ,("img/multiscripts_and_greek_alphabet.png","image/png",10060)
3130 ]
3231
33−tests :: [Test]
32+tests :: [TestTree]
3433tests =
3534 [ testGroup "EPUB Mediabag"
3635 [ testCase "features bag"
test/Tests/Readers/HTML.hs+2−2
@@ -1,7 +1,7 @@
11{-# LANGUAGE OverloadedStrings #-}
22module Tests.Readers.HTML (tests) where
33
4−import Test.Framework
4+import Test.Tasty
55import Tests.Helpers
66import Text.Pandoc
77import Text.Pandoc.Arbitrary ()
@@ -10,7 +10,7 @@ import Text.Pandoc.Builder
1010html :: String -> Pandoc
1111html = purely $ readHtml def
1212
13−tests :: [Test]
13+tests :: [TestTree]
1414tests = [ testGroup "base tag"
1515 [ test html "simple" $
1616 "<head><base href=\"http://www.w3schools.com/images/foo\" ></head><body><img src=\"stickman.gif\" alt=\"Stickman\"></head>" =?>
test/Tests/Readers/LaTeX.hs+5−5
@@ -1,7 +1,7 @@
11{-# LANGUAGE OverloadedStrings #-}
22module Tests.Readers.LaTeX (tests) where
33
4−import Test.Framework
4+import Test.Tasty
55import Tests.Helpers
66import Text.Pandoc
77import Text.Pandoc.Arbitrary ()
@@ -13,14 +13,14 @@ latex = purely $ readLaTeX def{
1313
1414infix 4 =:
1515(=:) :: ToString c
16− => String -> (String, c) -> Test
16+ => String -> (String, c) -> TestTree
1717(=:) = test latex
1818
1919simpleTable' :: [Alignment] -> [[Blocks]] -> Blocks
2020simpleTable' aligns = table "" (zip aligns (repeat 0.0))
2121 (map (const mempty) aligns)
2222
23−tests :: [Test]
23+tests :: [TestTree]
2424tests = [ testGroup "basic"
2525 [ "simple" =:
2626 "word" =?> para "word"
@@ -128,7 +128,7 @@ baseCitation = Citation{ citationId = "item1"
128128rt :: String -> Inlines
129129rt = rawInline "latex"
130130
131−natbibCitations :: Test
131+natbibCitations :: TestTree
132132natbibCitations = testGroup "natbib"
133133 [ "citet" =: "\\citet{item1}"
134134 =?> para (cite [baseCitation] (rt "\\citet{item1}"))
@@ -175,7 +175,7 @@ natbibCitations = testGroup "natbib"
175175 Strong [Str "32"]] }] (rt "\\citep[\\emph{see}][p. \\textbf{32}]{item1}"))
176176 ]
177177
178−biblatexCitations :: Test
178+biblatexCitations :: TestTree
179179biblatexCitations = testGroup "biblatex"
180180 [ "textcite" =: "\\textcite{item1}"
181181 =?> para (cite [baseCitation] (rt "\\textcite{item1}"))
test/Tests/Readers/Markdown.hs+4−4
@@ -1,7 +1,7 @@
11{-# LANGUAGE OverloadedStrings #-}
22module Tests.Readers.Markdown (tests) where
33
4−import Test.Framework
4+import Test.Tasty
55import Tests.Helpers
66import Text.Pandoc
77import Text.Pandoc.Arbitrary ()
@@ -25,10 +25,10 @@ markdownGH = purely $ readMarkdown def {
2525
2626infix 4 =:
2727(=:) :: ToString c
28− => String -> (String, c) -> Test
28+ => String -> (String, c) -> TestTree
2929(=:) = test markdown
3030
31−testBareLink :: (String, Inlines) -> Test
31+testBareLink :: (String, Inlines) -> TestTree
3232testBareLink (inp, ils) =
3333 test (purely $ readMarkdown def{ readerExtensions =
3434 extensionsFromList [Ext_autolink_bare_uris, Ext_raw_html] })
@@ -142,7 +142,7 @@ p_markdown_round_trip b = matches d' d''
142142 matches x y = x == y
143143-}
144144
145−tests :: [Test]
145+tests :: [TestTree]
146146tests = [ testGroup "inline code"
147147 [ "with attribute" =:
148148 "`document.write(\"Hello\");`{.javascript}"
test/Tests/Readers/Odt.hs+9−8
@@ -3,17 +3,18 @@ module Tests.Readers.Odt (tests) where
33import Control.Monad (liftM)
44import qualified Data.ByteString.Lazy as B
55import qualified Data.Map as M
6−import Test.Framework
6+import Test.Tasty
77import Tests.Helpers
88import Text.Pandoc
9+import System.IO.Unsafe (unsafePerformIO) -- TODO temporary
910
1011defopts :: ReaderOptions
1112defopts = def{ readerExtensions = getDefaultExtensions "odt" }
1213
13−tests :: [Test]
14+tests :: [TestTree]
1415tests = testsComparingToMarkdown ++ testsComparingToNative
1516
16−testsComparingToMarkdown :: [Test]
17+testsComparingToMarkdown :: [TestTree]
1718testsComparingToMarkdown = map nameToTest namesOfTestsComparingToMarkdown
1819 where nameToTest name = createTest
1920 compareOdtToMarkdown
@@ -23,7 +24,7 @@ testsComparingToMarkdown = map nameToTest namesOfTestsComparingToMarkdown
2324 toOdtPath name = "odt/odt/" ++ name ++ ".odt"
2425 toMarkdownPath name = "odt/markdown/" ++ name ++ ".md"
2526
26−testsComparingToNative :: [Test]
27+testsComparingToNative :: [TestTree]
2728testsComparingToNative = map nameToTest namesOfTestsComparingToNative
2829 where nameToTest name = createTest
2930 compareOdtToNative
@@ -77,9 +78,9 @@ compareOdtToMarkdown opts odtPath markdownPath = do
7778createTest :: TestCreator
7879 -> TestName
7980 -> FilePath -> FilePath
80− -> Test
81+ -> TestTree
8182createTest creator name path1 path2 =
82− buildTest $ liftM (test id name) (creator defopts path1 path2)
83+ unsafePerformIO $ liftM (test id name) (creator defopts path1 path2)
8384
8485{-
8586--
@@ -113,14 +114,14 @@ compareMediaBagIO odtFile = do
113114 (mediaDirectory mb)
114115 return $ and bools
115116
116−testMediaBagIO :: String -> FilePath -> IO Test
117+testMediaBagIO :: String -> FilePath -> IO TestTree
117118testMediaBagIO name odtFile = do
118119 outcome <- compareMediaBagIO odtFile
119120 return $ testCase name (assertBool
120121 ("Media didn't match media bag in file " ++ odtFile)
121122 outcome)
122123
123−testMediaBag :: String -> FilePath -> Test
124+testMediaBag :: String -> FilePath -> TestTree
124125testMediaBag name odtFile = buildTest $ testMediaBagIO name odtFile
125126-}
126127--
test/Tests/Readers/Org.hs+3−3
@@ -2,7 +2,7 @@
22module Tests.Readers.Org (tests) where
33
44import Data.List (intersperse)
5−import Test.Framework
5+import Test.Tasty
66import Tests.Helpers
77import Text.Pandoc
88import Text.Pandoc.Builder
@@ -16,7 +16,7 @@ orgSmart = purely $ readOrg def { readerExtensions =
1616
1717infix 4 =:
1818(=:) :: ToString c
19− => String -> (String, c) -> Test
19+ => String -> (String, c) -> TestTree
2020(=:) = test org
2121
2222spcSep :: [Inlines] -> Inlines
@@ -28,7 +28,7 @@ simpleTable' :: Int
2828 -> Blocks
2929simpleTable' n = table "" (take n $ repeat (AlignDefault, 0.0))
3030
31−tests :: [Test]
31+tests :: [TestTree]
3232tests =
3333 [ testGroup "Inlines" $
3434 [ "Plain String" =:
test/Tests/Readers/RST.hs+3−3
@@ -2,7 +2,7 @@
22{-# LANGUAGE ScopedTypeVariables #-}
33module Tests.Readers.RST (tests) where
44
5−import Test.Framework
5+import Test.Tasty
66import Tests.Helpers
77import Text.Pandoc
88import Text.Pandoc.Arbitrary ()
@@ -13,10 +13,10 @@ rst = purely $ readRST def{ readerStandalone = True }
1313
1414infix 4 =:
1515(=:) :: ToString c
16− => String -> (String, c) -> Test
16+ => String -> (String, c) -> TestTree
1717(=:) = test rst
1818
19−tests :: [Test]
19+tests :: [TestTree]
2020tests = [ "line block with blank line" =:
2121 "| a\n|\n| b" =?> lineBlock [ "a", mempty, "\160b" ]
2222 , testGroup "field list"
test/Tests/Readers/Txt2Tags.hs+3−3
@@ -2,7 +2,7 @@
22module Tests.Readers.Txt2Tags (tests) where
33
44import Data.List (intersperse)
5−import Test.Framework
5+import Test.Tasty
66import Tests.Helpers
77import Text.Pandoc
88import Text.Pandoc.Arbitrary ()
@@ -20,7 +20,7 @@ t2t = purely $ \s -> do
2020
2121infix 4 =:
2222(=:) :: ToString c
23− => String -> (String, c) -> Test
23+ => String -> (String, c) -> TestTree
2424(=:) = test t2t
2525
2626spcSep :: [Inlines] -> Inlines
@@ -32,7 +32,7 @@ simpleTable' :: Int
3232 -> Blocks
3333simpleTable' n = table "" (take n $ repeat (AlignCenter, 0.0))
3434
35−tests :: [Test]
35+tests :: [TestTree]
3636tests =
3737 [ testGroup "Inlines" $
3838 [ "Plain String" =:
test/Tests/Shared.hs+4−5
@@ -1,14 +1,13 @@
11module Tests.Shared (tests) where
22
33import System.FilePath.Posix (joinPath)
4−import Test.Framework
5−import Test.Framework.Providers.HUnit
6−import Test.HUnit (assertBool, (@?=))
4+import Test.Tasty
5+import Test.Tasty.HUnit (assertBool, (@?=), testCase)
76import Text.Pandoc.Arbitrary ()
87import Text.Pandoc.Builder
98import Text.Pandoc.Shared
109
11−tests :: [Test]
10+tests :: [TestTree]
1211tests = [ testGroup "compactifyDL"
1312 [ testCase "compactifyDL with empty def" $
1413 assertBool "compactifyDL"
@@ -18,7 +17,7 @@ tests = [ testGroup "compactifyDL"
1817 , testGroup "collapseFilePath" testCollapse
1918 ]
2019
21−testCollapse :: [Test]
20+testCollapse :: [TestTree]
2221testCollapse = map (testCase "collapse")
2322 [ (collapseFilePath (joinPath [ ""]) @?= (joinPath [ ""]))
2423 , (collapseFilePath (joinPath [ ".","foo"]) @?= (joinPath [ "foo"]))
test/Tests/Writers/AsciiDoc.hs+2−2
@@ -1,6 +1,6 @@
11module Tests.Writers.AsciiDoc (tests) where
22
3−import Test.Framework
3+import Test.Tasty
44import Tests.Helpers
55import Text.Pandoc
66import Text.Pandoc.Arbitrary ()
@@ -9,7 +9,7 @@ import Text.Pandoc.Builder
99asciidoc :: (ToPandoc a) => a -> String
1010asciidoc = purely (writeAsciiDoc def{ writerWrapText = WrapNone }) . toPandoc
1111
12−tests :: [Test]
12+tests :: [TestTree]
1313tests = [ testGroup "emphasis"
1414 [ test asciidoc "emph word before" $
1515 para (text "foo" <> emph (text "bar")) =?>
test/Tests/Writers/ConTeXt.hs+5−4
@@ -1,7 +1,8 @@
11{-# LANGUAGE OverloadedStrings #-}
22module Tests.Writers.ConTeXt (tests) where
33
4−import Test.Framework
4+import Test.Tasty
5+import Test.Tasty.QuickCheck
56import Tests.Helpers
67import Text.Pandoc
78import Text.Pandoc.Arbitrary ()
@@ -27,14 +28,14 @@ which is in turn shorthand for
2728
2829infix 4 =:
2930(=:) :: (ToString a, ToPandoc a)
30− => String -> (a, String) -> Test
31+ => String -> (a, String) -> TestTree
3132(=:) = test context
3233
33−tests :: [Test]
34+tests :: [TestTree]
3435tests = [ testGroup "inline code"
3536 [ "with '}'" =: code "}" =?> "\\mono{\\}}"
3637 , "without '}'" =: code "]" =?> "\\type{]}"
37− , property "code property" $ \s -> null s ||
38+ , testProperty "code property" $ \s -> null s ||
3839 if '{' `elem` s || '}' `elem` s
3940 then (context' $ code s) == "\\mono{" ++
4041 (context' $ str s) ++ "}"
test/Tests/Writers/Docbook.hs+3−3
@@ -1,7 +1,7 @@
11{-# LANGUAGE OverloadedStrings #-}
22module Tests.Writers.Docbook (tests) where
33
4−import Test.Framework
4+import Test.Tasty
55import Tests.Helpers
66import Text.Pandoc
77import Text.Pandoc.Arbitrary ()
@@ -27,7 +27,7 @@ which is in turn shorthand for
2727
2828infix 4 =:
2929(=:) :: (ToString a, ToPandoc a)
30− => String -> (a, String) -> Test
30+ => String -> (a, String) -> TestTree
3131(=:) = test docbook
3232
3333lineblock :: Blocks
@@ -40,7 +40,7 @@ lineblock_out = [ "<literallayout>some text"
4040 , "and again</literallayout>"
4141 ]
4242
43−tests :: [Test]
43+tests :: [TestTree]
4444tests = [ testGroup "line blocks"
4545 [ "none" =: para "This is a test"
4646 =?> unlines
test/Tests/Writers/Docx.hs+9−8
@@ -1,7 +1,7 @@
11module Tests.Writers.Docx (tests) where
22
33import System.FilePath ((</>))
4−import Test.Framework
4+import Test.Tasty
55import Tests.Helpers
66import Text.Pandoc.Class (runIOorExplode)
77import Text.Pandoc.Definition
@@ -9,6 +9,7 @@ import Text.Pandoc.Options
99import Text.Pandoc.Readers.Docx
1010import Text.Pandoc.Readers.Native
1111import Text.Pandoc.Writers.Docx
12+import System.IO.Unsafe (unsafePerformIO) -- TODO temporary
1213
1314type Options = (WriterOptions, ReaderOptions)
1415
@@ -27,26 +28,26 @@ compareOutput opts nativeFileIn nativeFileOut = do
2728 p <- runIOorExplode $ readDocx (snd opts) df
2829 return (p, df')
2930
30−testCompareWithOptsIO :: Options -> String -> FilePath -> FilePath -> IO Test
31+testCompareWithOptsIO :: Options -> String -> FilePath -> FilePath -> IO TestTree
3132testCompareWithOptsIO opts name nativeFileIn nativeFileOut = do
3233 (dp, np) <- compareOutput opts nativeFileIn nativeFileOut
3334 return $ test id name (dp, np)
3435
35−testCompareWithOpts :: Options -> String -> FilePath -> FilePath -> Test
36+testCompareWithOpts :: Options -> String -> FilePath -> FilePath -> TestTree
3637testCompareWithOpts opts name nativeFileIn nativeFileOut =
37− buildTest $ testCompareWithOptsIO opts name nativeFileIn nativeFileOut
38+ unsafePerformIO $ testCompareWithOptsIO opts name nativeFileIn nativeFileOut
3839
39−roundTripCompareWithOpts :: Options -> String -> FilePath -> Test
40+roundTripCompareWithOpts :: Options -> String -> FilePath -> TestTree
4041roundTripCompareWithOpts opts name nativeFile =
4142 testCompareWithOpts opts name nativeFile nativeFile
4243
43−-- testCompare :: String -> FilePath -> FilePath -> Test
44+-- testCompare :: String -> FilePath -> FilePath -> TestTree
4445-- testCompare = testCompareWithOpts def
4546
46−roundTripCompare :: String -> FilePath -> Test
47+roundTripCompare :: String -> FilePath -> TestTree
4748roundTripCompare = roundTripCompareWithOpts def
4849
49−tests :: [Test]
50+tests :: [TestTree]
5051tests = [ testGroup "inlines"
5152 [ roundTripCompare
5253 "font formatting"
test/Tests/Writers/HTML.hs+3−3
@@ -1,7 +1,7 @@
11{-# LANGUAGE OverloadedStrings #-}
22module Tests.Writers.HTML (tests) where
33
4−import Test.Framework
4+import Test.Tasty
55import Tests.Helpers
66import Text.Pandoc
77import Text.Pandoc.Arbitrary ()
@@ -24,10 +24,10 @@ which is in turn shorthand for
2424
2525infix 4 =:
2626(=:) :: (ToString a, ToPandoc a)
27− => String -> (a, String) -> Test
27+ => String -> (a, String) -> TestTree
2828(=:) = test html
2929
30−tests :: [Test]
30+tests :: [TestTree]
3131tests = [ testGroup "inline code"
3232 [ "basic" =: code "@&" =?> "<code>@&amp;</code>"
3333 , "haskell" =: codeWith ("",["haskell"],[]) ">>="
test/Tests/Writers/LaTeX.hs+3−3
@@ -1,7 +1,7 @@
11{-# LANGUAGE OverloadedStrings #-}
22module Tests.Writers.LaTeX (tests) where
33
4−import Test.Framework
4+import Test.Tasty
55import Tests.Helpers
66import Text.Pandoc
77import Text.Pandoc.Arbitrary ()
@@ -33,10 +33,10 @@ which is in turn shorthand for
3333
3434infix 4 =:
3535(=:) :: (ToString a, ToPandoc a)
36− => String -> (a, String) -> Test
36+ => String -> (a, String) -> TestTree
3737(=:) = test latex
3838
39−tests :: [Test]
39+tests :: [TestTree]
4040tests = [ testGroup "code blocks"
4141 [ "in footnotes" =: note (para "hi" <> codeBlock "hi") =?>
4242 "\\footnote{hi\n\n\\begin{Verbatim}\nhi\n\\end{Verbatim}\n}"
test/Tests/Writers/Markdown.hs+6−6
@@ -2,7 +2,7 @@
22{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
33module Tests.Writers.Markdown (tests) where
44
5−import Test.Framework
5+import Test.Tasty
66import Tests.Helpers
77import Text.Pandoc
88import Text.Pandoc.Arbitrary ()
@@ -31,10 +31,10 @@ which is in turn shorthand for
3131
3232infix 4 =:
3333(=:) :: (ToString a, ToPandoc a)
34− => String -> (a, String) -> Test
34+ => String -> (a, String) -> TestTree
3535(=:) = test markdown
3636
37−tests :: [Test]
37+tests :: [TestTree]
3838tests = [ "indented code after list"
3939 =: (orderedList [ para "one" <> para "two" ] <> codeBlock "test")
4040 =?> "1. one\n\n two\n\n<!-- -->\n\n test"
@@ -85,7 +85,7 @@ noteTestDoc =
8585
8686
8787
88−noteTests :: Test
88+noteTests :: TestTree
8989noteTests = testGroup "note and reference location"
9090 [ test (markdownWithOpts defopts)
9191 "footnotes at the end of a document" $
@@ -176,12 +176,12 @@ noteTests = testGroup "note and reference location"
176176
177177 ]
178178
179−shortcutLinkRefsTests :: Test
179+shortcutLinkRefsTests :: TestTree
180180shortcutLinkRefsTests =
181181 let infix 4 =:
182182 (=:) :: (ToString a, ToPandoc a)
183183
184− => String -> (a, String) -> Test
184+ => String -> (a, String) -> TestTree
185185 (=:) = test (purely (writeMarkdown defopts{writerReferenceLinks = True}) . toPandoc)
186186 in testGroup "Shortcut reference links"
187187 [ "Simple link (shortcutable)"
test/Tests/Writers/Muse.hs+3−3
@@ -1,6 +1,6 @@
11module Tests.Writers.Muse (tests) where
22
3−import Test.Framework
3+import Test.Tasty
44import Tests.Helpers
55import Text.Pandoc
66import Text.Pandoc.Arbitrary()
@@ -14,10 +14,10 @@ museWithOpts opts = purely (writeMuse opts) . toPandoc
1414
1515infix 4 =:
1616(=:) :: (ToString a, ToPandoc a)
17− => String -> (a, String) -> Test
17+ => String -> (a, String) -> TestTree
1818(=:) = test muse
1919
20−tests :: [Test]
20+tests :: [TestTree]
2121tests = [ testGroup "block elements"
2222 [ "plain" =: plain (text "Foo bar.") =?> "Foo bar."
2323 , testGroup "paragraphs"
test/Tests/Writers/Native.hs+5−4
@@ -1,6 +1,7 @@
11module Tests.Writers.Native (tests) where
22
3−import Test.Framework
3+import Test.Tasty
4+import Test.Tasty.QuickCheck
45import Tests.Helpers
56import Text.Pandoc
67import Text.Pandoc.Arbitrary ()
@@ -15,8 +16,8 @@ p_write_blocks_rt bs =
1516 read (purely (writeNative def) (Pandoc nullMeta bs)) ==
1617 bs
1718
18−tests :: [Test]
19−tests = [ property "p_write_rt" p_write_rt
20− , property "p_write_blocks_rt" $ mapSize
19+tests :: [TestTree]
20+tests = [ testProperty "p_write_rt" p_write_rt
21+ , testProperty "p_write_blocks_rt" $ mapSize
2122 (\x -> if x > 3 then 3 else x) $ p_write_blocks_rt
2223 ]
test/Tests/Writers/Org.hs+3−3
@@ -1,7 +1,7 @@
11{-# LANGUAGE OverloadedStrings #-}
22module Tests.Writers.Org (tests) where
33
4−import Test.Framework
4+import Test.Tasty
55import Tests.Helpers
66import Text.Pandoc
77import Text.Pandoc.Arbitrary ()
@@ -9,10 +9,10 @@ import Text.Pandoc.Builder
99
1010infix 4 =:
1111(=:) :: (ToString a, ToPandoc a)
12− => String -> (a, String) -> Test
12+ => String -> (a, String) -> TestTree
1313(=:) = test (purely (writeOrg def . toPandoc))
1414
15−tests :: [Test]
15+tests :: [TestTree]
1616tests = [ testGroup "links"
1717 -- See http://orgmode.org/manual/Internal-links.html#Internal-links
1818 [ "simple link"
test/Tests/Writers/Plain.hs+3−3
@@ -1,7 +1,7 @@
11{-# LANGUAGE OverloadedStrings #-}
22module Tests.Writers.Plain (tests) where
33
4−import Test.Framework
4+import Test.Tasty
55import Tests.Helpers
66import Text.Pandoc
77import Text.Pandoc.Arbitrary ()
@@ -10,11 +10,11 @@ import Text.Pandoc.Builder
1010
1111infix 4 =:
1212(=:) :: (ToString a, ToPandoc a)
13− => String -> (a, String) -> Test
13+ => String -> (a, String) -> TestTree
1414(=:) = test (purely (writePlain def) . toPandoc)
1515
1616
17−tests :: [Test]
17+tests :: [TestTree]
1818tests = [ "strongly emphasized text to uppercase"
1919 =: strong "Straße"
2020 =?> "STRASSE"
test/Tests/Writers/RST.hs+3−3
@@ -1,7 +1,7 @@
11{-# LANGUAGE OverloadedStrings #-}
22module Tests.Writers.RST (tests) where
33
4−import Test.Framework
4+import Test.Tasty
55import Tests.Helpers
66import Text.Pandoc
77import Text.Pandoc.Arbitrary ()
@@ -9,10 +9,10 @@ import Text.Pandoc.Builder
99
1010infix 4 =:
1111(=:) :: (ToString a, ToPandoc a)
12− => String -> (a, String) -> Test
12+ => String -> (a, String) -> TestTree
1313(=:) = test (purely (writeRST def . toPandoc))
1414
15−tests :: [Test]
15+tests :: [TestTree]
1616tests = [ testGroup "rubrics"
1717 [ "in list item" =:
1818 bulletList [header 2 (text "foo")] =?>
test/Tests/Writers/TEI.hs+3−3
@@ -1,7 +1,7 @@
11{-# LANGUAGE OverloadedStrings #-}
22module Tests.Writers.TEI (tests) where
33
4−import Test.Framework
4+import Test.Tasty
55import Tests.Helpers
66import Text.Pandoc
77import Text.Pandoc.Arbitrary ()
@@ -21,10 +21,10 @@ which is in turn shorthand for
2121
2222infix 4 =:
2323(=:) :: (ToString a, ToPandoc a)
24− => String -> (a, String) -> Test
24+ => String -> (a, String) -> TestTree
2525(=:) = test (purely (writeTEI def) . toPandoc)
2626
27−tests :: [Test]
27+tests :: [TestTree]
2828tests = [ testGroup "block elements"
2929 ["para" =: para "Lorem ipsum cetera."
3030 =?> "<p>Lorem ipsum cetera.</p>"
test/test-pandoc.hs+4−6
@@ -3,8 +3,7 @@
33module Main where
44
55import GHC.IO.Encoding
6−import System.Environment (getArgs)
7−import Test.Framework
6+import Test.Tasty
87import qualified Tests.Command
98import qualified Tests.Old
109import qualified Tests.Readers.Docx
@@ -32,8 +31,8 @@ import qualified Tests.Writers.TEI
3231import qualified Tests.Writers.Muse
3332import Text.Pandoc.Shared (inDirectory)
3433
35−tests :: [Test]
36−tests = [ Tests.Command.tests
34+tests :: TestTree
35+tests = testGroup "pandoc tests" [ Tests.Command.tests
3736 , testGroup "Old" Tests.Old.tests
3837 , testGroup "Shared" Tests.Shared.tests
3938 , testGroup "Writers"
@@ -67,5 +66,4 @@ tests = [ Tests.Command.tests
6766main :: IO ()
6867main = do
6968 setLocaleEncoding utf8
70− args <- getArgs
71− inDirectory "test" $ defaultMainWithArgs tests args
69+ inDirectory "test" $ defaultMain tests