git.iko.soy/typeable/pandoc
on master help sign in
Added 'tests' Cabal flag.

+ This ensures that test-pandoc gets built. + 'cabal test' now runs this. + The old tests/RunTests.hs has been removed, and src/test-pandoc.hs added.

commit605648cbbf03932f04ca7561a02926598b3a7242 authorJohn MacFarlane <jgm@berkeley.edu> dateWed 15 Dec 2010, 17:52 (16 years ago) parent63cf37a
3 files changed+37−16
Setup.hs+16−9 pandoc.cabal+21−7 tests/RunTests.hs → src/test-pandoc.hs
Setup.hs+16−9
@@ -9,8 +9,8 @@ import Distribution.Verbosity ( Verbosity, silent )
99import Distribution.Simple.InstallDirs (mandir, bindir, CopyDest (NoCopyDest))
1010import Distribution.Simple.Utils (copyFiles)
1111import Control.Exception ( bracket_ )
12−import Control.Monad ( unless )
13−import System.Process ( runCommand, runProcess, waitForProcess )
12+import Control.Monad ( unless, when )
13+import System.Process ( rawSystem, runCommand, runProcess, waitForProcess )
1414import System.FilePath ( (</>), (<.>) )
1515import System.Directory
1616import System.IO ( stderr )
@@ -38,13 +38,20 @@ main = do
3838
3939-- | Run test suite.
4040runTestSuite :: Args -> Bool -> PackageDescription -> LocalBuildInfo -> IO a
41−runTestSuite _ _ pkg _ = do
42− let isHighlightingKate (Dependency (PackageName "highlighting-kate") _) = True
43− isHighlightingKate _ = False
44− let highlightingSupport = any isHighlightingKate $ buildDepends pkg
45− let testArgs = ["lhs" | highlightingSupport]
46− let testCmd = "runhaskell -i.. RunTests.hs " ++ unwords testArgs
47− inDirectory "tests" $ runCommand testCmd >>= waitForProcess >>= exitWith
41+runTestSuite _ _ pkg lbi = do
42+ let testDir = buildDir lbi </> "test-pandoc"
43+ testDir' <- canonicalizePath testDir
44+ if any id [buildable (buildInfo exe) | exe <- executables pkg, exeName exe == "test-pandoc"]
45+ then do
46+ let isHighlightingKate (Dependency (PackageName "highlighting-kate") _) = True
47+ isHighlightingKate _ = False
48+ let highlightingSupport = any isHighlightingKate $ buildDepends pkg
49+ let testArgs = ["lhs" | highlightingSupport]
50+ inDirectory "tests" $ rawSystem (testDir' </> "test-pandoc")
51+ testArgs >>= exitWith
52+ else do
53+ putStrLn "Build pandoc with the 'tests' flag to run tests"
54+ exitWith $ ExitFailure 3
4855
4956-- | Build man pages from markdown sources in man/man1/.
5057makeManPages :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()
pandoc.cabal+21−7
@@ -74,7 +74,7 @@ Extra-Source-Files:
7474 -- code to create pandoc.1 man page
7575 MakeManPage.hs,
7676 manpage.template,
77− -- benchmarking
77+ -- benchmarks
7878 Benchmark.hs,
7979 -- tests
8080 tests/bodybg.gif,
@@ -136,8 +136,7 @@ Extra-Source-Files:
136136 tests/lhs-test.latex+lhs,
137137 tests/lhs-test.html,
138138 tests/lhs-test.html+lhs,
139− tests/lhs-test.fragment.html+lhs,
140− tests/RunTests.hs
139+ tests/lhs-test.fragment.html+lhs
141140Extra-Tmp-Files: man/man1/pandoc.1, man/man1/markdown2pdf.1
142141
143142Flag threaded
@@ -155,6 +154,12 @@ Flag library
155154Flag wrappers
156155 Description: Build the wrappers (markdown2pdf).
157156 Default: True
157+Flag tests
158+ Description: Build test-pandoc.
159+ Default: False
160+Flag benchmarks
161+ Description: Build benchmark-pandoc.
162+ Default: False
158163
159164Library
160165 -- Note: the following material must be in both Library and Executable stanzas.
@@ -261,9 +266,9 @@ Executable pandoc
261266
262267 Main-Is: pandoc.hs
263268 if flag(executable) || flag(wrappers)
264− Buildable: True
269+ Buildable: True
265270 else
266− Buildable: False
271+ Buildable: False
267272
268273Executable markdown2pdf
269274 Hs-Source-Dirs: src
@@ -275,7 +280,16 @@ Executable markdown2pdf
275280 Ghc-Prof-Options: -auto-all
276281 Extensions: CPP
277282 if flag(wrappers)
278− Buildable: True
283+ Buildable: True
279284 else
280− Buildable: False
285+ Buildable: False
286+
287+Executable test-pandoc
288+ Hs-Source-Dirs: src
289+ Main-Is: test-pandoc.hs
290+ if !flag(tests)
291+ Buildable: False
292+ else
293+ Ghc-Options: -Wall
294+ Build-Depends: base >= 4 && < 5, Diff, MissingH
281295
tests/RunTests.hs → src/test-pandoc.hsrenamed

The content is the same.