Skip to content

Commit 8e1fb53

Browse files
committed
add test for skipLinesMatching setting of license header step
1 parent 3a3583b commit 8e1fb53

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN" "https://checkstyle.org/dtds/configuration_1_3.dtd">
3+
4+
<module name="Checker">
5+
<module name="ThisIsNotARealCheckstyleConfigFolks">
6+
<property name="goodAdvice" value="dontTryItAnakin"/>
7+
<property name="adviceGiver" value="generalKenobi"/>
8+
</module>
9+
</module>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN" "https://checkstyle.org/dtds/configuration_1_3.dtd">
3+
<!--
4+
-- This is a fake license header.
5+
-- All rights reserved.
6+
-->
7+
8+
<module name="Checker">
9+
<module name="ThisIsNotARealCheckstyleConfigFolks">
10+
<property name="goodAdvice" value="dontTryItAnakin"/>
11+
<property name="adviceGiver" value="generalKenobi"/>
12+
</module>
13+
</module>

testlib/src/test/java/com/diffplug/spotless/generic/LicenseHeaderStepTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ void should_remove_header_when_empty() throws Throwable {
122122
.test(getTestResource("license/HasLicense.test"), getTestResource("license/MissingLicense.test"));
123123
}
124124

125+
@Test
126+
void should_skip_lines_matching_predefined_pattern() throws Throwable {
127+
StepHarness.forStep(LicenseHeaderStep.headerDelimiter("<!--\n -- This is a fake license header.\n -- All rights reserved.\n -->", "^(?!<!--|\\s+--).*$")
128+
.withSkipLinesMatching("(?i)^(<\\?xml[^>]+>|<!doctype[^>]+>)$").build())
129+
.testResource("license/SkipLines.test", "license/SkipLinesHasLicense.test");
130+
}
131+
125132
private String licenceWithAddress() {
126133
return "Copyright &#169; $YEAR FooBar Inc. All Rights Reserved.\n" +
127134
" *\n" +

0 commit comments

Comments
 (0)