-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
45 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{-# LANGUAGE CPP #-} | ||
|
||
module Test.Hspec.Api.Format.Compat | ||
( module Api | ||
, reasonToText | ||
) where | ||
|
||
import Prelude | ||
|
||
import Data.Maybe (fromMaybe) | ||
import Data.Text (Text, pack, unpack) | ||
import qualified Data.Text as T | ||
|
||
#if MIN_VERSION_hspec_api(2,11,0) | ||
import Test.Hspec.Api.Format.V2 as Api | ||
#else | ||
import Test.Hspec.Api.Format.V1 as Api | ||
#endif | ||
|
||
reasonToText :: FailureReason -> Text | ||
reasonToText = \case | ||
Error _ err -> pack $ show err | ||
NoReason -> "no reason" | ||
Reason err -> pack err | ||
#if MIN_VERSION_hspec_api(2,11,0) | ||
ColorizedReason err -> pack err | ||
#endif | ||
ExpectedButGot preface expected actual -> | ||
T.unlines $ | ||
pack | ||
<$> fromMaybe "" preface | ||
: ( foundLines "expected" expected | ||
<> foundLines " but got" actual | ||
) | ||
|
||
foundLines :: Show a => Text -> a -> [String] | ||
foundLines msg found = case lines' of | ||
[] -> [] | ||
first : rest -> | ||
unpack (msg <> ": " <> first) : (unpack . (T.replicate 9 " " <>) <$> rest) | ||
where | ||
lines' = T.lines . pack $ show found |
2 changes: 1 addition & 1 deletion
2
library/Test/Hspec/JUnit/Format/V2.hs → library/Test/Hspec/JUnit/Format.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module Test.Hspec.JUnit.Format.V2 | ||
module Test.Hspec.JUnit.Format | ||
( junit | ||
) where | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters