@@ -27,8 +27,9 @@ import qualified Distribution.Types.PackageDescription.Lens as L
27
27
28
28
tests :: TestTree
29
29
tests = testGroup " parsec tests"
30
- [ warningTests
31
- , regressionTests
30
+ [ regressionTests
31
+ , warningTests
32
+ , errorTests
32
33
]
33
34
34
35
-------------------------------------------------------------------------------
@@ -69,6 +70,33 @@ warningTest wt fp = testCase (show wt) $ do
69
70
[] -> assertFailure " got no warnings"
70
71
_ -> assertFailure $ " got multiple warnings: " ++ show warns
71
72
73
+ -------------------------------------------------------------------------------
74
+ -- Errors
75
+ -------------------------------------------------------------------------------
76
+
77
+ errorTests :: TestTree
78
+ errorTests = testGroup " errors"
79
+ [ errorTest " common1.cabal"
80
+ , errorTest " common2.cabal"
81
+ , errorTest " common3.cabal"
82
+ ]
83
+
84
+ errorTest :: FilePath -> TestTree
85
+ errorTest fp = cabalGoldenTest " errors" correct $ do
86
+ contents <- BS. readFile input
87
+ let res = parseGenericPackageDescription contents
88
+ let (_, errs, x) = runParseResult res
89
+
90
+ return $ toUTF8BS $ case x of
91
+ Just gpd | null errs ->
92
+ " UNXPECTED SUCCESS\n " ++
93
+ showGenericPackageDescription gpd
94
+ _ ->
95
+ unlines $ map show errs
96
+ where
97
+ input = " tests" </> " ParserTests" </> " errors" </> fp
98
+ correct = replaceExtension input " errors"
99
+
72
100
-------------------------------------------------------------------------------
73
101
-- Regressions
74
102
-------------------------------------------------------------------------------
@@ -83,6 +111,8 @@ regressionTests = testGroup "regressions"
83
111
, regressionTest " elif.cabal"
84
112
, regressionTest " elif2.cabal"
85
113
, regressionTest " shake.cabal"
114
+ , regressionTest " common.cabal"
115
+ , regressionTest " common2.cabal"
86
116
]
87
117
88
118
regressionTest :: FilePath -> TestTree
@@ -95,11 +125,12 @@ formatGoldenTest :: FilePath -> TestTree
95
125
formatGoldenTest fp = cabalGoldenTest " format" correct $ do
96
126
contents <- BS. readFile input
97
127
let res = parseGenericPackageDescription contents
98
- let (_ , errs, x) = runParseResult res
128
+ let (warns , errs, x) = runParseResult res
99
129
100
130
return $ toUTF8BS $ case x of
101
131
Just gpd | null errs ->
102
- showGenericPackageDescription gpd
132
+ unlines (map show warns)
133
+ ++ showGenericPackageDescription gpd
103
134
_ ->
104
135
unlines $ " ERROR" : map show errs
105
136
where
0 commit comments