-
Notifications
You must be signed in to change notification settings - Fork 665
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
Ensure that single space between tasks is preserved when using --write #3641
Conversation
test/test_yaml_utils.py
Outdated
|
||
before_formatting = yaml.loads(task_file_content) | ||
dump_from_formatting = yaml.dumps(before_formatting) | ||
assert task_file_content == dump_from_formatting |
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.
Basically you do only test that the formatter does not change the output in any way, but that is not a good enough way to test that the spacing is the correct one. I would want to also see a case where it is bad before and transformer is changing it the way we want.
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.
Another question that I have: if I comment the code change and only include the tests, are they going to pass? If they pass already it means they have only very limited value. If not, they are likely ok.
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 see that the body of the test looks identical. Maybe it would be better to use parameterized tests instead of repeating the same body of the test. Also this should make it easier to add other test files later, for other test-cases.
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.
Basically you do only test that the formatter does not change the output in any way, but that is not a good enough way to test that the spacing is the correct one. I would want to also see a case where it is bad before and transformer is changing it the way we want.
Initially I was testing exacting like this (with two different files basically) one with bad/extra spacing and other one with correct spacing after transform. And it was working as we want, but after pushing that commit prettier hook in the pre-commit
modified the before-file to remove some of the extra spaces between the tasks so I switched to using a single file because eventually pre-commit was making both of them identical.
In this commit: 2ddcea0
Update: The problem with prettier hook got resolved after moving these tests into test/fixtures/formatting-before/
directory.
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.
Another question that I have: if I comment the code change and only include the tests, are they going to pass? If they pass already it means they have only very limited value. If not, they are likely ok.
These new added tests won't pass, if I comment the code changes.
test/test_yaml_utils.py
Outdated
|
||
before_formatting = yaml.loads(task_file_content) | ||
dump_from_formatting = yaml.dumps(before_formatting) | ||
assert task_file_content == dump_from_formatting |
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.
Another question that I have: if I comment the code change and only include the tests, are they going to pass? If they pass already it means they have only very limited value. If not, they are likely ok.
test/test_yaml_utils.py
Outdated
|
||
before_formatting = yaml.loads(task_file_content) | ||
dump_from_formatting = yaml.dumps(before_formatting) | ||
assert task_file_content == dump_from_formatting |
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 see that the body of the test looks identical. Maybe it would be better to use parameterized tests instead of repeating the same body of the test. Also this should make it easier to add other test files later, for other test-cases.
158a3c5
to
4652da5
Compare
for more information, see https://pre-commit.ci
b650f8c
to
ebb7e13
Compare
This PR contains the following updates: | Package | Update | Change | |---|---|---| | [ansible-lint](https://github.com/ansible/ansible-lint) ([changelog](https://github.com/ansible/ansible-lint/releases)) | minor | `==6.17.2` -> `==6.18.0` | --- ### Release Notes <details> <summary>ansible/ansible-lint (ansible-lint)</summary> ### [`v6.18.0`](https://github.com/ansible/ansible-lint/releases/tag/v6.18.0) [Compare Source](ansible/ansible-lint@v6.17.2...v6.18.0) #### Minor Changes - Limit the maximum block depth ([#​3602](ansible/ansible-lint#3602)) [@​Ruchip16](https://github.com/Ruchip16) - Transform functionality for command_instead_of_shell ([#​3675](ansible/ansible-lint#3675)) [@​ajinkyau](https://github.com/ajinkyau) - Add rule to check the number of tasks ([#​3156](ansible/ansible-lint#3156)) [@​Ruchip16](https://github.com/Ruchip16) #### Bugfixes - Clarify loop-var-prefix rule and code snippet ([#​3642](ansible/ansible-lint#3642)) [@​schwarmco](https://github.com/schwarmco) - Update `version_added` for complexity rule ([#​3623](ansible/ansible-lint#3623)) [@​ajinkyau](https://github.com/ajinkyau) - Ensure that single space between tasks is preserved when using --write ([#​3641](ansible/ansible-lint#3641)) [@​shatakshiiii](https://github.com/shatakshiiii) - Update ansible-compat used for testing ([#​3664](ansible/ansible-lint#3664)) [@​ssbarnea](https://github.com/ssbarnea) - Document `yaml[line-length]` rule ([#​3653](ansible/ansible-lint#3653)) [@​shatakshiiii](https://github.com/shatakshiiii) - Prevent use of spdx-tools 0.8.0 due to breaking changes ([#​3649](ansible/ansible-lint#3649)) [@​ssbarnea](https://github.com/ssbarnea) - fixes dead marketplace link ([#​3631](ansible/ansible-lint#3631)) [@​wookietreiber](https://github.com/wookietreiber) - Improve profile information on summary line ([#​3637](ansible/ansible-lint#3637)) [@​ziegenberg](https://github.com/ziegenberg) - command-instead-of-module: allow `git rev-parse` ([#​3610](ansible/ansible-lint#3610)) [@​JohnVillalovos](https://github.com/JohnVillalovos) - Include filepaths starting from $HOME in lintables ([#​3621](ansible/ansible-lint#3621)) [@​shatakshiiii](https://github.com/shatakshiiii) - Update \_mockings.py to fix bug created in [#​3390](ansible/ansible-lint#3390) ([#​3614](ansible/ansible-lint#3614)) [@​karcaw](https://github.com/karcaw) - Allow to set gather_facts as templated boolean ([#​3606](ansible/ansible-lint#3606)) [@​noonedeadpunk](https://github.com/noonedeadpunk) - Add dependency version check for collection metadata ([#​3601](ansible/ansible-lint#3601)) [@​ajinkyau](https://github.com/ajinkyau) - Fix installation of dependencies when run as an action ([#​3592](ansible/ansible-lint#3592)) [@​ssbarnea](https://github.com/ssbarnea) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4yMy4yIiwidXBkYXRlZEluVmVyIjoiMzYuMjMuMiIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Reviewed-on: https://git.home/nrdufour/home-ops/pulls/49 Co-authored-by: Renovate <renovate@ptinem.io> Co-committed-by: Renovate <renovate@ptinem.io>
Fixes: #3603, #2112