@@ -16,7 +16,10 @@ import Data.Maybe (isNothing)
1616import Distribution.Fields (pwarning )
1717import Distribution.PackageDescription
1818 ( GenericPackageDescription
19- ( condLibrary
19+ ( packageDescription
20+ , gpdScannedVersion
21+ , genPackageFlags
22+ , condLibrary
2023 , condSubLibraries
2124 , condForeignLibs
2225 , condExecutables
@@ -268,24 +271,38 @@ 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+
275+ let checkField field =
276+ unless (field x == field y) $
273277{- FOURMOLU_DISABLE -}
274- unless (x == y') $
275278#ifdef MIN_VERSION_tree_diff
276- assertFailure $ unlines
277- [ " re-parsed doesn't match"
278- , show $ ansiWlEditExpr $ ediff x y
279- ]
279+ assertFailure $ unlines
280+ [ " re-parsed doesn't match"
281+ , show $ ansiWlEditExpr $ ediff x y
282+ ]
280283#else
281- assertFailure $ unlines
282- [ " re-parsed doesn't match"
283- , " expected"
284- , show x
285- , " actual"
286- , show y
287- ]
284+ assertFailure $ unlines
285+ [ " re-parsed doesn't match"
286+ , " expected"
287+ , show x
288+ , " actual"
289+ , show y
290+ ]
288291#endif
292+ -- Due to the imports being merged, the structural comparison will fail
293+ -- Instead, we check the equality after merging
294+ sequence_
295+ [ checkField packageDescription
296+ , checkField gpdScannedVersion
297+ , checkField genPackageFlags
298+ , checkField condLibrary
299+ , checkField condSubLibraries
300+ , checkField condForeignLibs
301+ , checkField condExecutables
302+ , checkField condTestSuites
303+ , checkField condBenchmarks
304+ ]
305+
289306 where
290307 parse :: BS. ByteString -> IO GenericPackageDescription
291308 parse c = do
0 commit comments