git.iko.soy/typeable/pandoc
on master help sign in
Removed run prefix from all test functions.
commitf3ee73607fd33a4ea6292ca02ba195ede075278b authorNathan Gass <gass@search.ch> dateTue 11 Jan 2011, 21:30 (16 years ago) parenta2153ac
1 file changed+68−70
src/test-pandoc.hs+68−70
src/test-pandoc.hs+68−70
@@ -16,8 +16,7 @@ module Main where
1616
1717import Test.Framework (defaultMain, testGroup, Test )
1818import Test.Framework.Providers.HUnit
19−
20−import Test.HUnit hiding ( Test )
19+import Test.HUnit ( assertBool )
2120
2221import System.IO ( openTempFile, stderr )
2322import System.Process ( runProcess, waitForProcess )
@@ -52,64 +51,53 @@ showDiff ((F, ln) : ds) = "|TEST| " ++ ln ++ "\n" ++ showDiff ds
5251showDiff ((S, ln) : ds) = "|NORM| " ++ ln ++ "\n" ++ showDiff ds
5352showDiff ((B, _ ) : ds) = showDiff ds
5453
55−markdownCitationTest :: Test
56−markdownCitationTest
57− = testGroup "citations" $ map styleToTest ["chicago-author-date","ieee","mhra"]
58− ++ [runTest "no-citeproc" wopts "markdown-citations.txt" "markdown-citations.txt"]
59− where
60− ropts = ["-r", "markdown", "-w", "markdown", "--bibliography", "biblio.bib", "--no-wrap"]
61− wopts = ropts ++ ["--no-citeproc"]
62− styleToTest style = runTest style (ropts ++ ["--csl", style ++ ".csl"])
63− "markdown-citations.txt" ("markdown-citations." ++ style ++ ".txt")
64−
65−
6654tests :: [Test]
67−tests = [ testGroup "markdown" [ testGroup "writer" (runWriterTests "markdown" ++ runLhsWriterTests "markdown")
68− , testGroup "reader" [ runTest "basic" ["-r", "markdown", "-w", "native", "-s", "-S"]
55+tests = [ testGroup "markdown" [ testGroup "writer" (writerTests "markdown" ++ lhsWriterTests "markdown")
56+ , testGroup "reader" [ test "basic" ["-r", "markdown", "-w", "native", "-s", "-S"]
6957 "testsuite.txt" "testsuite.native"
70− , runTest "tables" ["-r", "markdown", "-w", "native"]
58+ , test "tables" ["-r", "markdown", "-w", "native"]
7159 "tables.txt" "tables.native"
72− , runTest "more" ["-r", "markdown", "-w", "native", "-S"]
60+ , test "more" ["-r", "markdown", "-w", "native", "-S"]
7361 "markdown-reader-more.txt" "markdown-reader-more.native"
74− , runLhsReaderTest "markdown+lhs"
62+ , lhsReaderTest "markdown+lhs"
7563 ]
76− , markdownCitationTest
64+ , testGroup "citations" markdownCitationTests
7765 ]
78− , testGroup "rst" [ testGroup "writer" (runWriterTests "rst" ++ runLhsWriterTests "rst")
79− , testGroup "reader" [ runTest "basic" ["-r", "rst", "-w", "native", "-s", "-S"]
66+ , testGroup "rst" [ testGroup "writer" (writerTests "rst" ++ lhsWriterTests "rst")
67+ , testGroup "reader" [ test "basic" ["-r", "rst", "-w", "native", "-s", "-S"]
8068 "rst-reader.rst" "rst-reader.native"
81− , runTest "tables" ["-r", "rst", "-w", "native"]
69+ , test "tables" ["-r", "rst", "-w", "native"]
8270 "tables.rst" "tables-rstsubset.native"
83− , runLhsReaderTest "rst+lhs"
71+ , lhsReaderTest "rst+lhs"
8472 ]
8573 ]
86− , testGroup "latex" [ testGroup "writer" (runWriterTests "latex" ++ runLhsWriterTests "latex")
87− , testGroup "reader" [ runTest "basic" ["-r", "latex", "-w", "native", "-s", "-R"]
74+ , testGroup "latex" [ testGroup "writer" (writerTests "latex" ++ lhsWriterTests "latex")
75+ , testGroup "reader" [ test "basic" ["-r", "latex", "-w", "native", "-s", "-R"]
8876 "latex-reader.latex" "latex-reader.native"
89− , runLhsReaderTest "latex+lhs"
77+ , lhsReaderTest "latex+lhs"
9078 ]
91− , runLatexCitationTests "biblatex"
92− , runLatexCitationTests "natbib"
79+ , latexCitationTests "biblatex"
80+ , latexCitationTests "natbib"
9381 ]
94− , testGroup "html" [ testGroup "writer" (runWriterTests "html" ++ runLhsWriterTests "html")
95− , runTest "reader" ["-r", "html", "-w", "native", "-s"]
82+ , testGroup "html" [ testGroup "writer" (writerTests "html" ++ lhsWriterTests "html")
83+ , test "reader" ["-r", "html", "-w", "native", "-s"]
9684 "html-reader.html" "html-reader.native"
9785 ]
98− , testGroup "s5" [ runS5WriterTest "basic" ["-s"] "s5"
99− , runS5WriterTest "fancy" ["-s","-m","-i"] "s5"
100− , runS5WriterTest "fragment" [] "html"
101− , runS5WriterTest "inserts" ["-s", "-H", "insert",
86+ , testGroup "s5" [ s5WriterTest "basic" ["-s"] "s5"
87+ , s5WriterTest "fancy" ["-s","-m","-i"] "s5"
88+ , s5WriterTest "fragment" [] "html"
89+ , s5WriterTest "inserts" ["-s", "-H", "insert",
10290 "-B", "insert", "-A", "insert", "-c", "main.css"] "html"
10391 ]
104− , testGroup "textile" [ testGroup "writer" $ runWriterTests "textile"
105− , runTest "reader" ["-r", "textile", "-w", "native", "-s"]
92+ , testGroup "textile" [ testGroup "writer" $ writerTests "textile"
93+ , test "reader" ["-r", "textile", "-w", "native", "-s"]
10694 "textile-reader.textile" "textile-reader.native"
10795 ]
108− , testGroup "native" [ testGroup "writer" $ runWriterTests "native"
109− , runTest "reader" ["-r", "native", "-w", "native", "-s"]
96+ , testGroup "native" [ testGroup "writer" $ writerTests "native"
97+ , test "reader" ["-r", "native", "-w", "native", "-s"]
11098 "testsuite.native" "testsuite.native"
11199 ]
112− , testGroup "other writers" $ map (\f -> testGroup f $ runWriterTests f)
100+ , testGroup "other writers" $ map (\f -> testGroup f $ writerTests f)
113101 [ "docbook", "opendocument" , "context" , "texinfo"
114102 , "man" , "plain" , "mediawiki", "rtf", "org"
115103 ]
@@ -123,63 +111,73 @@ readFile' :: FilePath -> IO String
123111readFile' f = do s <- readFileUTF8 f
124112 return $! (length s `seq` s)
125113
126−runLhsWriterTests :: String -> [Test]
127−runLhsWriterTests format
114+lhsWriterTests :: String -> [Test]
115+lhsWriterTests format
128116 = [ t "lhs to normal" format
129117 , t "lhs to lhs" (format ++ "+lhs")
130118 ]
131119 where
132− t n f = runTest n ["--columns=78", "-r", "native", "-s", "-w", f]
120+ t n f = test n ["--columns=78", "-r", "native", "-s", "-w", f]
133121 "lhs-test.native" ("lhs-test" <.> f)
134122
135−runLhsReaderTest :: String -> Test
136−runLhsReaderTest format =
137− runTest "lhs" ["-r", format, "-w", "html+lhs"] ("lhs-test" <.> format) "lhs-test.fragment.html+lhs"
123+lhsReaderTest :: String -> Test
124+lhsReaderTest format =
125+ test "lhs" ["-r", format, "-w", "html+lhs"] ("lhs-test" <.> format) "lhs-test.fragment.html+lhs"
138126
139127
140−runLatexCitationTests :: String -> Test
141−runLatexCitationTests n
128+latexCitationTests :: String -> Test
129+latexCitationTests n
142130 = testGroup (n ++ " citations")
143− [ rt ("latex reader (" ++ n ++ " citations)") (["-r", "latex", "-w", "markdown", "-s", "--no-wrap"] ++ o)
131+ [ t ("latex reader (" ++ n ++ " citations)") (["-r", "latex", "-w", "markdown", "-s", "--no-wrap"] ++ o)
144132 f "markdown-citations.txt"
145− , rt ("latex writer (" ++ n ++ " citations)") (["-r", "markdown", "-w", "latex", "-s", "--no-wrap"] ++ o)
133+ , t ("latex writer (" ++ n ++ " citations)") (["-r", "markdown", "-w", "latex", "-s", "--no-wrap"] ++ o)
146134 "markdown-citations.txt" f
147135 ]
148136 where
149137 o = ["--bibliography", "biblio.bib", "--csl", "chicago-author-date.csl", "--no-citeproc", "--" ++ n]
150138 f = n ++ "-citations.latex"
151139 normalize = substitute "\160" " " . substitute "\8211" "-"
152− rt = runTestWithNormalize normalize
140+ t = testWithNormalize normalize
153141
154−runWriterTests :: String -> [Test]
155−runWriterTests format
156− = [ runTest "basic" (opts ++ ["-s"]) "testsuite.native" ("writer" <.> format)
157− , runTest "tables" opts "tables.native" ("tables" <.> format)
142+writerTests :: String -> [Test]
143+writerTests format
144+ = [ test "basic" (opts ++ ["-s"]) "testsuite.native" ("writer" <.> format)
145+ , test "tables" opts "tables.native" ("tables" <.> format)
158146 ]
159147 where
160148 opts = ["-r", "native", "-w", format, "--columns=78"]
161149
162−runS5WriterTest :: String -> [String] -> String -> Test
163−runS5WriterTest modifier opts format = runTest (format ++ " writer (" ++ modifier ++ ")")
164− (["-r", "native", "-w", format] ++ opts) "s5.native" ("s5." ++ modifier <.> "html")
150+s5WriterTest :: String -> [String] -> String -> Test
151+s5WriterTest modifier opts format
152+ = test (format ++ " writer (" ++ modifier ++ ")") (["-r", "native", "-w", format] ++ opts)
153+ "s5.native" ("s5." ++ modifier <.> "html")
165154
155+markdownCitationTests :: [Test]
156+markdownCitationTests
157+ = map styleToTest ["chicago-author-date","ieee","mhra"]
158+ ++ [test "no-citeproc" wopts "markdown-citations.txt" "markdown-citations.txt"]
159+ where
160+ ropts = ["-r", "markdown", "-w", "markdown", "--bibliography", "biblio.bib", "--no-wrap"]
161+ wopts = ropts ++ ["--no-citeproc"]
162+ styleToTest style = test style (ropts ++ ["--csl", style ++ ".csl"])
163+ "markdown-citations.txt" ("markdown-citations." ++ style ++ ".txt")
166164
167165-- | Run a test without normalize function, return True if test passed.
168−runTest :: String -- ^ Title of test
169− -> [String] -- ^ Options to pass to pandoc
170− -> String -- ^ Input filepath
171− -> FilePath -- ^ Norm (for test results) filepath
172− -> Test
173−runTest = runTestWithNormalize id
166+test :: String -- ^ Title of test
167+ -> [String] -- ^ Options to pass to pandoc
168+ -> String -- ^ Input filepath
169+ -> FilePath -- ^ Norm (for test results) filepath
170+ -> Test
171+test = testWithNormalize id
174172
175173-- | Run a test with normalize function, return True if test passed.
176−runTestWithNormalize :: (String -> String) -- ^ Normalize function for output
177− -> String -- ^ Title of test
178− -> [String] -- ^ Options to pass to pandoc
179− -> String -- ^ Input filepath
180− -> FilePath -- ^ Norm (for test results) filepath
181− -> Test
182−runTestWithNormalize normalize testname opts inp norm = testCase testname $ do
174+testWithNormalize :: (String -> String) -- ^ Normalize function for output
175+ -> String -- ^ Title of test
176+ -> [String] -- ^ Options to pass to pandoc
177+ -> String -- ^ Input filepath
178+ -> FilePath -- ^ Norm (for test results) filepath
179+ -> Test
180+testWithNormalize normalize testname opts inp norm = testCase testname $ do
183181 (outputPath, hOut) <- openTempFile "" "pandoc-test"
184182 let inpPath = inp
185183 let normPath = norm