-
Notifications
You must be signed in to change notification settings - Fork 325
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
Golden tests for JSON instances #1486
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced May 4, 2021
pcapriotti
force-pushed
the
pcapriotti/golden-tests
branch
4 times, most recently
from
May 6, 2021 08:53
c68fe94
to
42d0d72
Compare
These have been generated by patching wire-api to make sure that Show instances generate valid Haskell code.
pcapriotti
changed the title
[WIP] Golden tests for JSON instances [skip ci]
Golden tests for JSON instances
May 10, 2021
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.
Looks good, but let's add license headers to all the generated haskell.
Also update patch
akshaymankar
approved these changes
May 10, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This introduces some golden tests for JSON instances. The way this works is that when the test does not find JSON files to compare against, it fails, but it also generates them. One is supposed to add the files to git, and rerun the tests (which will now mostly likely pass). If in the future the JSON instance changes, the test will hopefully catch it.
The way the tests are generated is a bit hacky and hard to reproduce, but hopefully it shouldn't be done too often. Basically, the wire-server code is patched to add some ad-hoc
Show
instances. Then theArbitrary
instances are used to generate random objects, which are then printed and end up in theGolden.Generated
module as Haskell code. Some of this code is fixed by a sed script after the fact.So to regenerate
Golden.Generated
one can do the following:libs/wire-api/test/golden/
withgit am
gentests.sh
scriptTODO