aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-08-13 23:59:38 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2017-08-13 23:59:38 -0700
commitc7cbd3ddc2676e982a7fb92dc1da6e74a4248926 (patch)
tree1446f5a127f250ead05fd35066206ebe352d48f0
parent6aef1bd228e7cb3369056bf47151787cc58c11d3 (diff)
downloadpandoc-c7cbd3ddc2676e982a7fb92dc1da6e74a4248926.tar.gz
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.
-rw-r--r--test/Tests/Command.hs10
1 files changed, 5 insertions, 5 deletions
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