-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Issue #3961: DetailASTTest: 'checkTree' failing on deep AST tree #3966
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3966 +/- ##
======================================
Coverage 100% 100%
======================================
Files 283 283
Lines 14758 14758
Branches 3367 3367
======================================
Hits 14758 14758 Continue to review full report at Codecov.
|
private static void checkTree(final String filename, final DetailAST root) { | ||
DetailAST curNode = root; | ||
while (curNode != null) { | ||
checkNode(curNode, curNode.getParent(), curNode.getPreviousSibling(), filename, root); |
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.
Information sent to the method can't be done using the DetailAST
methods.
The whole point of this test is to verify those exact methods are functioning properly.
Example: Parameter prev
is set to curNode.getPreviousSibling()
and inside the method, it is then verified by assertEquals(badPrevMsg, prev, node.getPreviousSibling());
.
All it is doing now is testing the method against itself. If you change getPreviousSibling()
to return an invalid value, test would still pass.
Original test kept track of the parent and previous itself. This is why.
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.
Just some information:
This test assumes getFirstChild
and getNextSibling
are working correctly. We can assume getParent
and getPreviousSibling
are valid after this check
method call.
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.
Done. I misunderstood the purpose of that test before. Sorry for my careless 😅
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 am now having second thoughts about keeping the bad input file once I saw it is almost 4 megs in size.
@romani what do you think? Should we make an exception and just remove it?
uhh, and all that only to keep UT code correct. can we generate such file in runtime in temp folder ? |
Agree. Maybe it is better to skip that one file or just generate it in runtime. On the other hand, it can be placed at resources-noncompilable folder with an explanation why it is there. |
it will keep the same size in repo, it very undesirable. Fact that it is NOT a Input for main code lowers its value. |
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.
we need to try generate file in run time. Comment over generation code is required to explain.
653d9a1
to
f7ec6e3
Compare
Sorry for the late reply. I went climbing at the last weekend. 😅
@rnveach I didn't simplify the input file before. The original one is just a duplicate of https://github.com/checkstyle/checkstyle/blob/master/src/test/resources/com/puppycrawl/tools/checkstyle/checks/InputAllEscapedUnicodeCharacters.java. It is 12kb after the optimization, and can also be used to reproduce the stackoverflow error. @romani @MEZk BTW, I don't know why |
I am fine with 12kb. wrecker failure is timeout on checkstyle regression. |
Changes are ok, but we need to pass wercker. Wercker logs: https://gist.github.com/romani/306d36ba1a6590658db911906b83ac66 |
43cef0f
to
a47d2fd
Compare
This time is |
@romani |
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 am Ok with Changes,
#3961
The fix will follow the steps below:
Currently I am doing step one. I have duplicated the input file which makes CI failed in #3700. I am waiting for the CI result now.The stackoverflow is reproduced successfully. https://travis-ci.org/checkstyle/checkstyle/jobs/209359675#L2123
CI passed after rewriting the test now.
Diff report:
http://www.luolc.com/checkstyle-diff-report/issue3961/
@rnveach please have a review 😄