git.iko.soy/typeable/pandoc
on master help sign in
Integrated test suite with cabal.

To run tests, configure with --enable-tests, then 'cabal test'. You can specify particular tests using --test-options='-t markdown'. No output is shown unless tests fail. In the future, we can move to the detailed-1.0 interface.

commitacbb4a5e46f01d15ff1b7082d574b624bb22d1b1 authorJohn MacFarlane <jgm@berkeley.edu> dateThu 26 Jul 2012, 09:43 (14 years ago) parentc414a08
3 files changed+7−25
Setup.hs+1−14 pandoc.cabal+4−10 tests/test-pandoc.hs+2−1
Setup.hs+1−14
@@ -24,8 +24,7 @@ import Data.List ( (\\) )
2424main :: IO ()
2525main = do
2626 defaultMainWithHooks $ simpleUserHooks {
27− runTests = runTestSuite
28− , postBuild = makeManPages
27+ postBuild = makeManPages
2928 , postCopy = \ _ flags pkg lbi ->
3029 installManpages pkg lbi (fromFlag $ copyVerbosity flags)
3130 (fromFlag $ copyDest flags)
@@ -34,18 +33,6 @@ main = do
3433 }
3534 exitWith ExitSuccess
3635
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−
4936-- | Build man pages from markdown sources in man/
5037makeManPages :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()
5138makeManPages _ flags _ lbi = do
pandoc.cabal+4−10
@@ -188,9 +188,6 @@ Flag executable
188188Flag library
189189 Description: Build the pandoc library.
190190 Default: True
191−Flag tests
192− Description: Build test-pandoc.
193− Default: False
194191Flag blaze_html_0_5
195192 Description: Use blaze-html 0.5 and blaze-markup 0.5
196193 Default: False
@@ -373,9 +370,10 @@ Executable pandoc
373370 else
374371 Buildable: False
375372
376−Executable test-pandoc
377− Main-Is: test-pandoc.hs
378− Hs-Source-Dirs: tests
373+Test-Suite test-pandoc
374+ Type: exitcode-stdio-1.0
375+ Main-Is: test-pandoc.hs
376+ Hs-Source-Dirs: tests
379377 if impl(ghc >= 6.10)
380378 Build-depends: base >= 4 && < 5, syb >= 0.1 && < 0.4
381379 else
@@ -414,10 +412,6 @@ Executable test-pandoc
414412 Ghc-Options: -O2 -Wall -fno-warn-unused-do-bind -dno-debug-output
415413 else
416414 Ghc-Options: -O2 -Wall
417− if !flag(tests)
418− Buildable: False
419− else
420− Buildable: True
421415 if impl(ghc >= 7)
422416 cpp-options: -D_LIT=lit
423417 else
tests/test-pandoc.hs+2−1
@@ -14,6 +14,7 @@ import qualified Tests.Writers.HTML
1414import qualified Tests.Writers.Native
1515import qualified Tests.Writers.Markdown
1616import qualified Tests.Shared
17+import Text.Pandoc.Shared (inDirectory)
1718
1819tests :: [Test]
1920tests = [ testGroup "Old" Tests.Old.tests
@@ -33,4 +34,4 @@ tests = [ testGroup "Old" Tests.Old.tests
3334 ]
3435
3536main :: IO ()
36−main = defaultMain tests
37+main = inDirectory "tests" $ defaultMain tests