aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-01-04 20:14:24 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2019-01-04 20:14:24 -0800
commit4ac036fe13928d31b2b84d4143891ad0831f0455 (patch)
treef998fc0152b4709d46b9362377624e7801fe4ae1
parentfc87925b772b3e0e47cbdb30878e0288f1bb6853 (diff)
downloadpandoc-4ac036fe13928d31b2b84d4143891ad0831f0455.tar.gz
Cleaned up findPandoc.
-rw-r--r--test/Tests/Helpers.hs16
1 files changed, 5 insertions, 11 deletions
diff --git a/test/Tests/Helpers.hs b/test/Tests/Helpers.hs
index 5e3afe0c7..80bb559b0 100644
--- a/test/Tests/Helpers.hs
+++ b/test/Tests/Helpers.hs
@@ -79,16 +79,11 @@ showDiff (l,r) (Both _ _ : ds) =
showDiff (l+1,r+1) ds
-- | 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)
findPandoc :: IO FilePath
findPandoc = do
testExePath <- getExecutablePath
- curdir <- getCurrentDirectory
- let relTestExePathParts = splitDirectories $ makeRelative curdir $
- takeDirectory testExePath
- let pandocPath =
- (case reverse relTestExePathParts of
+ let pandocDir =
+ case reverse (splitDirectories (takeDirectory testExePath)) of
-- cabalv2 with --disable-optimization
"test-pandoc" : "build" : "noopt" : "test-pandoc" : "t" : ps
-> joinPath (reverse ps) </>
@@ -100,11 +95,10 @@ findPandoc = do
-- cabalv1
"test-pandoc" : "build" : ps
-> joinPath (reverse ps) </> "build" </> "pandoc"
- _ -> error $ "findPandoc: could not find pandoc executable")
+ _ -> error $ "findPandoc: could not find pandoc executable"
+ let pandocPath = pandocDir </> "pandoc"
#ifdef _WINDOWS
- </> "pandoc" <.> "exe"
-#else
- </> "pandoc"
+ <.> "exe"
#endif
found <- doesFileExist pandocPath
if found