-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into bugfix/local-variable-loops(#581)
- Loading branch information
Showing
47 changed files
with
753 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
...c/functionalTest/kotlin/org/cqfn/diktat/plugin/gradle/DiktatGradlePluginFunctionalTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package org.cqfn.diktat.plugin.gradle | ||
|
||
import org.cqfn.diktat.plugin.gradle.DiktatGradlePlugin.Companion.DIKTAT_CHECK_TASK | ||
import org.gradle.internal.impldep.org.junit.rules.TemporaryFolder | ||
import org.gradle.testkit.runner.GradleRunner | ||
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 | ||
|
||
class DiktatGradlePluginFunctionalTest { | ||
private val testProjectDir = TemporaryFolder() | ||
private lateinit var buildFile: File | ||
|
||
@BeforeEach | ||
fun setUp() { | ||
testProjectDir.create() | ||
File("../examples/gradle-kotlin-dsl").copyRecursively(testProjectDir.root) | ||
File(testProjectDir.root, "build.gradle.kts").delete() | ||
buildFile = testProjectDir.newFile("build.gradle.kts").apply { | ||
writeText( | ||
""" | ||
plugins { | ||
id("org.cqfn.diktat.diktat-gradle-plugin") | ||
} | ||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
""".trimIndent() | ||
) | ||
} | ||
} | ||
|
||
@AfterEach | ||
fun tearDown() { | ||
testProjectDir.delete() | ||
} | ||
|
||
@Test | ||
fun `should execute diktatCheck on default values`() { | ||
val result = runDiktat() | ||
|
||
val diktatCheckBuildResult = result.task(":$DIKTAT_CHECK_TASK") | ||
requireNotNull(diktatCheckBuildResult) | ||
Assertions.assertEquals(TaskOutcome.FAILED, diktatCheckBuildResult.outcome) | ||
Assertions.assertTrue( | ||
result.output.contains("[HEADER_MISSING_OR_WRONG_COPYRIGHT]") | ||
) | ||
} | ||
|
||
@Test | ||
fun `should execute diktatCheck with explicit inputs`() { | ||
buildFile.appendText( | ||
"""${System.lineSeparator()} | ||
diktat { | ||
inputs = files("src/**/*.kt") | ||
} | ||
""".trimIndent() | ||
) | ||
val result = runDiktat() | ||
|
||
val diktatCheckBuildResult = result.task(":$DIKTAT_CHECK_TASK") | ||
requireNotNull(diktatCheckBuildResult) | ||
Assertions.assertEquals(TaskOutcome.FAILED, diktatCheckBuildResult.outcome) | ||
Assertions.assertTrue( | ||
result.output.contains("[HEADER_MISSING_OR_WRONG_COPYRIGHT]") | ||
) | ||
} | ||
|
||
private fun runDiktat() = GradleRunner.create() | ||
.withProjectDir(testProjectDir.root) | ||
.withArguments(DIKTAT_CHECK_TASK) | ||
.withPluginClasspath() | ||
.withJaCoCo() | ||
.forwardOutput() | ||
.runCatching { | ||
buildAndFail() | ||
} | ||
.also { | ||
require(it.isSuccess) { "Running gradle returned exception ${it.exceptionOrNull()}" } | ||
} | ||
.getOrNull()!! | ||
|
||
/** | ||
* This is support for jacoco reports in tests run with gradle TestKit | ||
*/ | ||
private fun GradleRunner.withJaCoCo() = apply { | ||
javaClass.classLoader | ||
.getResourceAsStream("testkit-gradle.properties") | ||
.also { it ?: println("properties file for testkit is not available, check build configuration") } | ||
?.use { propertiesFileStream -> | ||
File(projectDir, "gradle.properties").outputStream().use { | ||
propertiesFileStream.copyTo(it) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.