@@ -16,7 +16,10 @@ import Data.Maybe (isNothing)
1616import Distribution.Fields (pwarning )
1717import Distribution.PackageDescription (GenericPackageDescription )
1818import 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