File tree 3 files changed +15
-3
lines changed
3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change
1
+ ## 0.3.3
2
+
3
+ - Change 'ediffGolden' so that parse errors in expected file don't cause the hard failure.
4
+ This way you may ` --accept ` new results even when expected files are broken, e.g. due merge conflict markers.
5
+ For now the change is a bit a hack to avoid breaking change in type-signature of ` ediffGolden/1 ` .
6
+
1
7
## 0.3.2
2
8
3
9
- Add 'ediffGolden1', a variant of 'ediffGolden' with an additional argument.
Original file line number Diff line number Diff line change
1
+ {-# LANGUAGE ScopedTypeVariables #-}
1
2
-- | "Golden tests" using 'ediff' comparison.
2
3
module Data.TreeDiff.Golden (
3
4
ediffGolden ,
@@ -50,20 +51,25 @@ ediffGolden impl testName fp x = ediffGolden1 impl' testName fp (\() -> x) where
50
51
-- @since 0.3.2
51
52
--
52
53
ediffGolden1
53
- :: (Eq a , ToExpr a )
54
+ :: forall a arg testName testTree . (Eq a , ToExpr a )
54
55
=> (testName -> IO Expr -> (arg -> IO Expr ) -> (Expr -> Expr -> IO (Maybe String )) -> (Expr -> IO () ) -> testTree ) -- ^ 'goldenTest'
55
56
-> testName -- ^ test name
56
57
-> FilePath -- ^ path to "golden file"
57
58
-> (arg -> IO a ) -- ^ result value
58
59
-> testTree
59
60
ediffGolden1 impl testName fp x = impl testName expect actual cmp wrt
60
61
where
62
+ actual :: arg -> IO Expr
61
63
actual arg = fmap toExpr (x arg)
64
+
65
+ expect :: IO Expr
62
66
expect = do
63
67
contents <- BS. readFile fp
64
68
case parse (exprParser <* eof) fp $ TE. decodeUtf8 contents of
65
- Left err -> print err >> fail " parse error "
69
+ Left err -> return $ App " ParseError " [toExpr fp, toExpr ( show err)]
66
70
Right r -> return r
71
+
72
+ cmp :: Expr -> Expr -> IO (Maybe [Char ])
67
73
cmp a b
68
74
| a == b = return Nothing
69
75
| otherwise = return $ Just $
Original file line number Diff line number Diff line change 1
1
cabal-version : 2.2
2
2
name : tree-diff
3
- version : 0.3.2
3
+ version : 0.3.3
4
4
synopsis : Diffing of (expression) trees.
5
5
category : Data, Testing
6
6
description :
You can’t perform that action at this time.
0 commit comments