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
Bug: change in test runner breaks tests with exclusions #1177
Comments
This is by design in the new testing system. If you are testing a sniff like WordPress.Arrays.ArrayDeclaration, and that sniffs produces a WordPress.Arrays.ArrayDeclaration.SingleLineNotAllowed error, you'll need your test to ensure that the error is being produced correctly. The fact that a ruleset excludes it doesn't mean that the sniff doesn't produce it and that it should not be tested. If someone else wants to use that sniff, they'd need to know that the error is being correctly reported. I suspect what is happening here is that the sniff itself is reporting the error because it is shortcutting the process of array checking by just extending the Squiz sniff. If this is the case, the ruleset should really be referencing the Squiz sniff and excluding the messages it doesn't want. If additional array checks need to be made in the WordPress sniff, the sniff should only report those. Or, the sniff needs needs to only produce the errors that you want. |
Sorry, I forgot to make my final point before submitting that comment. My main point is that the unit tests are for checking that sniffs work correctly. They aren't for checking that rulesets work correctly. |
Thanks for your repsonse. Makes sense.
I think this is the direction these kind of sniffs should be taking. Will look into refactoring those. |
The Squiz array sniff is a horrible sniff because it is all just a big lump. I have plans, that I can never seem to get around to, for creating a bunch of new Generic sniffs to check those common individual rules. Then probably a new one to enforce a simpler array indent rule rather than the convoluted one the Squiz standard uses now. It's one of the original sniffs from before PHPCS was a public project, so it needs some love. |
I hear you, if only days had 40 hours each ;-) Hmm.. we'd probably still have the same struggle for time.... FYI: I'm working on a number of extra utility functions, things like |
I sure do. |
The change in commit 3df85dc breaks tests for rulesets which include a rule, but exclude a modular sub-sniff.
The exclusion is no longer respected and results in unit test run failures such as: https://travis-ci.org/WPTRT/WordPress-Coding-Standards/jobs/163087045#L188.
Minimal code example to reproduce the issue:
Ruleset
ruleset.xml
:Sniff file
WordPress/Sniffs/Arrays/ArrayDeclarationSniff.php
Test case
WordPress/Tests/Arrays/ArrayDeclarationUnitTest.inc
:Test case fixed file
WordPress/Tests/Arrays/ArrayDeclarationUnitTest.inc.fixed
:Failure details:
The text was updated successfully, but these errors were encountered: