Revert "FB2 reader test: better diagnostics on failure."

This reverts commit c65af7d1a2.
This commit is contained in:
John MacFarlane 2019-09-15 10:27:19 -07:00
parent c65af7d1a2
commit 45b7636307

View file

@ -15,40 +15,13 @@ module Tests.Readers.FB2 (tests) where
import Prelude import Prelude
import Test.Tasty import Test.Tasty
import Tests.Helpers import Tests.Helpers
-- import Test.Tasty.Golden (goldenVsString) import Test.Tasty.Golden (goldenVsString)
import Test.Tasty.Golden.Advanced (goldenTest)
import Text.Printf
import qualified Data.ByteString.Lazy as LBS
import qualified Data.ByteString as BS import qualified Data.ByteString as BS
import Text.Pandoc import Text.Pandoc
import Text.Pandoc.UTF8 (toText, fromStringLazy) import Text.Pandoc.UTF8 (toText, fromStringLazy)
import Data.Text (Text, unpack) import Data.Text (Text, unpack)
import System.FilePath (replaceExtension) import System.FilePath (replaceExtension)
simpleCmp :: Eq a => String -> a -> a -> IO (Maybe String)
simpleCmp e x y =
return $ if x == y then Nothing else Just e
goldenVsString
:: TestName -- ^ test name
-> FilePath -- ^ path to the «golden» file (the file that contains correct output)
-> IO LBS.ByteString -- ^ action that returns a string
-> TestTree -- ^ the test verifies that the returned string is the same as the golden file contents
goldenVsString name ref act =
goldenTest
name
(BS.readFile ref)
(LBS.toStrict <$> act)
cmp
upd
where
cmp x y = simpleCmp msg x y
where
msg = printf "Test output from %s was different from %s. It was: %s" ref (show x) (show y)
upd = BS.writeFile ref
fb2ToNative :: Text -> Text fb2ToNative :: Text -> Text
fb2ToNative = purely (writeNative def{ writerTemplate = Just mempty }) . purely (readFB2 def) fb2ToNative = purely (writeNative def{ writerTemplate = Just mempty }) . purely (readFB2 def)