diff options
author | John MacFarlane <jgm@berkeley.edu> | 2010-12-15 17:52:35 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2010-12-15 17:54:51 -0800 |
commit | 605648cbbf03932f04ca7561a02926598b3a7242 (patch) | |
tree | da4bebe994f63d0dd0c6736613cb4ca430475d3f /Setup.hs | |
parent | 63cf37a9ca0cd9ffbc0a7a7091c5420f68a09dfe (diff) | |
download | pandoc-605648cbbf03932f04ca7561a02926598b3a7242.tar.gz |
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.
Diffstat (limited to 'Setup.hs')
-rw-r--r-- | Setup.hs | 25 |
1 files changed, 16 insertions, 9 deletions
@@ -9,8 +9,8 @@ import Distribution.Verbosity ( Verbosity, silent ) import Distribution.Simple.InstallDirs (mandir, bindir, CopyDest (NoCopyDest)) import Distribution.Simple.Utils (copyFiles) import Control.Exception ( bracket_ ) -import Control.Monad ( unless ) -import System.Process ( runCommand, runProcess, waitForProcess ) +import Control.Monad ( unless, when ) +import System.Process ( rawSystem, runCommand, runProcess, waitForProcess ) import System.FilePath ( (</>), (<.>) ) import System.Directory import System.IO ( stderr ) @@ -38,13 +38,20 @@ main = do -- | Run test suite. runTestSuite :: Args -> Bool -> PackageDescription -> LocalBuildInfo -> IO a -runTestSuite _ _ pkg _ = do - let isHighlightingKate (Dependency (PackageName "highlighting-kate") _) = True - isHighlightingKate _ = False - let highlightingSupport = any isHighlightingKate $ buildDepends pkg - let testArgs = ["lhs" | highlightingSupport] - let testCmd = "runhaskell -i.. RunTests.hs " ++ unwords testArgs - inDirectory "tests" $ runCommand testCmd >>= waitForProcess >>= exitWith +runTestSuite _ _ pkg lbi = do + let testDir = buildDir lbi </> "test-pandoc" + testDir' <- canonicalizePath testDir + if any id [buildable (buildInfo exe) | exe <- executables pkg, exeName exe == "test-pandoc"] + then do + let isHighlightingKate (Dependency (PackageName "highlighting-kate") _) = True + isHighlightingKate _ = False + let highlightingSupport = any isHighlightingKate $ buildDepends pkg + let testArgs = ["lhs" | highlightingSupport] + 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/man1/. makeManPages :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO () |