-
Notifications
You must be signed in to change notification settings - Fork 40
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
WordPressVIPMinimum: fix the failing ruleset test & let Travis show failures #504
WordPressVIPMinimum: fix the failing ruleset test & let Travis show failures #504
Conversation
In the |
Except that in the line in the WordPressVIPMinimum test case file, both I can, of course, rename it to something else, I do think the other changes related to the potential for |
@GaryJones Oh and another thing - that still wouldn't take care of the fact that PHP 5 does not throw a parse error on line 7. |
The builds on PHP 5.4, 5.5 and 5.6 should have been failing on the ruleset test for a while now, but aren't. Example: https://travis-ci.org/github/Automattic/VIP-Coding-Standards/jobs/710513865#L311-L315 What is happening here is that when several commands are run via a script, Travis will only look at the exit code of the last script to decide whether the build should be failed or not. This means that failures from the `WordPressVIPMinimum` ruleset test were never failing the build as they were hidden by a passing ruleset test for the `WordPress-VIP-Go` ruleset. By chaining the commands together, the exit codes of both commands are taken into account when determining whether the build should be failed or not.
In which case, I think the definition of
Yes. I'm not precious about the names of the variables used in the rulesets - one minor task would be to minimise the variations of the variables names even more to reduce the size of line 5 to make it more reasonable. My thought was that we could even call them
If PHP version check is needed for this, then that's fine. What's the reason for the parse error in PHP 5? Could we use another code snippet that is a syntax error for all PHP versions instead?
+1; I'd not seen any instance of those values until now. |
6980e12
to
199dd57
Compare
@GaryJones I've updated the PR to address both issues in an alternative way. The last two commits can be folded into the second commit realistically, but I've committed them separately for now to make reviewing the difference between the alternative solution and the original PR easier. Would you like me to tidy up the commits before merge after you've reviewed ? And to answer your questions:
Of course we can ;-)
I suggest we open an issue for that with low priority.
And they aren't there now anymore either, but having that defensive coding in place will save us scratching our heads again at a later point when it comes up again ;-) |
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.
Would you like me to tidy up the commits before merge after you've reviewed ?
Yes please, thanks!
Ok, this is a fun one. Line 5 of the ruleset-test is not supposed to error. It is just setting up the variables for the VariableAnalysis test. Line 7, however, is supposed to error on a PHP parse error (`Generic.PHP.Syntax`). The above is true and working for PHP 7. However on PHP 5, line 7 will not throw a parse error, while line 5 actually will - `Cannot re-assign $this`. To fix this, I've: * Replaced the `$this` variable assignment on line 5 with an assignment to `$stdClass`. * Replaced the PHP 7 parse error on line 7 with a parse error which will error on all currently known PHP versions. Fun times ;-)
199dd57
to
4aed540
Compare
Turns out the test script was not set up to be able to deal with `0` values and would throw a very informative "_Expected 0 errors, found 0 on line 7._" error in such a case. Fixed now.
@GaryJones Done. |
Ruleset test script: fail the build on failing ruleset tests
The builds on PHP 5.4, 5.5 and 5.6 should have been failing on the ruleset test for a while now, but aren't.
Example: https://travis-ci.org/github/Automattic/VIP-Coding-Standards/jobs/710513865#L311-L315
What is happening here is that when several commands are run via a script, Travis will only look at the exit code of the last script to decide whether the build should be failed or not.
This means that failures from the
WordPressVIPMinimum
ruleset test were never failing the build as they were hidden by a passing ruleset test for theWordPress-VIP-Go
ruleset.By chaining the commands together, the exit codes of both commands are taken into account when determining whether the build should be failed or not.
WordPressVIPMinimum: fix the failing ruleset test
Ok, this is a fun one.
Line 5 of the ruleset-test is not supposed to error. It is just setting up the variables for the VariableAnalysis test.
Line 7, however, is supposed to error on a PHP parse error (
Generic.PHP.Syntax
).The above is true and working for PHP 7.
However on PHP 5, line 7 will not throw a parse error, while line 5 actually will -
Cannot re-assign $this
.As the test on line 7 is about checking that the parse error sniff is correctly triggered and the error on line 5 on PHP 5 is a parse error, I deem this sufficiently covered and have fixed the build failure by making the expected errors on line 5 and 7 conditional on the PHP version on which the tests are being run.
Includes annotating these findings in the inline documentation of the test case file.
Fun times ;-)
RulesetTest: fix the test script to be able to handle 0 values
Turns out the test script was not set up to be able to deal with
0
values and would throw a very informative "Expected 0 errors, found 0 on line 7." error in such a case.Fixed now.