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.
This commit is contained in:
John MacFarlane 2012-07-26 09:43:27 -07:00
parent c414a08bcf
commit acbb4a5e46
3 changed files with 7 additions and 25 deletions

View file

@ -24,8 +24,7 @@ import Data.List ( (\\) )
main :: IO ()
main = do
defaultMainWithHooks $ simpleUserHooks {
runTests = runTestSuite
, postBuild = makeManPages
postBuild = makeManPages
, postCopy = \ _ flags pkg lbi ->
installManpages pkg lbi (fromFlag $ copyVerbosity flags)
(fromFlag $ copyDest flags)
@ -34,18 +33,6 @@ main = do
}
exitWith ExitSuccess
-- | Run test suite.
runTestSuite :: Args -> Bool -> PackageDescription -> LocalBuildInfo -> IO a
runTestSuite args _ pkg lbi = do
let testDir = buildDir lbi </> "test-pandoc"
testDir' <- canonicalizePath testDir
let testArgs = "--timeout=5" : concatMap (\arg -> ["-t",arg]) args
if any id [buildable (buildInfo exe) | exe <- executables pkg, exeName exe == "test-pandoc"]
then inDirectory "tests" $ rawSystem (testDir' </> "test-pandoc") testArgs >>= exitWith
else do
putStrLn "Build pandoc with the 'tests' flag to run tests"
exitWith $ ExitFailure 3
-- | Build man pages from markdown sources in man/
makeManPages :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()
makeManPages _ flags _ lbi = do

View file

@ -188,9 +188,6 @@ Flag executable
Flag library
Description: Build the pandoc library.
Default: True
Flag tests
Description: Build test-pandoc.
Default: False
Flag blaze_html_0_5
Description: Use blaze-html 0.5 and blaze-markup 0.5
Default: False
@ -373,9 +370,10 @@ Executable pandoc
else
Buildable: False
Executable test-pandoc
Main-Is: test-pandoc.hs
Hs-Source-Dirs: tests
Test-Suite test-pandoc
Type: exitcode-stdio-1.0
Main-Is: test-pandoc.hs
Hs-Source-Dirs: tests
if impl(ghc >= 6.10)
Build-depends: base >= 4 && < 5, syb >= 0.1 && < 0.4
else
@ -414,10 +412,6 @@ Executable test-pandoc
Ghc-Options: -O2 -Wall -fno-warn-unused-do-bind -dno-debug-output
else
Ghc-Options: -O2 -Wall
if !flag(tests)
Buildable: False
else
Buildable: True
if impl(ghc >= 7)
cpp-options: -D_LIT=lit
else

View file

@ -14,6 +14,7 @@ import qualified Tests.Writers.HTML
import qualified Tests.Writers.Native
import qualified Tests.Writers.Markdown
import qualified Tests.Shared
import Text.Pandoc.Shared (inDirectory)
tests :: [Test]
tests = [ testGroup "Old" Tests.Old.tests
@ -33,4 +34,4 @@ tests = [ testGroup "Old" Tests.Old.tests
]
main :: IO ()
main = defaultMain tests
main = inDirectory "tests" $ defaultMain tests