From 7ee4e6134cc447c8b053129e7557d9883c7e8e01 Mon Sep 17 00:00:00 2001 From: Nick Boultbee Date: Fri, 17 Nov 2017 14:55:27 +0000 Subject: Make unixFilter output stderr when failing Fixes #581. --- tests/Hakyll/Core/UnixFilter/Tests.hs | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'tests') 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 -- cgit v1.2.3