git.iko.soy/typeable/pandoc
on master help sign in
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.

commitc7cbd3ddc2676e982a7fb92dc1da6e74a4248926 authorJohn MacFarlane <jgm@berkeley.edu> dateSun 13 Aug 2017, 23:59 (9 years ago) parent6aef1bd
1 file changed+5−5
test/Tests/Command.hs+5−5
test/Tests/Command.hs+5−5
@@ -13,18 +13,18 @@ import Test.Tasty
1313import Test.Tasty.HUnit
1414import Tests.Helpers
1515import Text.Pandoc
16−import Text.Pandoc.Shared (trimr)
1716import qualified Data.ByteString as BS
1817import qualified Text.Pandoc.UTF8 as UTF8
1918import System.IO.Unsafe (unsafePerformIO) -- TODO temporary
2019
2120-- | Run a test with normalize function, return True if test passed.
2221runTest :: String -- ^ Title of test
22+ -> FilePath -- ^ Path to pandoc
2323 -> String -- ^ Shell command
2424 -> String -- ^ Input text
2525 -> String -- ^ Expected output
2626 -> TestTree
27−runTest testname cmd inp norm = testCase testname $ do
27+runTest testname pandocpath cmd inp norm = testCase testname $ do
2828 let cmd' = cmd ++ " --data-dir ../data"
2929 let findDynlibDir [] = Nothing
3030 findDynlibDir ("build":xs) = Just $ joinPath (reverse xs) </> "build"
@@ -35,7 +35,7 @@ runTest testname cmd inp norm = testCase testname $ do
3535 Nothing -> []
3636 Just d -> [("DYLD_LIBRARY_PATH", d),
3737 ("LD_LIBRARY_PATH", d)]
38− let env' = dynlibEnv ++ [("TMP","."),("LANG","en_US.UTF-8"),("HOME", "./")]
38+ let env' = dynlibEnv ++ [("PATH",takeDirectory pandocpath),("TMP","."),("LANG","en_US.UTF-8"),("HOME", "./")]
3939 let pr = (shell cmd'){ env = Just env' }
4040 (ec, out', err') <- readCreateProcessWithExitCode pr inp
4141 -- filter \r so the tests will work on Windows machines
@@ -82,8 +82,8 @@ runCommandTest pandocpath (num, code) =
8282 normlines = takeWhile (/=".") (drop 1 r3)
8383 input = unlines inplines
8484 norm = unlines normlines
85− shcmd = trimr $ takeDirectory pandocpath </> cmd
86− in runTest ("#" ++ show num) shcmd input norm
85+ shcmd = cmd -- trimr $ takeDirectory pandocpath </> cmd
86+ in runTest ("#" ++ show num) pandocpath shcmd input norm
8787
8888extractCommandTest :: FilePath -> FilePath -> TestTree
8989extractCommandTest pandocpath fp = unsafePerformIO $ do