From 4ac036fe13928d31b2b84d4143891ad0831f0455 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 4 Jan 2019 20:14:24 -0800 Subject: Cleaned up findPandoc. --- test/Tests/Helpers.hs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'test/Tests') 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 -- cgit v1.2.3