Test fixes so we can find data files.
In old tests & command tests, we now set the environment variable pandoc_datadir. In lua tests, we set the datadir explicitly.
This commit is contained in:
parent
ceda566a5e
commit
38578ad06c
3 changed files with 7 additions and 7 deletions
|
@ -25,7 +25,6 @@ runTest :: String -- ^ Title of test
|
|||
-> String -- ^ Expected output
|
||||
-> TestTree
|
||||
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"
|
||||
findDynlibDir (_:xs) = findDynlibDir xs
|
||||
|
@ -35,8 +34,8 @@ runTest testname pandocpath cmd inp norm = testCase testname $ do
|
|||
Nothing -> []
|
||||
Just d -> [("DYLD_LIBRARY_PATH", d),
|
||||
("LD_LIBRARY_PATH", d)]
|
||||
let env' = dynlibEnv ++ [("PATH",takeDirectory pandocpath),("TMP","."),("LANG","en_US.UTF-8"),("HOME", "./")]
|
||||
let pr = (shell cmd'){ env = Just env' }
|
||||
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
|
||||
-- filter \r so the tests will work on Windows machines
|
||||
let out = filter (/= '\r') $ err' ++ out'
|
||||
|
|
|
@ -68,7 +68,7 @@ tests = map (localOption (QuickCheckTests 20))
|
|||
|
||||
assertFilterConversion :: String -> FilePath -> Pandoc -> Pandoc -> Assertion
|
||||
assertFilterConversion msg filterPath docIn docExpected = do
|
||||
docRes <- runLuaFilter Nothing ("lua" </> filterPath) [] docIn
|
||||
docRes <- runLuaFilter (Just "../data") ("lua" </> filterPath) [] docIn
|
||||
assertEqual msg docExpected docRes
|
||||
|
||||
roundtripEqual :: (Eq a, FromLuaStack a, ToLuaStack a) => a -> IO Bool
|
||||
|
@ -77,7 +77,7 @@ roundtripEqual x = (x ==) <$> roundtripped
|
|||
roundtripped :: (FromLuaStack a, ToLuaStack a) => IO a
|
||||
roundtripped = runLua $ do
|
||||
openlibs
|
||||
pushPandocModule Nothing
|
||||
pushPandocModule (Just "../data")
|
||||
setglobal "pandoc"
|
||||
oldSize <- gettop
|
||||
push x
|
||||
|
|
|
@ -238,7 +238,8 @@ testWithNormalize normalizer testname opts inp norm =
|
|||
Just d -> [("DYLD_LIBRARY_PATH", d),
|
||||
("LD_LIBRARY_PATH", d)]
|
||||
let env = dynlibEnv ++
|
||||
[("TMP","."),("LANG","en_US.UTF-8"),("HOME", "./")]
|
||||
[("TMP","."),("LANG","en_US.UTF-8"),("HOME", "./"),
|
||||
("pandoc_datadir","..")]
|
||||
ph <- runProcess pandocPath options Nothing
|
||||
(Just env) Nothing (Just hOut) (Just hErr)
|
||||
ec <- waitForProcess ph
|
||||
|
@ -253,7 +254,7 @@ testWithNormalize normalizer testname opts inp norm =
|
|||
then ""
|
||||
else '\n':errcontents
|
||||
updateGolden = UTF8.writeFile norm
|
||||
options = ["--quiet", "--data-dir", ".." </> "data"] ++ [inp] ++ opts
|
||||
options = ["--quiet"] ++ [inp] ++ opts
|
||||
|
||||
compareValues :: FilePath -> [String] -> String -> String -> IO (Maybe String)
|
||||
compareValues norm options expected actual = do
|
||||
|
|
Loading…
Add table
Reference in a new issue