-
Notifications
You must be signed in to change notification settings - Fork 723
Per-field GenericPackageDescription golden test
#11285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Cabal-tests/tests/ParserTests.hs
Outdated
| import Distribution.PackageDescription (GenericPackageDescription) | ||
| import Distribution.PackageDescription | ||
| ( GenericPackageDescription | ||
| ( packageDescription |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :)
Cabal-tests/tests/ParserTests.hs
Outdated
| let y' = y | ||
|
|
||
| let checkField field = | ||
| unless (field x == field y) $ |
There was a problem hiding this comment.
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?
GenericPackageDescription golden test
We are making changes to the internal representation of
GenericPackageDescriptionin #11277 in order to retain common stanzas. Our current approach with the common stanza retention is done by adding aMap ImportName (CondTree ConfVar [Dependency] BuildInfo)intoGenericPackageDescription, and merging on demand withPatternSynonymsaccessors.The current golden test test suite doesn't handle this change well — we have one single golden file per
GenericPackageDescriptiondata. 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
GenericPackageDescriptionto write eachGenericPackageDescriptionfield 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: