Skip to content

Commit 9c98990

Browse files
committed
tests: add tests for accessors
1 parent 8365cec commit 9c98990

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+24573
-2747
lines changed

Cabal-tests/tests/ParserTests.hs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,16 @@ import Control.Monad (unless, void)
1414
import Data.Algorithm.Diff (PolyDiff (..), getGroupedDiff)
1515
import Data.Maybe (isNothing)
1616
import Distribution.Fields (pwarning)
17-
import Distribution.PackageDescription (GenericPackageDescription)
17+
import Distribution.PackageDescription
18+
( GenericPackageDescription
19+
( condLibrary
20+
, condSubLibraries
21+
, condForeignLibs
22+
, condExecutables
23+
, condTestSuites
24+
, condBenchmarks
25+
)
26+
)
1827
import Distribution.PackageDescription.Parsec (parseGenericPackageDescription)
1928
import Distribution.PackageDescription.PrettyPrint (showGenericPackageDescription)
2029
import Distribution.Parsec (PWarnType (..), PWarning (..), showPErrorWithSource, showPWarningWithSource)
@@ -237,7 +246,16 @@ treeDiffGoldenTest fp = ediffGolden goldenTest "expr" exprFile $ do
237246
let res = withSource (PCabalFile (fp, contents)) $ parseGenericPackageDescription contents
238247
let (_, x) = runParseResult res
239248
case x of
240-
Right gpd -> pure (toExpr gpd)
249+
Right gpd -> pure $ toExpr
250+
( gpd
251+
-- Test accessors because they encapsulate the merging behaviour
252+
, condLibrary gpd
253+
, condSubLibraries gpd
254+
, condForeignLibs gpd
255+
, condExecutables gpd
256+
, condTestSuites gpd
257+
, condBenchmarks gpd
258+
)
241259
Left (_, errs) -> fail $ unlines $ "ERROR" : map (showPErrorWithSource . fmap renderCabalFileSource) (NE.toList errs)
242260
where
243261
input = "tests" </> "ParserTests" </> "regressions" </> fp

0 commit comments

Comments
 (0)