Skip to content

Conversation

@leana8959
Copy link

@leana8959 leana8959 commented Nov 13, 2025

We are making changes to the internal representation of GenericPackageDescription in #11277 in order to retain common stanzas. Our current approach with the common stanza retention is done by adding a Map ImportName (CondTree ConfVar [Dependency] BuildInfo) into GenericPackageDescription, and merging on demand with PatternSynonyms accessors.
The current golden test test suite doesn't handle this change well ­— we have one single golden file per GenericPackageDescription data. Adding fields to this data type creates huge amount of diffs, making bugs harder to spot for both me and the reviewers.

To get out of this diff hell, we have split the golden tests of GenericPackageDescription to write each GenericPackageDescription field into its own file. This way, we can quickly identify which behaviour has changed and for which file. New fields will simply be in new files.

This is a separate PR because the diff is very big, which is caused by the golden test files changes. After merging this, #11277's diff would roughly drop from 24kloc to 1.8kloc. This would make the actual behaviour changes more reviewable.

This PR does not modify behaviour or interface

E.g. the PR only touches documentation or tests, does refactorings, etc.

Include the following checklist in your PR:

  • Patches conform to the coding conventions.
  • Is this a PR that fixes CI? If so, it will need to be backported to older cabal release branches (ask maintainers for directions).

import Distribution.PackageDescription (GenericPackageDescription)
import Distribution.PackageDescription
( GenericPackageDescription
( packageDescription
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general it's more robust to import Distribution.PackageDescription (GenericPackageDescription, fooField, bazField) than import Distribution.PackageDescription (GenericPackageDescription (fooField, bazField)). If in future the fields of GPD are changed and old accessors become simple functions (retained for backwards compatibility), the first form survives without a change, while the second would have to be amended.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know this is possible, I'll change this :)

let y' = y

let checkField field =
unless (field x == field y) $
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While at it, could you possible use (@?) or assertBool instead of raw assertFailure?

@leana8959 leana8959 mentioned this pull request Nov 14, 2025
6 tasks
@leana8959 leana8959 changed the title Accessor tests Per-field GenericPackageDescription golden test Nov 15, 2025
@leana8959 leana8959 marked this pull request as ready for review November 15, 2025 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants