diff options
author | John MacFarlane <jgm@berkeley.edu> | 2019-01-31 17:25:36 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-01-31 17:25:36 -0800 |
commit | fdf7f07f6269238dacae7dc90068f64d4666367e (patch) | |
tree | 99a78cfe32d966d03bcd29d3db67804c1f16126e /test/Tests | |
parent | 4e6ef532953c5d2b446d7c2e51be9fab83386f6f (diff) | |
download | pandoc-fdf7f07f6269238dacae7dc90068f64d4666367e.tar.gz |
Old tests: remove need for temp files by using pipeProcess.
Diffstat (limited to 'test/Tests')
-rw-r--r-- | test/Tests/Old.hs | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/test/Tests/Old.hs b/test/Tests/Old.hs index 4a1fbcbf7..de8c6bf6a 100644 --- a/test/Tests/Old.hs +++ b/test/Tests/Old.hs @@ -6,8 +6,7 @@ import Data.Algorithm.Diff import Prelude hiding (readFile) import System.Exit import System.FilePath (joinPath, splitDirectories, (<.>), (</>)) -import System.IO.Temp (withTempFile) -import System.Process (runProcess, waitForProcess) +import Text.Pandoc.Process (pipeProcess) import Test.Tasty (TestTree, testGroup) import Test.Tasty.Golden.Advanced (goldenTest) import Tests.Helpers hiding (test) @@ -250,9 +249,7 @@ testWithNormalize normalizer testname opts inp norm = goldenTest testname getExpected getActual (compareValues norm options) updateGolden where getExpected = normalizer <$> readFile' norm - getActual = - withTempFile "." "pandoc-test" $ \outputPath hOut -> do - withTempFile "." "pandoc-test" $ \errorPath hErr -> do + getActual = do pandocPath <- findPandoc let mbDynlibDir = findDynlibDir (reverse $ splitDirectories pandocPath) @@ -263,19 +260,12 @@ testWithNormalize normalizer testname opts inp norm = let env = dynlibEnv ++ [("TMP","."),("LANG","en_US.UTF-8"),("HOME", "./"), ("pandoc_datadir","..")] - ph <- runProcess pandocPath options Nothing - (Just env) Nothing (Just hOut) (Just hErr) - ec <- waitForProcess ph + (ec, out) <- pipeProcess (Just env) pandocPath options mempty if ec == ExitSuccess - then + then return $ filter (/='\r') . normalizer + $ UTF8.toStringLazy out -- filter \r so the tests will work on Windows machines - (filter (/='\r') . normalizer) <$> readFile' outputPath - else do - errcontents <- UTF8.readFile errorPath - fail $ "Pandoc failed with " ++ show ec ++ - if null errcontents - then "" - else '\n':errcontents + else fail $ "Pandoc failed with error code " ++ show ec updateGolden = UTF8.writeFile norm options = ["--quiet"] ++ [inp] ++ opts |