From 6ecc5b96a9854382682fd1c9231133c08dae7b17 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 14 Mar 2017 17:05:36 +0100 Subject: Use tasty for tests rather than test-framework. --- test/Tests/Readers/Docx.hs | 30 +++++++++++++++--------------- test/Tests/Readers/EPUB.hs | 7 +++---- test/Tests/Readers/HTML.hs | 4 ++-- test/Tests/Readers/LaTeX.hs | 10 +++++----- test/Tests/Readers/Markdown.hs | 8 ++++---- test/Tests/Readers/Odt.hs | 17 +++++++++-------- test/Tests/Readers/Org.hs | 6 +++--- test/Tests/Readers/RST.hs | 6 +++--- test/Tests/Readers/Txt2Tags.hs | 6 +++--- 9 files changed, 47 insertions(+), 47 deletions(-) (limited to 'test/Tests/Readers') diff --git a/test/Tests/Readers/Docx.hs b/test/Tests/Readers/Docx.hs index 6e0ea127c..215fced78 100644 --- a/test/Tests/Readers/Docx.hs +++ b/test/Tests/Readers/Docx.hs @@ -3,13 +3,13 @@ module Tests.Readers.Docx (tests) where import Codec.Archive.Zip import qualified Data.ByteString.Lazy as B import qualified Data.Map as M -import Test.Framework -import Test.Framework.Providers.HUnit -import Test.HUnit (assertBool) +import Test.Tasty +import Test.Tasty.HUnit import Tests.Helpers import Text.Pandoc import qualified Text.Pandoc.Class as P import Text.Pandoc.MediaBag (MediaBag, lookupMedia, mediaDirectory) +import System.IO.Unsafe -- TODO temporary -- We define a wrapper around pandoc that doesn't normalize in the -- tests. Since we do our own normalization, we want to make sure @@ -45,30 +45,30 @@ compareOutput opts docxFile nativeFile = do df' <- runIOorExplode $ readNative def nf return $ (noNorm p, noNorm df') -testCompareWithOptsIO :: ReaderOptions -> String -> FilePath -> FilePath -> IO Test +testCompareWithOptsIO :: ReaderOptions -> String -> FilePath -> FilePath -> IO TestTree testCompareWithOptsIO opts name docxFile nativeFile = do (dp, np) <- compareOutput opts docxFile nativeFile return $ test id name (dp, np) -testCompareWithOpts :: ReaderOptions -> String -> FilePath -> FilePath -> Test +testCompareWithOpts :: ReaderOptions -> String -> FilePath -> FilePath -> TestTree testCompareWithOpts opts name docxFile nativeFile = - buildTest $ testCompareWithOptsIO opts name docxFile nativeFile + unsafePerformIO $ testCompareWithOptsIO opts name docxFile nativeFile -testCompare :: String -> FilePath -> FilePath -> Test +testCompare :: String -> FilePath -> FilePath -> TestTree testCompare = testCompareWithOpts defopts -testForWarningsWithOptsIO :: ReaderOptions -> String -> FilePath -> [String] -> IO Test +testForWarningsWithOptsIO :: ReaderOptions -> String -> FilePath -> [String] -> IO TestTree testForWarningsWithOptsIO opts name docxFile expected = do df <- B.readFile docxFile logs <- runIOorExplode (readDocx opts df >> P.getLog) let warns = [m | DocxParserWarning m <- logs] return $ test id name (unlines warns, unlines expected) -testForWarningsWithOpts :: ReaderOptions -> String -> FilePath -> [String] -> Test +testForWarningsWithOpts :: ReaderOptions -> String -> FilePath -> [String] -> TestTree testForWarningsWithOpts opts name docxFile expected = - buildTest $ testForWarningsWithOptsIO opts name docxFile expected + unsafePerformIO $ testForWarningsWithOptsIO opts name docxFile expected --- testForWarnings :: String -> FilePath -> [String] -> Test +-- testForWarnings :: String -> FilePath -> [String] -> TestTree -- testForWarnings = testForWarningsWithOpts defopts getMedia :: FilePath -> FilePath -> IO (Maybe B.ByteString) @@ -100,17 +100,17 @@ compareMediaBagIO docxFile = do (mediaDirectory mb) return $ and bools -testMediaBagIO :: String -> FilePath -> IO Test +testMediaBagIO :: String -> FilePath -> IO TestTree testMediaBagIO name docxFile = do outcome <- compareMediaBagIO docxFile return $ testCase name (assertBool ("Media didn't match media bag in file " ++ docxFile) outcome) -testMediaBag :: String -> FilePath -> Test -testMediaBag name docxFile = buildTest $ testMediaBagIO name docxFile +testMediaBag :: String -> FilePath -> TestTree +testMediaBag name docxFile = unsafePerformIO $ testMediaBagIO name docxFile -tests :: [Test] +tests :: [TestTree] tests = [ testGroup "inlines" [ testCompare "font formatting" diff --git a/test/Tests/Readers/EPUB.hs b/test/Tests/Readers/EPUB.hs index f343a75d8..5da5d33d3 100644 --- a/test/Tests/Readers/EPUB.hs +++ b/test/Tests/Readers/EPUB.hs @@ -1,9 +1,8 @@ module Tests.Readers.EPUB (tests) where import qualified Data.ByteString.Lazy as BL -import Test.Framework -import Test.Framework.Providers.HUnit -import Test.HUnit (assertBool) +import Test.Tasty +import Test.Tasty.HUnit import qualified Text.Pandoc.Class as P import Text.Pandoc.MediaBag (MediaBag, mediaDirectory) import Text.Pandoc.Options @@ -30,7 +29,7 @@ featuresBag = [("img/check.gif","image/gif",1340) ,("img/multiscripts_and_greek_alphabet.png","image/png",10060) ] -tests :: [Test] +tests :: [TestTree] tests = [ testGroup "EPUB Mediabag" [ testCase "features bag" diff --git a/test/Tests/Readers/HTML.hs b/test/Tests/Readers/HTML.hs index 0b97f68f8..e2262d131 100644 --- a/test/Tests/Readers/HTML.hs +++ b/test/Tests/Readers/HTML.hs @@ -1,7 +1,7 @@ {-# LANGUAGE OverloadedStrings #-} module Tests.Readers.HTML (tests) where -import Test.Framework +import Test.Tasty import Tests.Helpers import Text.Pandoc import Text.Pandoc.Arbitrary () @@ -10,7 +10,7 @@ import Text.Pandoc.Builder html :: String -> Pandoc html = purely $ readHtml def -tests :: [Test] +tests :: [TestTree] tests = [ testGroup "base tag" [ test html "simple" $ "\"Stickman\"" =?> diff --git a/test/Tests/Readers/LaTeX.hs b/test/Tests/Readers/LaTeX.hs index 423735243..75547ed6b 100644 --- a/test/Tests/Readers/LaTeX.hs +++ b/test/Tests/Readers/LaTeX.hs @@ -1,7 +1,7 @@ {-# LANGUAGE OverloadedStrings #-} module Tests.Readers.LaTeX (tests) where -import Test.Framework +import Test.Tasty import Tests.Helpers import Text.Pandoc import Text.Pandoc.Arbitrary () @@ -13,14 +13,14 @@ latex = purely $ readLaTeX def{ infix 4 =: (=:) :: ToString c - => String -> (String, c) -> Test + => String -> (String, c) -> TestTree (=:) = test latex simpleTable' :: [Alignment] -> [[Blocks]] -> Blocks simpleTable' aligns = table "" (zip aligns (repeat 0.0)) (map (const mempty) aligns) -tests :: [Test] +tests :: [TestTree] tests = [ testGroup "basic" [ "simple" =: "word" =?> para "word" @@ -128,7 +128,7 @@ baseCitation = Citation{ citationId = "item1" rt :: String -> Inlines rt = rawInline "latex" -natbibCitations :: Test +natbibCitations :: TestTree natbibCitations = testGroup "natbib" [ "citet" =: "\\citet{item1}" =?> para (cite [baseCitation] (rt "\\citet{item1}")) @@ -175,7 +175,7 @@ natbibCitations = testGroup "natbib" Strong [Str "32"]] }] (rt "\\citep[\\emph{see}][p. \\textbf{32}]{item1}")) ] -biblatexCitations :: Test +biblatexCitations :: TestTree biblatexCitations = testGroup "biblatex" [ "textcite" =: "\\textcite{item1}" =?> para (cite [baseCitation] (rt "\\textcite{item1}")) diff --git a/test/Tests/Readers/Markdown.hs b/test/Tests/Readers/Markdown.hs index 6e742e828..e1d0c8e1f 100644 --- a/test/Tests/Readers/Markdown.hs +++ b/test/Tests/Readers/Markdown.hs @@ -1,7 +1,7 @@ {-# LANGUAGE OverloadedStrings #-} module Tests.Readers.Markdown (tests) where -import Test.Framework +import Test.Tasty import Tests.Helpers import Text.Pandoc import Text.Pandoc.Arbitrary () @@ -25,10 +25,10 @@ markdownGH = purely $ readMarkdown def { infix 4 =: (=:) :: ToString c - => String -> (String, c) -> Test + => String -> (String, c) -> TestTree (=:) = test markdown -testBareLink :: (String, Inlines) -> Test +testBareLink :: (String, Inlines) -> TestTree testBareLink (inp, ils) = test (purely $ readMarkdown def{ readerExtensions = extensionsFromList [Ext_autolink_bare_uris, Ext_raw_html] }) @@ -142,7 +142,7 @@ p_markdown_round_trip b = matches d' d'' matches x y = x == y -} -tests :: [Test] +tests :: [TestTree] tests = [ testGroup "inline code" [ "with attribute" =: "`document.write(\"Hello\");`{.javascript}" diff --git a/test/Tests/Readers/Odt.hs b/test/Tests/Readers/Odt.hs index c31af38fc..6fc062158 100644 --- a/test/Tests/Readers/Odt.hs +++ b/test/Tests/Readers/Odt.hs @@ -3,17 +3,18 @@ module Tests.Readers.Odt (tests) where import Control.Monad (liftM) import qualified Data.ByteString.Lazy as B import qualified Data.Map as M -import Test.Framework +import Test.Tasty import Tests.Helpers import Text.Pandoc +import System.IO.Unsafe (unsafePerformIO) -- TODO temporary defopts :: ReaderOptions defopts = def{ readerExtensions = getDefaultExtensions "odt" } -tests :: [Test] +tests :: [TestTree] tests = testsComparingToMarkdown ++ testsComparingToNative -testsComparingToMarkdown :: [Test] +testsComparingToMarkdown :: [TestTree] testsComparingToMarkdown = map nameToTest namesOfTestsComparingToMarkdown where nameToTest name = createTest compareOdtToMarkdown @@ -23,7 +24,7 @@ testsComparingToMarkdown = map nameToTest namesOfTestsComparingToMarkdown toOdtPath name = "odt/odt/" ++ name ++ ".odt" toMarkdownPath name = "odt/markdown/" ++ name ++ ".md" -testsComparingToNative :: [Test] +testsComparingToNative :: [TestTree] testsComparingToNative = map nameToTest namesOfTestsComparingToNative where nameToTest name = createTest compareOdtToNative @@ -77,9 +78,9 @@ compareOdtToMarkdown opts odtPath markdownPath = do createTest :: TestCreator -> TestName -> FilePath -> FilePath - -> Test + -> TestTree createTest creator name path1 path2 = - buildTest $ liftM (test id name) (creator defopts path1 path2) + unsafePerformIO $ liftM (test id name) (creator defopts path1 path2) {- -- @@ -113,14 +114,14 @@ compareMediaBagIO odtFile = do (mediaDirectory mb) return $ and bools -testMediaBagIO :: String -> FilePath -> IO Test +testMediaBagIO :: String -> FilePath -> IO TestTree testMediaBagIO name odtFile = do outcome <- compareMediaBagIO odtFile return $ testCase name (assertBool ("Media didn't match media bag in file " ++ odtFile) outcome) -testMediaBag :: String -> FilePath -> Test +testMediaBag :: String -> FilePath -> TestTree testMediaBag name odtFile = buildTest $ testMediaBagIO name odtFile -} -- diff --git a/test/Tests/Readers/Org.hs b/test/Tests/Readers/Org.hs index 586526815..821739437 100644 --- a/test/Tests/Readers/Org.hs +++ b/test/Tests/Readers/Org.hs @@ -2,7 +2,7 @@ module Tests.Readers.Org (tests) where import Data.List (intersperse) -import Test.Framework +import Test.Tasty import Tests.Helpers import Text.Pandoc import Text.Pandoc.Builder @@ -16,7 +16,7 @@ orgSmart = purely $ readOrg def { readerExtensions = infix 4 =: (=:) :: ToString c - => String -> (String, c) -> Test + => String -> (String, c) -> TestTree (=:) = test org spcSep :: [Inlines] -> Inlines @@ -28,7 +28,7 @@ simpleTable' :: Int -> Blocks simpleTable' n = table "" (take n $ repeat (AlignDefault, 0.0)) -tests :: [Test] +tests :: [TestTree] tests = [ testGroup "Inlines" $ [ "Plain String" =: diff --git a/test/Tests/Readers/RST.hs b/test/Tests/Readers/RST.hs index 7a0a3de28..7f67ee742 100644 --- a/test/Tests/Readers/RST.hs +++ b/test/Tests/Readers/RST.hs @@ -2,7 +2,7 @@ {-# LANGUAGE ScopedTypeVariables #-} module Tests.Readers.RST (tests) where -import Test.Framework +import Test.Tasty import Tests.Helpers import Text.Pandoc import Text.Pandoc.Arbitrary () @@ -13,10 +13,10 @@ rst = purely $ readRST def{ readerStandalone = True } infix 4 =: (=:) :: ToString c - => String -> (String, c) -> Test + => String -> (String, c) -> TestTree (=:) = test rst -tests :: [Test] +tests :: [TestTree] tests = [ "line block with blank line" =: "| a\n|\n| b" =?> lineBlock [ "a", mempty, "\160b" ] , testGroup "field list" diff --git a/test/Tests/Readers/Txt2Tags.hs b/test/Tests/Readers/Txt2Tags.hs index 27ced0f5a..f6fa4f989 100644 --- a/test/Tests/Readers/Txt2Tags.hs +++ b/test/Tests/Readers/Txt2Tags.hs @@ -2,7 +2,7 @@ module Tests.Readers.Txt2Tags (tests) where import Data.List (intersperse) -import Test.Framework +import Test.Tasty import Tests.Helpers import Text.Pandoc import Text.Pandoc.Arbitrary () @@ -20,7 +20,7 @@ t2t = purely $ \s -> do infix 4 =: (=:) :: ToString c - => String -> (String, c) -> Test + => String -> (String, c) -> TestTree (=:) = test t2t spcSep :: [Inlines] -> Inlines @@ -32,7 +32,7 @@ simpleTable' :: Int -> Blocks simpleTable' n = table "" (take n $ repeat (AlignCenter, 0.0)) -tests :: [Test] +tests :: [TestTree] tests = [ testGroup "Inlines" $ [ "Plain String" =: -- cgit v1.2.3