Skip to content

Commit 6ddbcc4

Browse files
committed
tests: use tuple to serialise unmerged accessor tests
1 parent de16658 commit 6ddbcc4

10 files changed

+421
-403
lines changed

Cabal-tests/tests/ParserTests.hs

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -182,27 +182,26 @@ accessorsTests = testGroup "accessors"
182182
]
183183

184184
#ifdef MIN_VERSION_tree_diff
185+
-- Here, we test the unmerged internal representation
185186
accessorsGoldenTest :: FilePath -> TestTree
186-
accessorsGoldenTest fp =
187-
let go label f = ediffGolden goldenTest label exprFile $ do
188-
contents <- BS.readFile input
189-
let res = withSource (PCabalFile (fp, contents)) $ parseGenericPackageDescription contents
190-
let (_, x) = runParseResult res
191-
case x of
192-
Right gpd -> pure (toExpr $ f gpd)
193-
Left (_, errs) -> fail $ unlines $ "ERROR" : map (showPErrorWithSource . fmap renderCabalFileSource) (NE.toList errs)
194-
where
195-
input = "tests" </> "ParserTests" </> "accessors" </> fp
196-
exprFile = replaceExtension input (label <> ".expr")
197-
in testGroup "accessors"
198-
[ go "gpdCommonStanzas" gpdCommonStanzas
199-
, go "condLibraryUnmerged" condLibraryUnmerged
200-
, go "condSubLibrariesUnmerged" condSubLibrariesUnmerged
201-
, go "condForeignLibsUnmerged" condForeignLibsUnmerged
202-
, go "condExecutablesUnmerged" condExecutablesUnmerged
203-
, go "condTestSuitesUnmerged" condTestSuitesUnmerged
204-
, go "condBenchmarksUnmerged" condBenchmarksUnmerged
205-
]
187+
accessorsGoldenTest fp = ediffGolden goldenTest "expr" exprFile $ do
188+
contents <- BS.readFile input
189+
let res = withSource (PCabalFile (fp, contents)) $ parseGenericPackageDescription contents
190+
let (_, x) = runParseResult res
191+
case x of
192+
Right gpd -> pure $ toExpr
193+
( gpdCommonStanzas gpd
194+
, condLibraryUnmerged gpd
195+
, condSubLibrariesUnmerged gpd
196+
, condForeignLibsUnmerged gpd
197+
, condExecutablesUnmerged gpd
198+
, condTestSuitesUnmerged gpd
199+
, condBenchmarksUnmerged gpd
200+
)
201+
Left (_, errs) -> fail $ unlines $ "ERROR" : map (showPErrorWithSource . fmap renderCabalFileSource) (NE.toList errs)
202+
where
203+
input = "tests" </> "ParserTests" </> "accessors" </> fp
204+
exprFile = replaceExtension input "expr"
206205
#endif
207206

208207
-------------------------------------------------------------------------------

Cabal-tests/tests/ParserTests/accessors/library-merging.condBenchmarksUnmerged.expr

Lines changed: 0 additions & 1 deletion
This file was deleted.

Cabal-tests/tests/ParserTests/accessors/library-merging.condExecutablesUnmerged.expr

Lines changed: 0 additions & 1 deletion
This file was deleted.

Cabal-tests/tests/ParserTests/accessors/library-merging.condForeignLibsUnmerged.expr

Lines changed: 0 additions & 1 deletion
This file was deleted.

Cabal-tests/tests/ParserTests/accessors/library-merging.condLibraryUnmerged.expr

Lines changed: 0 additions & 153 deletions
This file was deleted.

Cabal-tests/tests/ParserTests/accessors/library-merging.condSubLibrariesUnmerged.expr

Lines changed: 0 additions & 1 deletion
This file was deleted.

Cabal-tests/tests/ParserTests/accessors/library-merging.condTestSuitesUnmerged.expr

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)