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).

@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
@Bodigrim
Copy link
Collaborator

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.

I'm not quite convinced about this. Having an entire GPD in a single file is much more convenient than scattered across a dozen of them. If you wish to future-proof the test suite against future changes to GPD fields, you can serialise a tuple of (packageDescription, gpdScannedVersion, genPackageFlags, condLibrary, condSubLibraries, condForeignLibs, condExecutables, condTestSuites, condBenchmarks) but still in the same file. What do you think?

@leana8959
Copy link
Author

@Bodigrim That is true, thanks for the comment :). I just did that for this branch and for #11277, which now has a diff of 2.5kloc now. Does this PR still have its place or should I close this one and focus on that one instead knowing the diff is significantly smaller?

@Bodigrim
Copy link
Collaborator

I think it's fine to change this in a separate branch to keep other PRs smaller.

@leana8959
Copy link
Author

I see, thanks for the review :)

As Artem mentioned in the comment parser PR, if it's useful to rebase and reduce the test related commit to only one, let me know and I'll do it 👍

@Bodigrim
Copy link
Collaborator

Rebase and preferably squash please, yes.

@mpickering
Copy link
Collaborator

@leana8959 We can land this shortly but it would be good to address my two comments to future-proof this.

@leana8959
Copy link
Author

I end up changing the ToExpr instance of GenericPackageDescription with a pattern match and named fields. What do you think about this?

test: check equality on each field

test: improve import list

test: use @? operator

test: use a tuple to store all gpd fields

test: define ToExpr tuple instance manually

test: update expected

test: use Rec constructor to annotate field names

test: update expected

test: remove comment not in scope for this PR

test: use field equality in hackage tests
@leana8959
Copy link
Author

I squashed everything into one commit so this should be ready for review!
The CI failure seems to be caused by an unrelated curl failure.

@geekosaur
Copy link
Collaborator

@jappeace, we have the reviews, we just need someone to mark the earlier comments as resolved if they are.

@leana8959
Copy link
Author

Just resolved the earlier comments! Sorry that took a while, I thought you wanted someone from the review side to resolve them.

@geekosaur
Copy link
Collaborator

In general we expect that you resolve them if you believe you have addressed them, and request further reviews if you think it might be needed. (I personally often re-request a review from the person who made the review comment.)

One reason for this is that GitHub's UI can otherwise "lose" review comments: a change that removes the line commented on will make the review comment inaccessible, but GitHub will still consider the comment unresolved. In this case you need to (possibly get someone with access to) dismiss the review comment.

@geekosaur
Copy link
Collaborator

Also I see two review comments from @Bodigrim that are still open.

@leana8959
Copy link
Author

I see, that makes sense. Also oops I didn't scroll up far enough, I resolved everything now.

@ulysses4ever
Copy link
Collaborator

I disagree with @geekosaur on how comment resolution should work. I prefer it when comments left by me are resolved by me as well. I guess we should decide what we want to do in the Cabal project and write it down in CONTRIBUTING.md.

I saw a question from Matt that could use an explicit answer, not just code update: #11285 (comment)

@Bodigrim
Copy link
Collaborator

I disagree with @geekosaur on how comment resolution should work. I prefer it when comments left by me are resolved by me as well. I guess we should decide what we want to do in the Cabal project and write it down in CONTRIBUTING.md.

It would be most helpful to write it down indeed. My recent attempt to demistify the contribution process in #11232 (comment) left me absolutely baffled (and, more specifically, under an impression that a PR author is free to resolve comments themselves).

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.

6 participants