@@ -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 ()