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/Tests/Command.hs | |
| parent | f4185fcef0aa5c00e37a1bf8bbc8b8c6459fffe7 (diff) | |
Propagate (DY)LD_LIBRARY_PATH in tests (#6376)
Diffstat (limited to 'test/Tests/Command.hs')
| -rw-r--r-- | test/Tests/Command.hs | 12 |
1 files changed, 7 insertions, 5 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 |
