git.iko.soy/typeable/pandoc
on master help sign in
Integrated test suite with cabal.
acbb4a5John MacFarlane
Setup.hs+1−14
@@ -24,8 +24,7 @@ import Data.List ( (\\) )
24main :: IO ()
24main :: IO ()
25main = do
25main = do
26 defaultMainWithHooks $ simpleUserHooks {
26 defaultMainWithHooks $ simpleUserHooks {
27− runTests = runTestSuite
28− , postBuild = makeManPages
27+ postBuild = makeManPages
29 , postCopy = \ _ flags pkg lbi ->
28 , postCopy = \ _ flags pkg lbi ->
30 installManpages pkg lbi (fromFlag $ copyVerbosity flags)
29 installManpages pkg lbi (fromFlag $ copyVerbosity flags)
31 (fromFlag $ copyDest flags)
30 (fromFlag $ copyDest flags)
@@ -34,18 +33,6 @@ main = do
34 }
33 }
35 exitWith ExitSuccess
34 exitWith ExitSuccess
36
35
37−-- | Run test suite.
38−runTestSuite :: Args -> Bool -> PackageDescription -> LocalBuildInfo -> IO a
39−runTestSuite args _ pkg lbi = do
40− let testDir = buildDir lbi </> "test-pandoc"
41− testDir' <- canonicalizePath testDir
42− let testArgs = "--timeout=5" : concatMap (\arg -> ["-t",arg]) args
43− if any id [buildable (buildInfo exe) | exe <- executables pkg, exeName exe == "test-pandoc"]
44− then inDirectory "tests" $ rawSystem (testDir' </> "test-pandoc") testArgs >>= exitWith
45− else do
46− putStrLn "Build pandoc with the 'tests' flag to run tests"
47− exitWith $ ExitFailure 3
48−
49-- | Build man pages from markdown sources in man/
36-- | Build man pages from markdown sources in man/
50makeManPages :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()
37makeManPages :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()
51makeManPages _ flags _ lbi = do
38makeManPages _ flags _ lbi = do
pandoc.cabal+4−10
@@ -188,9 +188,6 @@ Flag executable
188Flag library
188Flag library
189 Description: Build the pandoc library.
189 Description: Build the pandoc library.
190 Default: True
190 Default: True
191−Flag tests
192− Description: Build test-pandoc.
193− Default: False
194Flag blaze_html_0_5
191Flag blaze_html_0_5
195 Description: Use blaze-html 0.5 and blaze-markup 0.5
192 Description: Use blaze-html 0.5 and blaze-markup 0.5
196 Default: False
193 Default: False
@@ -373,9 +370,10 @@ Executable pandoc
373 else
370 else
374 Buildable: False
371 Buildable: False
375
372
376−Executable test-pandoc
373+Test-Suite test-pandoc
374+ Type: exitcode-stdio-1.0
377− Main-Is: test-pandoc.hs
375+ Main-Is: test-pandoc.hs
378− Hs-Source-Dirs: tests
376+ Hs-Source-Dirs: tests
379 if impl(ghc >= 6.10)
377 if impl(ghc >= 6.10)
380 Build-depends: base >= 4 && < 5, syb >= 0.1 && < 0.4
378 Build-depends: base >= 4 && < 5, syb >= 0.1 && < 0.4
381 else
379 else
@@ -414,10 +412,6 @@ Executable test-pandoc
414 Ghc-Options: -O2 -Wall -fno-warn-unused-do-bind -dno-debug-output
412 Ghc-Options: -O2 -Wall -fno-warn-unused-do-bind -dno-debug-output
415 else
413 else
416 Ghc-Options: -O2 -Wall
414 Ghc-Options: -O2 -Wall
417− if !flag(tests)
418− Buildable: False
419− else
420− Buildable: True
421 if impl(ghc >= 7)
415 if impl(ghc >= 7)
422 cpp-options: -D_LIT=lit
416 cpp-options: -D_LIT=lit
423 else
417 else
tests/test-pandoc.hs+2−1
@@ -14,6 +14,7 @@ import qualified Tests.Writers.HTML
14import qualified Tests.Writers.Native
14import qualified Tests.Writers.Native
15import qualified Tests.Writers.Markdown
15import qualified Tests.Writers.Markdown
16import qualified Tests.Shared
16import qualified Tests.Shared
17+import Text.Pandoc.Shared (inDirectory)
17
18
18tests :: [Test]
19tests :: [Test]
19tests = [ testGroup "Old" Tests.Old.tests
20tests = [ testGroup "Old" Tests.Old.tests
@@ -33,4 +34,4 @@ tests = [ testGroup "Old" Tests.Old.tests
33 ]
34 ]
34
35
35main :: IO ()
36main :: IO ()
36−main = defaultMain tests
37+main = inDirectory "tests" $ defaultMain tests