git.iko.soy/typeable/pandoc
on master help sign in
Fix findPandoc so it works with cabalv2.
commitae4a5f48584ae88fc4c812270ad9990b694f7398 authorJohn MacFarlane <jgm@berkeley.edu> dateFri 4 Jan 2019, 17:44 (8 years ago) parent577ad44
2 files changed+28−9
test/Tests/Helpers.hs+23−8 test/test-pandoc.hs+5−1
test/Tests/Helpers.hs+23−8
@@ -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
test/test-pandoc.hs+5−1
@@ -40,6 +40,7 @@ import qualified Tests.Writers.Plain
4040import qualified Tests.Writers.Powerpoint
4141import qualified Tests.Writers.RST
4242import qualified Tests.Writers.TEI
43+import Tests.Helpers (findPandoc)
4344import Text.Pandoc.Shared (inDirectory)
4445
4546tests :: TestTree
@@ -86,4 +87,7 @@ tests = testGroup "pandoc tests" [ Tests.Command.tests
8687main :: IO ()
8788main = do
8889 setLocaleEncoding utf8
89− inDirectory "test" $ defaultMain tests
90+ inDirectory "test" $ do
91+ fp <- findPandoc
92+ putStrLn $ "Using pandoc executable at " ++ fp
93+ defaultMain tests