Skip to content

Commit

Permalink
Issue checkstyle#11446: Update AllSinglelineCommentsTest to use Abstr…
Browse files Browse the repository at this point in the history
…actModuleTestSupport#execute
  • Loading branch information
nrmancuso committed Mar 21, 2022
1 parent cd682af commit 0b894f1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 0 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1548,8 +1548,6 @@

<exclude>**/SuppressionSingleFilterTest.class</exclude>

<exclude>**/AllSinglelineCommentsTest.class</exclude>

<exclude>**/FileSetCheckTest.class</exclude>

<exclude>**/AbstractFileSetCheckTest.class</exclude>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,22 @@ protected final void verifyWithLimitedResources(String fileName, String... expec
.isNull();
}

/**
* Executes given config on a list of files only. Does not verify violations.
*
* @param config check configuration
* @param filenames names of files to process
* @throws Exception if there is a problem during checker configuration
*/
protected final void execute(Configuration config, String... filenames) throws Exception {
final Checker checker = createChecker(config);
final List<File> files = Arrays.stream(filenames)
.map(File::new)
.collect(Collectors.toList());
checker.process(files);
checker.destroy();
}

/**
* Performs verification of violation lines.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ public void testAllSinglelineComments() throws Exception {
createModuleConfig(SinglelineCommentListenerCheck.class);
final String path = getPath("InputFullOfSinglelineComments.java");
lineSeparator = CheckUtil.getLineSeparatorForFile(path, StandardCharsets.UTF_8);
final String[] expected = CommonUtil.EMPTY_STRING_ARRAY;
verify(checkConfig, path, expected);
execute(checkConfig, path);
assertWithMessage("All comments should be empty")
.that(ALL_COMMENTS)
.isEmpty();
Expand Down

0 comments on commit 0b894f1

Please sign in to comment.