Skip to content
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

Add tool to generate formatting fixtures #1936

Merged
merged 7 commits into from
Feb 25, 2022

Conversation

cognifloyd
Copy link
Contributor

Add tools/generate-formatting-fixtures.py which uses prettier to generate the fixture files.

Rename test/fixtures/formatting-after -> test/fixtures/formatting-prettier.
Add new test/fixtures/formatting-ruamel-yaml which is a copy of the prettier files for now.
In #1927, the diff will show where our ruamel.yaml formatter differs from prettier.

Also, add new fmt-2.yml formatting test fixture to cover a few more yaml oddities.

@cognifloyd cognifloyd requested a review from a team as a code owner February 21, 2022 23:02
@cognifloyd cognifloyd added this to the 6.0.0 milestone Feb 21, 2022
@cognifloyd cognifloyd added the skip-changelog Can be missed from the changelog. label Feb 21, 2022
@cognifloyd cognifloyd requested review from ssbarnea and removed request for a team February 21, 2022 23:02
@cognifloyd cognifloyd force-pushed the generate-formatting-fixtures branch from f6338ea to 725be20 Compare February 21, 2022 23:04
@cognifloyd cognifloyd self-assigned this Feb 21, 2022
@cognifloyd
Copy link
Contributor Author

aargh. galaxy seems to be on the fritz.

@webknjaz
Copy link
Member

Consider implementing this as a pytest plugin activated by a custom CLI option.

@cognifloyd
Copy link
Contributor Author

@webknjaz done. I converted it to a "test" + pytest plugin. If --regenerate-formatting-fixtures, the plugin skips all tests except the one that regenerates the fixtures. Otherwise it skips just test_regenerate_formatting_fixtures.

Copy link
Member

@ssbarnea ssbarnea left a comment

Choose a reason for hiding this comment

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

OK. I made a fix myself to keep using "after" in naming of formatting fixtures as we should not use implementation detail in them.

Keep in mind that we might start to format something else than yaml or to swap for another yaml library. The fact that we use ruamel-yaml is an implementation detail.

@ssbarnea ssbarnea merged commit 5584461 into ansible:main Feb 25, 2022
@cognifloyd
Copy link
Contributor Author

Works for me. Thanks for reviewing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog Can be missed from the changelog.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants