From c7cbd3ddc2676e982a7fb92dc1da6e74a4248926 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 13 Aug 2017 23:59:38 -0700 Subject: Fixed command tests to set local path. Previously we just tacked on a directory to the command line, but that didn't work when we e.g. used a pipe for round tripping, with two invocations of pandoc. --- test/Tests/Command.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/Tests/Command.hs b/test/Tests/Command.hs index 24e7a67d9..95fb69ef0 100644 --- a/test/Tests/Command.hs +++ b/test/Tests/Command.hs @@ -13,18 +13,18 @@ import Test.Tasty import Test.Tasty.HUnit import Tests.Helpers import Text.Pandoc -import Text.Pandoc.Shared (trimr) import qualified Data.ByteString as BS import qualified Text.Pandoc.UTF8 as UTF8 import System.IO.Unsafe (unsafePerformIO) -- TODO temporary -- | Run a test with normalize function, return True if test passed. runTest :: String -- ^ Title of test + -> FilePath -- ^ Path to pandoc -> String -- ^ Shell command -> String -- ^ Input text -> String -- ^ Expected output -> TestTree -runTest testname cmd inp norm = testCase testname $ do +runTest testname pandocpath cmd inp norm = testCase testname $ do let cmd' = cmd ++ " --data-dir ../data" let findDynlibDir [] = Nothing findDynlibDir ("build":xs) = Just $ joinPath (reverse xs) "build" @@ -35,7 +35,7 @@ runTest testname cmd inp norm = testCase testname $ do Nothing -> [] Just d -> [("DYLD_LIBRARY_PATH", d), ("LD_LIBRARY_PATH", d)] - let env' = dynlibEnv ++ [("TMP","."),("LANG","en_US.UTF-8"),("HOME", "./")] + let env' = dynlibEnv ++ [("PATH",takeDirectory pandocpath),("TMP","."),("LANG","en_US.UTF-8"),("HOME", "./")] let pr = (shell cmd'){ env = Just env' } (ec, out', err') <- readCreateProcessWithExitCode pr inp -- filter \r so the tests will work on Windows machines @@ -82,8 +82,8 @@ runCommandTest pandocpath (num, code) = normlines = takeWhile (/=".") (drop 1 r3) input = unlines inplines norm = unlines normlines - shcmd = trimr $ takeDirectory pandocpath cmd - in runTest ("#" ++ show num) shcmd input norm + shcmd = cmd -- trimr $ takeDirectory pandocpath cmd + in runTest ("#" ++ show num) pandocpath shcmd input norm extractCommandTest :: FilePath -> FilePath -> TestTree extractCommandTest pandocpath fp = unsafePerformIO $ do -- cgit v1.2.3