git.iko.soy/typeable/pandoc
on master help sign in
Fixed tests with dynamic linking.
65c0e52John MacFarlane
tests/Tests/Old.hs+12−3
@@ -6,7 +6,8 @@ import Test.HUnit ( assertBool )
6import System.Environment.Executable (getExecutablePath)
6import System.Environment.Executable (getExecutablePath)
7import System.IO ( openTempFile, stderr )
7import System.IO ( openTempFile, stderr )
8import System.Process ( runProcess, waitForProcess )
8import System.Process ( runProcess, waitForProcess )
9−import System.FilePath ( (</>), (<.>), takeDirectory, splitDirectories, joinPath )
9+import System.FilePath ( (</>), (<.>), takeDirectory, splitDirectories,
10+ joinPath )
10import System.Directory
11import System.Directory
11import System.Exit
12import System.Exit
12import Data.Algorithm.Diff
13import Data.Algorithm.Diff
@@ -260,9 +261,17 @@ testWithNormalize normalizer testname opts inp norm = testCase testname $ do
260 let normPath = norm
261 let normPath = norm
261 let options = ["--data-dir", ".." </> "data"] ++ [inpPath] ++ opts
262 let options = ["--data-dir", ".." </> "data"] ++ [inpPath] ++ opts
262 let cmd = pandocPath ++ " " ++ unwords options
263 let cmd = pandocPath ++ " " ++ unwords options
264+ let findDynlibDir [] = Nothing
265+ findDynlibDir ("build":xs) = Just $ joinPath (reverse xs) </> "build"
266+ findDynlibDir (_:xs) = findDynlibDir xs
267+ let mbDynlibDir = findDynlibDir (reverse $ splitDirectories pandocPath)
268+ let dynlibEnv = case mbDynlibDir of
269+ Nothing -> []
270+ Just d -> [("DYLD_LIBRARY_PATH", d),
271+ ("LD_LIBRARY_PATH", d)]
272+ let env = dynlibEnv ++ [("TMP","."),("LANG","en_US.UTF-8"),("HOME", "./")]
263 ph <- runProcess pandocPath options Nothing
273 ph <- runProcess pandocPath options Nothing
264− (Just [("TMP","."),("LANG","en_US.UTF-8"),("HOME", "./")]) Nothing (Just hOut)
274+ (Just env) Nothing (Just hOut) (Just stderr)
265− (Just stderr)
266 ec <- waitForProcess ph
275 ec <- waitForProcess ph
267 result <- if ec == ExitSuccess
276 result <- if ec == ExitSuccess
268 then do
277 then do