@@ -83,14 +83,29 @@ showDiff (l,r) (Both _ _ : ds) =
8383findPandoc :: IO FilePath
8484findPandoc = do
8585 testExePath <- getExecutablePath
86− let testExeDir = takeDirectory testExePath
87− found <- doesFileExist (testExeDir </> "pandoc")
88− return $ if found
89− then testExeDir </> "pandoc"
90− else case splitDirectories testExeDir of
91− [] -> error "test-pandoc: empty testExeDir"
92− xs -> joinPath (init xs) </> "pandoc" </> "pandoc"
93−
86+ curdir <- getCurrentDirectory
87+ let relTestExePathParts = splitDirectories $ makeRelative curdir $
88+ takeDirectory testExePath
89+ let pandocPath =
90+ (case reverse relTestExePathParts of
91+ -- cabalv2 with --disable-optimization
92+ "test-pandoc" : "build" : "noopt" : "test-pandoc" : "t" : ps
93+ -> joinPath (reverse ps) </>
94+ "x" </> "pandoc" </> "noopt" </> "build" </> "pandoc"
95+ -- cabalv2 without --disable-optimization
96+ "test-pandoc" : "build" : "test-pandoc" : "t" : ps
97+ -> joinPath (reverse ps) </>
98+ "x" </> "pandoc" </> "build" </> "pandoc"
99+ -- cabalv1
100+ "test-pandoc" : "build" : ps
101+ -> joinPath (reverse ps) </> "build" </> "pandoc"
102+ _ -> error $ "findPandoc: could not find pandoc executable")
103+ </> "pandoc"
104+ found <- doesFileExist pandocPath
105+ if found
106+ then return pandocPath
107+ else error $ "findPandoc: could not find pandoc executable at "
108+ ++ pandocPath
94109
95110vividize :: Diff String -> String
96111vividize (Both s _) = " " ++ s