blob: 92c290426ba63b098eaa998d5ae93dbac74ad6d2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
--------------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
module Hakyll.Core.UnixFilter.Tests
( tests
) where
--------------------------------------------------------------------------------
import Data.List (isInfixOf)
import Test.Framework (Test, testGroup)
import Test.Framework.Providers.HUnit (testCase)
import qualified Test.HUnit as H
--------------------------------------------------------------------------------
import Hakyll.Core.Compiler
import Hakyll.Core.Compiler.Internal
import Hakyll.Core.Item
import Hakyll.Core.UnixFilter
import TestSuite.Util
--------------------------------------------------------------------------------
tests :: Test
tests = testGroup "Hakyll.Core.UnixFilter.Tests"
[ testCase "unixFilter rev" unixFilterRev
, testCase "unixFilter false" unixFilterFalse
]
--------------------------------------------------------------------------------
unixFilterRev :: H.Assertion
unixFilterRev = do
store <- newTestStore
provider <- newTestProvider store
output <- testCompilerDone store provider "russian.md" compiler
expected <- testCompilerDone store provider "russian.md" getResourceString
H.assert $ rev (itemBody expected) == lines (itemBody output)
cleanTestEnv
where
compiler = getResourceString >>= withItemBody (unixFilter "rev" [])
rev = map reverse . lines
--------------------------------------------------------------------------------
unixFilterFalse :: H.Assertion
unixFilterFalse = do
store <- newTestStore
provider <- newTestProvider store
result <- testCompiler store provider "russian.md" compiler
H.assert $ case result of
CompilerError es -> any ("exit code" `isInfixOf`) es
_ -> False
cleanTestEnv
where
compiler = getResourceString >>= withItemBody (unixFilter "false" [])
|