git.iko.soy/typeable/pandoc
on master help sign in
Fix finding of data files from test programs.

Apparently Cabal sets a `pandoc_datadir` environment variable so that the data files will be sought in the source directory rather than in the final destination (where they aren't yet installed). So we no longer need to set `--data-dir` in the tests. We just need to make sure `pandoc_datadir` is set in the environment when we call the program in the test suite. This will fix the issue with loading of pandoc.lua when pandoc is built with `-embed_data_files`, reported in #7163. Closes #7163.

commit2ca1b20a85303dc8656f782f5804afdec215948b authorJohn MacFarlane <jgm@berkeley.edu> dateFri 19 Mar 2021, 18:54 (6 years ago) parentc3a9322
2 files changed+5−2
test/Tests/Command.hs+2−1 test/Tests/Old.hs+3−1
test/Tests/Command.hs+2−1
@@ -40,11 +40,12 @@ execTest :: String -- ^ Path to test executable
4040execTest testExePath cmd inp = do
4141 mldpath <- Env.lookupEnv "LD_LIBRARY_PATH"
4242 mdyldpath <- Env.lookupEnv "DYLD_LIBRARY_PATH"
43+ mpdd <- Env.lookupEnv "pandoc_datadir"
4344 let env' = ("PATH",takeDirectory testExePath) :
4445 ("TMP",".") :
4546 ("LANG","en_US.UTF-8") :
4647 ("HOME", "./") :
47− ("pandoc_datadir", "..") :
48+ maybe [] ((:[]) . ("pandoc_datadir",)) mpdd ++
4849 maybe [] ((:[]) . ("LD_LIBRARY_PATH",)) mldpath ++
4950 maybe [] ((:[]) . ("DYLD_LIBRARY_PATH",)) mdyldpath
5051 let pr = (shell (pandocToEmulate True cmd)){ env = Just env' }
test/Tests/Old.hs+3−1
@@ -321,9 +321,11 @@ testWithNormalize normalizer pandocPath testname opts inp norm =
321321 getActual = do
322322 mldpath <- Env.lookupEnv "LD_LIBRARY_PATH"
323323 mdyldpath <- Env.lookupEnv "DYLD_LIBRARY_PATH"
324+ mpdd <- Env.lookupEnv "pandoc_datadir"
324325 let env = ("TMP",".") :
325326 ("LANG","en_US.UTF-8") :
326327 ("HOME", "./") :
328+ maybe [] ((:[]) . ("pandoc_datadir",)) mpdd ++
327329 maybe [] ((:[]) . ("LD_LIBRARY_PATH",)) mldpath ++
328330 maybe [] ((:[]) . ("DYLD_LIBRARY_PATH",)) mdyldpath
329331
@@ -335,7 +337,7 @@ testWithNormalize normalizer pandocPath testname opts inp norm =
335337 -- filter \r so the tests will work on Windows machines
336338 else fail $ "Pandoc failed with error code " ++ show ec
337339 updateGolden = UTF8.writeFile norm . T.pack
338− options = ["--data-dir=../data","--quiet"] ++ [inp] ++ opts
340+ options = ["--quiet"] ++ [inp] ++ opts
339341
340342compareValues :: FilePath -> [String] -> String -> String -> IO (Maybe String)
341343compareValues norm options expected actual = do