mirror of
https://github.com/alpmestan/taggy.git
synced 2024-08-17 02:40:33 +03:00
A test suite to validate a successful parse on each html_files/*html.
This commit is contained in:
parent
986af3de9f
commit
f56acd06e4
30
taggy.cabal
30
taggy.cabal
@ -45,6 +45,7 @@ copyright: 2014 Alp Mestanogullari, Vikram Verma
|
||||
category: Text, Web
|
||||
build-type: Simple
|
||||
extra-source-files: html_files/*.html
|
||||
data-files: html_files/*.html
|
||||
cabal-version: >=1.10
|
||||
|
||||
library
|
||||
@ -93,13 +94,13 @@ benchmark taggytagsoup
|
||||
vector
|
||||
default-language: Haskell2010
|
||||
|
||||
test-suite spec
|
||||
test-suite unit
|
||||
type:
|
||||
exitcode-stdio-1.0
|
||||
ghc-options:
|
||||
-Wall -O -fno-warn-unused-do-bind
|
||||
hs-source-dirs:
|
||||
src, tests
|
||||
src, tests/unit
|
||||
main-is:
|
||||
Spec.hs
|
||||
build-depends:
|
||||
@ -114,3 +115,28 @@ test-suite spec
|
||||
, unordered-containers
|
||||
default-language:
|
||||
Haskell2010
|
||||
|
||||
test-suite integration
|
||||
type:
|
||||
exitcode-stdio-1.0
|
||||
ghc-options:
|
||||
-Wall -Werror -O -fno-warn-unused-do-bind
|
||||
hs-source-dirs:
|
||||
src, tests/integration
|
||||
main-is:
|
||||
Main.hs
|
||||
build-depends:
|
||||
base == 4.*
|
||||
, blaze-html
|
||||
, blaze-markup
|
||||
, directory
|
||||
, text
|
||||
, hspec >= 1.11
|
||||
, hspec-attoparsec
|
||||
, vector
|
||||
, attoparsec
|
||||
, unordered-containers
|
||||
other-modules:
|
||||
Paths_taggy
|
||||
default-language:
|
||||
Haskell2010
|
||||
|
24
tests/integration/Main.hs
Normal file
24
tests/integration/Main.hs
Normal file
@ -0,0 +1,24 @@
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
|
||||
module Main (main) where
|
||||
|
||||
import Prelude hiding (readFile)
|
||||
import Data.Functor ((<$>))
|
||||
import Data.List (isSuffixOf)
|
||||
import Data.Text.Lazy (Text)
|
||||
import Data.Text.Lazy.IO (readFile)
|
||||
import Paths_taggy (getDataFileName)
|
||||
import System.Directory (getDirectoryContents, setCurrentDirectory)
|
||||
import Test.Hspec (hspec, runIO, describe, it, shouldSatisfy)
|
||||
import Text.Taggy (taggyWith)
|
||||
|
||||
getHTMLFiles :: IO [(FilePath, Text)]
|
||||
getHTMLFiles = getDataFileName "html_files"
|
||||
>>= setCurrentDirectory
|
||||
>> filter (isSuffixOf ".html") <$> getDirectoryContents "."
|
||||
>>= mapM (\name -> fmap (name,) $ readFile name)
|
||||
|
||||
main :: IO ()
|
||||
main = hspec . (runIO getHTMLFiles >>=) . mapM_ $ \(name, content) ->
|
||||
describe name . it "Should parse without error." $
|
||||
taggyWith True content `shouldSatisfy` not . null
|
Loading…
Reference in New Issue
Block a user