Skip to content

Commit 1474d99

Browse files
committed
Fix the rest of the ktlint tests.
1 parent 1d9d686 commit 1474d99

File tree

3 files changed

+3
-133
lines changed

3 files changed

+3
-133
lines changed

plugin-gradle/src/test/java/com/diffplug/gradle/spotless/KotlinExtensionTest.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -177,31 +177,6 @@ void withExperimentalEditorConfigOverride() throws IOException {
177177
assertFile("src/main/kotlin/Main.kt").sameAsResource("kotlin/ktlint/experimentalEditorConfigOverride.clean");
178178
}
179179

180-
/**
181-
* Check that the sample used to verify the experimental ruleset is untouched by the default ruleset, to verify
182-
* that enabling the experimental ruleset is actually doing something.
183-
*
184-
* If this test fails, it's likely that the experimental rule being used as a test graduated into the standard
185-
* ruleset, and therefore a new experimental rule should be used to verify functionality.
186-
*/
187-
@Test
188-
void experimentalSampleUnchangedWithDefaultRuleset() throws IOException {
189-
setFile("build.gradle").toLines(
190-
"plugins {",
191-
" id 'org.jetbrains.kotlin.jvm' version '1.5.31'",
192-
" id 'com.diffplug.spotless'",
193-
"}",
194-
"repositories { mavenCentral() }",
195-
"spotless {",
196-
" kotlin {",
197-
" ktlint()",
198-
" }",
199-
"}");
200-
setFile("src/main/kotlin/Main.kt").toResource("kotlin/ktlint/experimental.dirty");
201-
gradleRunner().withArguments("spotlessApply").build();
202-
assertFile("src/main/kotlin/Main.kt").sameAsResource("kotlin/ktlint/experimental.dirty");
203-
}
204-
205180
@Test
206181
void testWithHeader() throws IOException {
207182
setFile("build.gradle").toLines(

plugin-gradle/src/test/java/com/diffplug/gradle/spotless/KotlinGradleExtensionTest.java

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -94,24 +94,6 @@ void integration_default_diktat() throws IOException {
9494
assertThat(result.getOutput()).contains("[AVOID_NESTED_FUNCTIONS] try to avoid using nested functions");
9595
}
9696

97-
@Test
98-
void integration_pinterest() throws IOException {
99-
setFile("build.gradle").toLines(
100-
"plugins {",
101-
" id 'org.jetbrains.kotlin.jvm' version '1.5.31'",
102-
" id 'com.diffplug.spotless'",
103-
"}",
104-
"repositories { mavenCentral() }",
105-
"spotless {",
106-
" kotlinGradle {",
107-
" ktlint('0.32.0')",
108-
" }",
109-
"}");
110-
setFile("configuration.gradle.kts").toResource("kotlin/ktlint/basic.dirty");
111-
gradleRunner().withArguments("spotlessApply").build();
112-
assertFile("configuration.gradle.kts").sameAsResource("kotlin/ktlint/basic.clean");
113-
}
114-
11597
@Test
11698
void indentStep() throws IOException {
11799
setFile("build.gradle").toLines(
@@ -147,24 +129,6 @@ void withExperimental() throws IOException {
147129
assertFile("configuration.gradle.kts").sameAsResource("kotlin/ktlint/experimental.clean");
148130
}
149131

150-
@Test
151-
void withExperimental_0_32() throws IOException {
152-
setFile("build.gradle").toLines(
153-
"plugins {",
154-
" id 'org.jetbrains.kotlin.jvm' version '1.5.31'",
155-
" id 'com.diffplug.spotless'",
156-
"}",
157-
"repositories { mavenCentral() }",
158-
"spotless {",
159-
" kotlinGradle {",
160-
" ktlint('0.32.0').setUseExperimental(true)",
161-
" }",
162-
"}");
163-
setFile("configuration.gradle.kts").toResource("kotlin/ktlint/basic.dirty");
164-
gradleRunner().withArguments("spotlessApply").build();
165-
assertFile("configuration.gradle.kts").sameAsResource("kotlin/ktlint/basic.clean");
166-
}
167-
168132
@Test
169133
void withExperimentalEditorConfigOverride() throws IOException {
170134
setFile("build.gradle").toLines(
@@ -187,53 +151,6 @@ void withExperimentalEditorConfigOverride() throws IOException {
187151
assertFile("configuration.gradle.kts").sameAsResource("kotlin/ktlint/experimentalEditorConfigOverride.clean");
188152
}
189153

190-
@Test
191-
void withEditorConfigOverride_0_45_1() throws IOException {
192-
setFile("build.gradle").toLines(
193-
"plugins {",
194-
" id 'org.jetbrains.kotlin.jvm' version '1.5.31'",
195-
" id 'com.diffplug.spotless'",
196-
"}",
197-
"repositories { mavenCentral() }",
198-
"spotless {",
199-
" kotlinGradle {",
200-
" ktlint('0.45.1')",
201-
" .editorConfigOverride([",
202-
" indent_size: 5",
203-
" ])",
204-
" }",
205-
"}");
206-
setFile("configuration.gradle.kts").toResource("kotlin/ktlint/basic.dirty");
207-
Throwable error = assertThrows(Throwable.class,
208-
() -> gradleRunner().withArguments("spotlessApply").build());
209-
assertThat(error).hasMessageContaining("KtLint editorConfigOverride supported for version 0.45.2 and later");
210-
}
211-
212-
/**
213-
* Check that the sample used to verify the experimental ruleset is untouched by the default ruleset, to verify
214-
* that enabling the experimental ruleset is actually doing something.
215-
*
216-
* If this test fails, it's likely that the experimental rule being used as a test graduated into the standard
217-
* ruleset, and therefore a new experimental rule should be used to verify functionality.
218-
*/
219-
@Test
220-
void experimentalSampleUnchangedWithDefaultRuleset() throws IOException {
221-
setFile("build.gradle").toLines(
222-
"plugins {",
223-
" id 'org.jetbrains.kotlin.jvm' version '1.5.31'",
224-
" id 'com.diffplug.spotless'",
225-
"}",
226-
"repositories { mavenCentral() }",
227-
"spotless {",
228-
" kotlinGradle {",
229-
" ktlint()",
230-
" }",
231-
"}");
232-
setFile("configuration.gradle.kts").toResource("kotlin/ktlint/experimental.dirty");
233-
gradleRunner().withArguments("spotlessApply").build();
234-
assertFile("configuration.gradle.kts").sameAsResource("kotlin/ktlint/experimental.dirty");
235-
}
236-
237154
@Test
238155
@EnabledForJreRange(min = JAVA_11) // ktfmt's dependency, google-java-format 1.8 requires a minimum of JRE 11+.
239156
void integration_ktfmt() throws IOException {

plugin-maven/src/test/java/com/diffplug/spotless/maven/kotlin/KtlintTest.java

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,9 @@ class KtlintTest extends MavenIntegrationHarness {
2424
void testKtlint() throws Exception {
2525
writePomWithKotlinSteps("<ktlint/>");
2626

27-
String path1 = "src/main/kotlin/main1.kt";
28-
String path2 = "src/main/kotlin/main2.kt";
29-
30-
setFile(path1).toResource("kotlin/ktlint/basic.dirty");
31-
setFile(path2).toResource("kotlin/ktlint/basic.dirty");
32-
27+
String path = "src/main/kotlin/Main.kt";
28+
setFile(path).toResource("kotlin/ktlint/basic.dirty");
3329
mavenRunner().withArguments("spotless:apply").runNoError();
34-
35-
assertFile(path1).sameAsResource("kotlin/ktlint/basic.clean");
36-
assertFile(path2).sameAsResource("kotlin/ktlint/basic.clean");
37-
}
38-
39-
@Test
40-
void testKtlintShyiko() throws Exception {
41-
writePomWithKotlinSteps("<ktlint><version>0.21.0</version></ktlint>");
42-
43-
String path1 = "src/main/kotlin/main1.kt";
44-
String path2 = "src/main/kotlin/main2.kt";
45-
46-
setFile(path1).toResource("kotlin/ktlint/basic.dirty");
47-
setFile(path2).toResource("kotlin/ktlint/basic.dirty");
48-
49-
mavenRunner().withArguments("spotless:apply").runNoError();
50-
51-
assertFile(path1).sameAsResource("kotlin/ktlint/basic.clean");
52-
assertFile(path2).sameAsResource("kotlin/ktlint/basic.clean");
30+
assertFile(path).sameAsResource("kotlin/ktlint/basic.clean");
5331
}
5432
}

0 commit comments

Comments
 (0)