Skip to content

Commit 492ad9e

Browse files
committed
Merge branch 'accessor-tests' into no-flatten-package-description
2 parents 467bcee + 791eb8c commit 492ad9e

File tree

1 file changed

+30
-15
lines changed

1 file changed

+30
-15
lines changed

Cabal-tests/tests/ParserTests.hs

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ import Data.Maybe (isNothing)
1616
import Distribution.Fields (pwarning)
1717
import Distribution.PackageDescription (GenericPackageDescription)
1818
import Distribution.PackageDescription
19-
( condLibrary
19+
( packageDescription
20+
, gpdScannedVersion
21+
, genPackageFlags
22+
, condLibrary
2023
, condSubLibraries
2124
, condForeignLibs
2225
, condExecutables
@@ -268,24 +271,36 @@ formatRoundTripTest fp = testCase "roundtrip" $ do
268271
x <- parse contents
269272
let contents' = showGenericPackageDescription x
270273
y <- parse (toUTF8BS contents')
271-
-- previously we mangled licenses a bit
272-
let y' = y
274+
let checkField field =
275+
unless (field x == field y) $
273276
{- FOURMOLU_DISABLE -}
274-
unless (x == y') $
275277
#ifdef MIN_VERSION_tree_diff
276-
assertFailure $ unlines
277-
[ "re-parsed doesn't match"
278-
, show $ ansiWlEditExpr $ ediff x y
279-
]
278+
assertFailure $ unlines
279+
[ "re-parsed doesn't match"
280+
, show $ ansiWlEditExpr $ ediff x y
281+
]
280282
#else
281-
assertFailure $ unlines
282-
[ "re-parsed doesn't match"
283-
, "expected"
284-
, show x
285-
, "actual"
286-
, show y
287-
]
283+
assertFailure $ unlines
284+
[ "re-parsed doesn't match"
285+
, "expected"
286+
, show x
287+
, "actual"
288+
, show y
289+
]
288290
#endif
291+
-- Due to the imports being merged, the structural comparison will fail
292+
-- Instead, we check the equality after merging
293+
sequence_
294+
[ checkField packageDescription
295+
, checkField gpdScannedVersion
296+
, checkField genPackageFlags
297+
, checkField condLibrary
298+
, checkField condSubLibraries
299+
, checkField condForeignLibs
300+
, checkField condExecutables
301+
, checkField condTestSuites
302+
, checkField condBenchmarks
303+
]
289304
where
290305
parse :: BS.ByteString -> IO GenericPackageDescription
291306
parse c = do

0 commit comments

Comments
 (0)