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

Issue #11446: Update SuppressionCommentFilterTest to use verifyWithInlineConfigParser #11464

Closed
wants to merge 1 commit into from
Closed

Issue #11446: Update SuppressionCommentFilterTest to use verifyWithInlineConfigParser #11464

wants to merge 1 commit into from

Conversation

Rahulkhinchi03
Copy link
Contributor

Resolves update for SuppressionCommentFilterTest in #11446.

@Rahulkhinchi03
Copy link
Contributor Author

GitHub, rebase

1 similar comment
@Rahulkhinchi03
Copy link
Contributor Author

GitHub, rebase

@Rahulkhinchi03 Rahulkhinchi03 changed the title Issue #11446: Update SuppressionCommentFilterTest to use verifyWithIn… Issue #11446: Update SuppressionCommentFilterTest to use verifyWithInlineConfigParser Mar 25, 2022
Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

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

Items

* @throws Exception if there is a problem during checker configuration
*/
protected final void execute(Configuration moduleConfig, String fileName,
String[] expectedViolations, String... suppressedViolations)
Copy link
Member

Choose a reason for hiding this comment

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

We do not need these parameters

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But we have the verify method in verifySuppressed which uses these 2 parameters like expected violation and suppressed violations

Copy link
Contributor Author

Choose a reason for hiding this comment

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

e77a62f#diff-cf838e5bbdb7de5a3e0e91f9919a389a0fd2ffdbda60c85a3c6dba07dcf69acdR406-R420 only deals with config and file name and when I am using this execute method then we can't use expected and suppressed violation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

    private void verifySuppressed(Configuration moduleConfig, String fileName)
        throws Exception {

        execute(moduleConfig, getPath(fileName));
    }

Like this?

Copy link
Member

Choose a reason for hiding this comment

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

Yes

Copy link
Member

Choose a reason for hiding this comment

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

New method should be created.

Please do not push your code until mvn verify is passing on local.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need Help:

  1. I started with creating:
private void verifySuppressed(Configuration moduleConfig, String fileName)
        throws Exception {

        execute(moduleConfig, getPath(fileName));
    }

in the SuppressionCommentFilterTest.java

  1. I saw that I should change this verifySuppressed method of 3 parameters with my verifySuppressed method that only takes 2 parameters.
    @Test
    public void testInvalidMessageFormat() throws Exception {
        final DefaultConfiguration filterConfig =
            createModuleConfig(SuppressionCommentFilter.class);
        filterConfig.addProperty("messageFormat", "e[l");

        try {
            final String[] suppressed = CommonUtil.EMPTY_STRING_ARRAY;
            verifySuppressed(filterConfig, "InputSuppressionCommentFilter11.java", suppressed);
            assertWithMessage("Exception is expected").fail();
        }
        catch (CheckstyleException ex) {
            final IllegalArgumentException cause = (IllegalArgumentException) ex.getCause();
            assertWithMessage("Invalid exception message")
                .that(cause)
                .hasMessageThat()
                .isEqualTo("unable to parse expanded comment e[l");
        }
    }

Like this -->

        try {
            verifySuppressed(filterConfig, "InputSuppressionCommentFilter11.java");
            assertWithMessage("Exception is expected").fail();
        }

But now I am getting an error of EXCEPTION IS EXPECTED

PS; I haven't changed the verify() method in verifySuppressed method which takes 4 parameter

Copy link
Member

Choose a reason for hiding this comment

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

you updating too much.

you need to remove methods:

-    private void verifySuppressed(Configuration moduleConfig, String fileName,
-            String... aSuppressed)
-            throws Exception {
- 
-    private void verifySuppressed(Configuration moduleConfig, String fileName,
-            String[] expectedViolations, String... suppressedViolations) throws Exception {

and figure out how to upadate test that that used them to execute validation by checkstyle but wihtout comparison with expected violation, as you expect exception.

test has problem with path to file and Input file is over complicated for no reason, so please redo Input file content and have only config for filter and for one Check and in code to have only one violation (no more code in Input file is requied).

time to debug how Checks are working :).

Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

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

Items

@@ -406,8 +396,7 @@ public void testInvalidMessageFormat() throws Exception {
filterConfig.addProperty("messageFormat", "e[l");

try {
final String[] suppressed = CommonUtil.EMPTY_STRING_ARRAY;
verifySuppressed(filterConfig, "InputSuppressionCommentFilter11.java", suppressed);
verifySuppressed(filterConfig, "InputSuppressionCommentFilter11.java");
Copy link
Member

Choose a reason for hiding this comment

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

Method should be "execute" as we do not validate anything, we just run and expect exception

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have used execute method in the verifySuppressed method which takes 2 parameters.

Copy link
Member

Choose a reason for hiding this comment

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

Do not use it inside, use it here.

@romani
Copy link
Member

romani commented Mar 26, 2022

Follow complains from CI

@romani
Copy link
Member

romani commented Mar 30, 2022

@Rahulkhinchi03, ping

@Rahulkhinchi03
Copy link
Contributor Author

@romani I am currently debugging the code and trying to find the reason for EXCEPTION IS EXPECTED

@Rahulkhinchi03
Copy link
Contributor Author

@romani I had some issues with this commit so I created a new PR: #11503

@Rahulkhinchi03 Rahulkhinchi03 deleted the SuppressionCommentFilterTest branch April 3, 2022 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants