diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-08-13 08:12:07 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-08-13 08:12:07 -0700 |
commit | 1d6e1cf9f3d45147538aee639e00a3ae95260055 (patch) | |
tree | 04328a2c7db0e54a7dd6c80464671a91237fcad9 | |
parent | 22ab3367c6ce7a87a479a4630a6ba4305ad5d333 (diff) | |
download | pandoc-1d6e1cf9f3d45147538aee639e00a3ae95260055.tar.gz |
Removed special testHook from Setup.
This was just too fragile and dependent on a changing Cabal API
(see #1526).
Instead of passing the bulid directory to the test program, we
now let the test program find itself (using executable-path)
and then find the pandoc executable relative to itself.
-rw-r--r-- | Setup.hs | 4 | ||||
-rw-r--r-- | pandoc.cabal | 1 | ||||
-rw-r--r-- | tests/Tests/Old.hs | 19 |
3 files changed, 13 insertions, 11 deletions
@@ -38,10 +38,6 @@ main :: IO () main = do defaultMainWithHooks $ simpleUserHooks { postBuild = makeManPages - , testHook = \pkg lbi _ flags -> - -- pass build directory as first argument to test program - test pkg lbi flags{ testOptions = - toPathTemplate (buildDir lbi) : testOptions flags } , postCopy = \ _ flags pkg lbi -> installManpages pkg lbi (fromFlag $ copyVerbosity flags) (fromFlag $ copyDest flags) diff --git a/pandoc.cabal b/pandoc.cabal index 39e901614..80fd994e6 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -406,6 +406,7 @@ Test-Suite test-pandoc HUnit >= 1.2 && < 1.3, containers >= 0.1 && < 0.6, ansi-terminal >= 0.5 && < 0.7, + executable-path >= 0.0 && < 0.1, zip-archive >= 0.2.3.4 && < 0.3 Other-Modules: Tests.Old Tests.Helpers diff --git a/tests/Tests/Old.hs b/tests/Tests/Old.hs index 7278ec720..8ecbdbbba 100644 --- a/tests/Tests/Old.hs +++ b/tests/Tests/Old.hs @@ -3,10 +3,10 @@ module Tests.Old (tests) where import Test.Framework (testGroup, Test ) import Test.Framework.Providers.HUnit import Test.HUnit ( assertBool ) -import System.Environment ( getArgs ) +import System.Environment.Executable (getExecutablePath) import System.IO ( openTempFile, stderr ) import System.Process ( runProcess, waitForProcess ) -import System.FilePath ( (</>), (<.>) ) +import System.FilePath ( (</>), (<.>), takeDirectory ) import System.Directory import System.Exit import Data.Algorithm.Diff @@ -225,11 +225,16 @@ testWithNormalize :: (String -> String) -- ^ Normalize function for output -> FilePath -- ^ Norm (for test results) filepath -> Test testWithNormalize normalizer testname opts inp norm = testCase testname $ do - args <- getArgs - let buildDir = case args of - (x:_) -> ".." </> x - _ -> error "test-pandoc: missing buildDir argument" - let pandocPath = buildDir </> "pandoc" </> "pandoc" + -- find pandoc executable relative to test-pandoc + -- First, try in same directory (e.g. if both in ~/.cabal/bin) + -- Second, try ../pandoc (e.g. if in dist/XXX/build/test-pandoc) + pandocPath <- do + testExePath <- getExecutablePath + let testExeDir = takeDirectory testExePath + found <- doesFileExist (testExeDir </> "pandoc") + return $ if found + then testExeDir </> "pandoc" + else testExeDir </> ".." </> "pandoc" </> "pandoc" (outputPath, hOut) <- openTempFile "" "pandoc-test" let inpPath = inp let normPath = norm |