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 b365d91
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 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 @@ -288,6 +288,22 @@ protected final void verify(Configuration aConfig, String fileName, String... ex
verify(createChecker(aConfig), fileName, fileName, expected);
}

/**
* 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 the file with the given file name.
* Uses provided {@link Checker} instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void testAllSinglelineComments() throws Exception {
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 b365d91

Please sign in to comment.