aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-01-04 17:44:26 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2019-01-04 17:44:26 -0800
commitae4a5f48584ae88fc4c812270ad9990b694f7398 (patch)
treef6aea6cee3fc556cb850cd93c57703a11f08a9ee
parent577ad44350eb7e5c1338efdd59dca3a15a4a112d (diff)
downloadpandoc-ae4a5f48584ae88fc4c812270ad9990b694f7398.tar.gz
Fix findPandoc so it works with cabalv2.
-rw-r--r--test/Tests/Helpers.hs31
-rw-r--r--test/test-pandoc.hs6
2 files changed, 28 insertions, 9 deletions
diff --git a/test/Tests/Helpers.hs b/test/Tests/Helpers.hs
index 1c031aa64..3a8058114 100644
--- a/test/Tests/Helpers.hs
+++ b/test/Tests/Helpers.hs
@@ -83,14 +83,29 @@ showDiff (l,r) (Both _ _ : ds) =
findPandoc :: IO FilePath
findPandoc = do
testExePath <- getExecutablePath
- let testExeDir = takeDirectory testExePath
- found <- doesFileExist (testExeDir </> "pandoc")
- return $ if found
- then testExeDir </> "pandoc"
- else case splitDirectories testExeDir of
- [] -> error "test-pandoc: empty testExeDir"
- xs -> joinPath (init xs) </> "pandoc" </> "pandoc"
-
+ curdir <- getCurrentDirectory
+ let relTestExePathParts = splitDirectories $ makeRelative curdir $
+ takeDirectory testExePath
+ let pandocPath =
+ (case reverse relTestExePathParts of
+ -- cabalv2 with --disable-optimization
+ "test-pandoc" : "build" : "noopt" : "test-pandoc" : "t" : ps
+ -> joinPath (reverse ps) </>
+ "x" </> "pandoc" </> "noopt" </> "build" </> "pandoc"
+ -- cabalv2 without --disable-optimization
+ "test-pandoc" : "build" : "test-pandoc" : "t" : ps
+ -> joinPath (reverse ps) </>
+ "x" </> "pandoc" </> "build" </> "pandoc"
+ -- cabalv1
+ "test-pandoc" : "build" : ps
+ -> joinPath (reverse ps) </> "build" </> "pandoc"
+ _ -> error $ "findPandoc: could not find pandoc executable")
+ </> "pandoc"
+ found <- doesFileExist pandocPath
+ if found
+ then return pandocPath
+ else error $ "findPandoc: could not find pandoc executable at "
+ ++ pandocPath
vividize :: Diff String -> String
vividize (Both s _) = " " ++ s
diff --git a/test/test-pandoc.hs b/test/test-pandoc.hs
index dc51b73cc..63560936c 100644
--- a/test/test-pandoc.hs
+++ b/test/test-pandoc.hs
@@ -40,6 +40,7 @@ import qualified Tests.Writers.Plain
import qualified Tests.Writers.Powerpoint
import qualified Tests.Writers.RST
import qualified Tests.Writers.TEI
+import Tests.Helpers (findPandoc)
import Text.Pandoc.Shared (inDirectory)
tests :: TestTree
@@ -86,4 +87,7 @@ tests = testGroup "pandoc tests" [ Tests.Command.tests
main :: IO ()
main = do
setLocaleEncoding utf8
- inDirectory "test" $ defaultMain tests
+ inDirectory "test" $ do
+ fp <- findPandoc
+ putStrLn $ "Using pandoc executable at " ++ fp
+ defaultMain tests