Skip to content

Commit

Permalink
Enabled functionalTest in gradle plugin (#1579)
Browse files Browse the repository at this point in the history
  • Loading branch information
nulls authored Nov 25, 2022
1 parent 67aee72 commit fb849b4
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 26 deletions.
1 change: 1 addition & 0 deletions diktat-gradle-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
<arguments>
<argument>clean</argument>
<argument>test</argument>
<argument>functionalTest</argument>
<argument>-Pgroup=${project.groupId}</argument>
<argument>-Pversion=${project.version}</argument>
<argument>-Pdescription=${project.description}</argument>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package org.cqfn.diktat.plugin.gradle

import org.cqfn.diktat.plugin.gradle.DiktatGradlePlugin.Companion.DIKTAT_CHECK_TASK
import org.gradle.buildinit.plugins.internal.modifiers.BuildInitDsl
import org.gradle.internal.impldep.org.junit.rules.TemporaryFolder
import org.gradle.testkit.runner.TaskOutcome
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import java.io.File
Expand All @@ -30,18 +28,8 @@ class DiktatGradlePluginMultiprojectFunctionalTest {
@Test
fun `should execute diktatCheck on default values in multiproject build`() {
val result = runDiktat(testProjectDir, shouldSucceed = false)

val diktatCheckRootResult = result.task(":$DIKTAT_CHECK_TASK")
requireNotNull(diktatCheckRootResult)
Assertions.assertEquals(TaskOutcome.NO_SOURCE, diktatCheckRootResult.outcome) {
assertDiktatExecuted(result, TaskOutcome.NO_SOURCE) {
"Task for root project with empty sources should succeed"
}

val diktatCheckBackendResult = result.task(":backend:$DIKTAT_CHECK_TASK")
requireNotNull(diktatCheckBackendResult)
Assertions.assertEquals(TaskOutcome.FAILED, diktatCheckBackendResult.outcome)
Assertions.assertTrue(
result.output.contains("org.cqfn.diktat.example.gradle.multiproject")
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal fun createExampleProject(testProjectDir: TemporaryFolder,
plugins {
id("org.cqfn.diktat.diktat-gradle-plugin")
}
repositories {
mavenLocal()
mavenCentral()
Expand Down Expand Up @@ -75,11 +75,17 @@ private fun GradleRunner.withJaCoCo(number: Int) = apply {
}
}

fun assertDiktatExecuted(result: BuildResult) {
fun assertDiktatExecuted(
result: BuildResult,
taskOutcome: TaskOutcome = TaskOutcome.FAILED,
errorMessage: () -> String? = { null }
) {
val diktatCheckBuildResult = result.task(":${DiktatGradlePlugin.DIKTAT_CHECK_TASK}")
requireNotNull(diktatCheckBuildResult)
Assertions.assertEquals(TaskOutcome.FAILED, diktatCheckBuildResult.outcome)
Assertions.assertEquals(taskOutcome, diktatCheckBuildResult.outcome, errorMessage)
Assertions.assertTrue(
result.output.contains("[FILE_NAME_MATCH_CLASS]")
)
) {
"Task ${DiktatGradlePlugin.DIKTAT_CHECK_TASK} wasn't run"
}
}
4 changes: 2 additions & 2 deletions diktat-test-framework/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<groupId>io.github.microutils</groupId>
<artifactId>kotlin-logging-jvm</artifactId>
</dependency>
<dependency>
<groupId>io.github.petertrr</groupId>
Expand Down
9 changes: 2 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
<jacoco.version>0.8.8</jacoco.version>
<maven-plugin-tools.version>3.6.4</maven-plugin-tools.version>
<jbool.version>1.24</jbool.version>
<mu-logging.version>3.0.4</mu-logging.version>
<log4j.version>2.19.0</log4j.version>
<!-- downgraded to be compliance with ktlint -->
<mu-logging.version>2.1.23</mu-logging.version>
</properties>

<modules>
Expand Down Expand Up @@ -198,11 +198,6 @@
<artifactId>kotlin-logging-jvm</artifactId>
<version>${mu-logging.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>io.github.petertrr</groupId>
<artifactId>kotlin-multiplatform-diff-jvm</artifactId>
Expand Down
7 changes: 7 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@
],
"allowedVersions": "<= 1.6.8 || > 1.6.13"
},
{
"managers": ["maven"],
"matchPackageNames": [
"io.github.microutils:kotlin-logging-jvm"
],
"allowedVersions": "<= 2.1.23"
},
{
"managers": ["gradle"],
"matchPackagePatterns": [
Expand Down

0 comments on commit fb849b4

Please sign in to comment.