diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-03-14 17:27:30 +0100 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-03-14 17:27:30 +0100 |
commit | ebbaf2e965ad4f1ba6e5130a73840a531ececcaf (patch) | |
tree | a4c40c44127797acee41b25d3bad7383e52041be /test/Tests | |
parent | 6ecc5b96a9854382682fd1c9231133c08dae7b17 (diff) | |
download | pandoc-ebbaf2e965ad4f1ba6e5130a73840a531ececcaf.tar.gz |
Small test plumbing improvement.
Diffstat (limited to 'test/Tests')
-rw-r--r-- | test/Tests/Command.hs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/test/Tests/Command.hs b/test/Tests/Command.hs index 2fc31174c..b15d95fa7 100644 --- a/test/Tests/Command.hs +++ b/test/Tests/Command.hs @@ -67,18 +67,18 @@ dropPercent :: String -> String dropPercent ('%':xs) = dropWhile (== ' ') xs dropPercent xs = xs -runCommandTest :: FilePath -> (Int, String) -> IO TestTree -runCommandTest pandocpath (num, code) = do +runCommandTest :: FilePath -> (Int, String) -> TestTree +runCommandTest pandocpath (num, code) = let codelines = lines code - let (continuations, r1) = span ("\\" `isSuffixOf`) codelines - let (cmd, r2) = (dropPercent (unwords (map init continuations ++ take 1 r1)), + (continuations, r1) = span ("\\" `isSuffixOf`) codelines + (cmd, r2) = (dropPercent (unwords (map init continuations ++ take 1 r1)), drop 1 r1) - let (inplines, r3) = break (=="^D") r2 - let normlines = takeWhile (/=".") (drop 1 r3) - let input = unlines inplines - let norm = unlines normlines - let shcmd = trimr $ takeDirectory pandocpath </> cmd - return $ runTest ("#" ++ show num) shcmd input norm + (inplines, r3) = break (=="^D") r2 + normlines = takeWhile (/=".") (drop 1 r3) + input = unlines inplines + norm = unlines normlines + shcmd = trimr $ takeDirectory pandocpath </> cmd + in runTest ("#" ++ show num) shcmd input norm extractCommandTest :: FilePath -> TestTree extractCommandTest fp = unsafePerformIO $ do @@ -87,6 +87,6 @@ extractCommandTest fp = unsafePerformIO $ do Pandoc _ blocks <- runIOorExplode (readMarkdown def{ readerExtensions = pandocExtensions } contents) let codeblocks = map extractCode $ filter isCodeBlock $ blocks - cases <- mapM (runCommandTest pandocpath) $ zip [1..] codeblocks + let cases = map (runCommandTest pandocpath) $ zip [1..] codeblocks return $ testGroup fp cases |