diff options
author | Lila <lila91142@gmail.com> | 2020-05-19 07:46:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-18 22:46:14 -0700 |
commit | c04800305e97a42d2d346fc6b0425817056438b7 (patch) | |
tree | 70d433a976ed162980cd08ffeece3c84d1ad3b8a /test | |
parent | f4185fcef0aa5c00e37a1bf8bbc8b8c6459fffe7 (diff) | |
download | pandoc-c04800305e97a42d2d346fc6b0425817056438b7.tar.gz |
Propagate (DY)LD_LIBRARY_PATH in tests (#6376)
Diffstat (limited to 'test')
-rw-r--r-- | test/Tests/Command.hs | 12 | ||||
-rw-r--r-- | test/Tests/Old.hs | 11 |
2 files changed, 14 insertions, 9 deletions
diff --git a/test/Tests/Command.hs b/test/Tests/Command.hs index e0c5a8408..14e71e78c 100644 --- a/test/Tests/Command.hs +++ b/test/Tests/Command.hs @@ -17,8 +17,10 @@ import Prelude import Data.Algorithm.Diff import qualified Data.ByteString as BS import qualified Data.Text as T -import Data.List (isSuffixOf) +import Data.List (isSuffixOf, intercalate) +import Data.Maybe (catMaybes) import System.Directory +import qualified System.Environment as Env import System.Exit import System.FilePath (joinPath, splitDirectories, takeDirectory, (</>)) import System.IO (hPutStr, stderr) @@ -38,15 +40,15 @@ runTest :: String -- ^ Title of test -> String -- ^ Expected output -> TestTree runTest testname pandocpath cmd inp norm = testCase testname $ do + mldpath <- Env.lookupEnv "LD_LIBRARY_PATH" + mdyldpath <- Env.lookupEnv "DYLD_LIBRARY_PATH" let findDynlibDir [] = Nothing findDynlibDir ("build":xs) = Just $ joinPath (reverse xs) </> "build" findDynlibDir (_:xs) = findDynlibDir xs let mbDynlibDir = findDynlibDir (reverse $ splitDirectories $ takeDirectory $ takeWhile (/=' ') cmd) - let dynlibEnv = case mbDynlibDir of - Nothing -> [] - Just d -> [("DYLD_LIBRARY_PATH", d), - ("LD_LIBRARY_PATH", d)] + let dynlibEnv = [("DYLD_LIBRARY_PATH", intercalate ":" $ catMaybes [mbDynlibDir, mdyldpath]) + ,("LD_LIBRARY_PATH", intercalate ":" $ catMaybes [mbDynlibDir, mldpath])] let env' = dynlibEnv ++ [("PATH",takeDirectory pandocpath),("TMP","."),("LANG","en_US.UTF-8"),("HOME", "./"),("pandoc_datadir", "..")] let pr = (shell cmd){ env = Just env' } (ec, out', err') <- readCreateProcessWithExitCode pr inp diff --git a/test/Tests/Old.hs b/test/Tests/Old.hs index 7366a3142..ce0532ac8 100644 --- a/test/Tests/Old.hs +++ b/test/Tests/Old.hs @@ -15,8 +15,11 @@ module Tests.Old (tests) where import Prelude import Data.Algorithm.Diff import Prelude hiding (readFile) +import Data.List (intercalate) +import Data.Maybe (catMaybes) import System.Exit import System.FilePath (joinPath, splitDirectories, (<.>), (</>)) +import qualified System.Environment as Env import Text.Pandoc.Process (pipeProcess) import Test.Tasty (TestTree, testGroup) import Test.Tasty.Golden.Advanced (goldenTest) @@ -298,12 +301,12 @@ testWithNormalize normalizer pandocPath testname opts inp norm = (compareValues norm options) updateGolden where getExpected = normalizer <$> readFile' norm getActual = do + mldpath <- Env.lookupEnv "LD_LIBRARY_PATH" + mdyldpath <- Env.lookupEnv "DYLD_LIBRARY_PATH" let mbDynlibDir = findDynlibDir (reverse $ splitDirectories pandocPath) - let dynlibEnv = case mbDynlibDir of - Nothing -> [] - Just d -> [("DYLD_LIBRARY_PATH", d), - ("LD_LIBRARY_PATH", d)] + let dynlibEnv = [("DYLD_LIBRARY_PATH", intercalate ":" $ catMaybes [mbDynlibDir, mdyldpath]) + ,("LD_LIBRARY_PATH", intercalate ":" $ catMaybes [mbDynlibDir, mldpath])] let env = dynlibEnv ++ [("TMP","."),("LANG","en_US.UTF-8"),("HOME", "./")] (ec, out) <- pipeProcess (Just env) pandocPath options mempty |