From c04800305e97a42d2d346fc6b0425817056438b7 Mon Sep 17 00:00:00 2001 From: Lila Date: Tue, 19 May 2020 07:46:14 +0200 Subject: Propagate (DY)LD_LIBRARY_PATH in tests (#6376) --- test/Tests/Command.hs | 12 +++++++----- test/Tests/Old.hs | 11 +++++++---- 2 files changed, 14 insertions(+), 9 deletions(-) (limited to 'test') 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 -- cgit v1.2.3