summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Hakyll/Core/UnixFilter.hs3
-rw-r--r--tests/Hakyll/Core/UnixFilter/Tests.hs24
2 files changed, 23 insertions, 4 deletions
diff --git a/lib/Hakyll/Core/UnixFilter.hs b/lib/Hakyll/Core/UnixFilter.hs
index 734d8d8..b796bb1 100644
--- a/lib/Hakyll/Core/UnixFilter.hs
+++ b/lib/Hakyll/Core/UnixFilter.hs
@@ -92,7 +92,8 @@ unixFilterWith writer reader programName args input = do
ExitSuccess -> return output
ExitFailure e -> fail $
"Hakyll.Core.UnixFilter.unixFilterWith: " ++
- unwords (programName : args) ++ " gave exit code " ++ show e
+ unwords (programName : args) ++ " gave exit code " ++ show e ++
+ ". (Error: " ++ err ++ ")"
--------------------------------------------------------------------------------
diff --git a/tests/Hakyll/Core/UnixFilter/Tests.hs b/tests/Hakyll/Core/UnixFilter/Tests.hs
index 255b043..521d051 100644
--- a/tests/Hakyll/Core/UnixFilter/Tests.hs
+++ b/tests/Hakyll/Core/UnixFilter/Tests.hs
@@ -17,6 +17,7 @@ import Hakyll.Core.Compiler
import Hakyll.Core.Compiler.Internal
import Hakyll.Core.Item
import Hakyll.Core.UnixFilter
+import Hakyll.Core.Identifier
import TestSuite.Util
@@ -25,16 +26,19 @@ tests :: TestTree
tests = testGroup "Hakyll.Core.UnixFilter.Tests"
[ testCase "unixFilter rev" unixFilterRev
, testCase "unixFilter false" unixFilterFalse
+ , testCase "unixFilter error" unixFilterError
]
+testMarkdown :: Identifier
+testMarkdown = "russian.md"
--------------------------------------------------------------------------------
unixFilterRev :: H.Assertion
unixFilterRev = do
store <- newTestStore
provider <- newTestProvider store
- output <- testCompilerDone store provider "russian.md" compiler
- expected <- testCompilerDone store provider "russian.md" getResourceString
+ output <- testCompilerDone store provider testMarkdown compiler
+ expected <- testCompilerDone store provider testMarkdown getResourceString
H.assert $ rev (itemBody expected) == lines (itemBody output)
cleanTestEnv
where
@@ -47,10 +51,24 @@ unixFilterFalse :: H.Assertion
unixFilterFalse = do
store <- newTestStore
provider <- newTestProvider store
- result <- testCompiler store provider "russian.md" compiler
+ result <- testCompiler store provider testMarkdown compiler
H.assert $ case result of
CompilerError es -> any ("exit code" `isInfixOf`) es
_ -> False
cleanTestEnv
where
compiler = getResourceString >>= withItemBody (unixFilter "false" [])
+
+
+--------------------------------------------------------------------------------
+unixFilterError :: H.Assertion
+unixFilterError = do
+ store <- newTestStore
+ provider <- newTestProvider store
+ result <- testCompiler store provider testMarkdown compiler
+ H.assert $ case result of
+ CompilerError es -> any ("invalid option" `isInfixOf`) es
+ _ -> False
+ cleanTestEnv
+ where
+ compiler = getResourceString >>= withItemBody (unixFilter "head" ["-#"]) \ No newline at end of file