Reformat :kotlin-gradle-plugin-integration-tests
This commit is contained in:
+25
-12
@@ -1,6 +1,5 @@
|
|||||||
package org.jetbrains.kotlin.gradle
|
package org.jetbrains.kotlin.gradle
|
||||||
|
|
||||||
import org.gradle.util.VersionNumber
|
|
||||||
import org.jetbrains.kotlin.gradle.util.getFileByName
|
import org.jetbrains.kotlin.gradle.util.getFileByName
|
||||||
import org.jetbrains.kotlin.gradle.util.getFilesByNames
|
import org.jetbrains.kotlin.gradle.util.getFilesByNames
|
||||||
import org.jetbrains.kotlin.gradle.util.isLegacyAndroidGradleVersion
|
import org.jetbrains.kotlin.gradle.util.isLegacyAndroidGradleVersion
|
||||||
@@ -10,7 +9,9 @@ import org.junit.Test
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
|
|
||||||
class KotlinAndroidGradleIT : AbstractKotlinAndroidGradleTests(gradleVersion = GradleVersionRequired.AtLeast("3.4"), androidGradlePluginVersion = "2.3.0")
|
class KotlinAndroidGradleIT :
|
||||||
|
AbstractKotlinAndroidGradleTests(gradleVersion = GradleVersionRequired.AtLeast("3.4"), androidGradlePluginVersion = "2.3.0")
|
||||||
|
|
||||||
class KotlinAndroidWithJackGradleIT : AbstractKotlinAndroidWithJackGradleTests(androidGradlePluginVersion = "2.3.+")
|
class KotlinAndroidWithJackGradleIT : AbstractKotlinAndroidWithJackGradleTests(androidGradlePluginVersion = "2.3.+")
|
||||||
|
|
||||||
// TODO If we there is a way to fetch the latest Android plugin version, test against the latest version
|
// TODO If we there is a way to fetch the latest Android plugin version, test against the latest version
|
||||||
@@ -56,8 +57,10 @@ abstract class AbstractKotlinAndroidGradleTests(
|
|||||||
) : BaseGradleIT() {
|
) : BaseGradleIT() {
|
||||||
|
|
||||||
override fun defaultBuildOptions() =
|
override fun defaultBuildOptions() =
|
||||||
super.defaultBuildOptions().copy(androidHome = KotlinTestUtils.findAndroidSdk(),
|
super.defaultBuildOptions().copy(
|
||||||
androidGradlePluginVersion = androidGradlePluginVersion)
|
androidHome = KotlinTestUtils.findAndroidSdk(),
|
||||||
|
androidGradlePluginVersion = androidGradlePluginVersion
|
||||||
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testSimpleCompile() {
|
fun testSimpleCompile() {
|
||||||
@@ -132,11 +135,13 @@ abstract class AbstractKotlinAndroidGradleTests(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val getSomethingKt = project.projectDir.walk().filter { it.isFile && it.name.endsWith("getSomething.kt") }.first()
|
val getSomethingKt = project.projectDir.walk().filter { it.isFile && it.name.endsWith("getSomething.kt") }.first()
|
||||||
getSomethingKt.writeText("""
|
getSomethingKt.writeText(
|
||||||
|
"""
|
||||||
package foo
|
package foo
|
||||||
|
|
||||||
fun getSomething() = 10
|
fun getSomething() = 10
|
||||||
""")
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
project.build("assembleDebug", options = options) {
|
project.build("assembleDebug", options = options) {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
@@ -174,8 +179,12 @@ fun getSomething() = 10
|
|||||||
}
|
}
|
||||||
|
|
||||||
val androidModuleKt = project.projectDir.getFileByName("AndroidModule.kt")
|
val androidModuleKt = project.projectDir.getFileByName("AndroidModule.kt")
|
||||||
androidModuleKt.modify { it.replace("fun provideApplicationContext(): Context {",
|
androidModuleKt.modify {
|
||||||
"fun provideApplicationContext(): Context? {") }
|
it.replace(
|
||||||
|
"fun provideApplicationContext(): Context {",
|
||||||
|
"fun provideApplicationContext(): Context? {"
|
||||||
|
)
|
||||||
|
}
|
||||||
// rebuilt because DaggerApplicationComponent.java was regenerated
|
// rebuilt because DaggerApplicationComponent.java was regenerated
|
||||||
val baseApplicationKt = project.projectDir.getFileByName("BaseApplication.kt")
|
val baseApplicationKt = project.projectDir.getFileByName("BaseApplication.kt")
|
||||||
// rebuilt because BuildConfig.java was regenerated (timestamp was changed)
|
// rebuilt because BuildConfig.java was regenerated (timestamp was changed)
|
||||||
@@ -183,11 +192,13 @@ fun getSomething() = 10
|
|||||||
|
|
||||||
project.build(":app:assembleDebug", options = options) {
|
project.build(":app:assembleDebug", options = options) {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertCompiledKotlinSources(project.relativize(
|
assertCompiledKotlinSources(
|
||||||
|
project.relativize(
|
||||||
androidModuleKt,
|
androidModuleKt,
|
||||||
baseApplicationKt,
|
baseApplicationKt,
|
||||||
useBuildConfigJavaKt
|
useBuildConfigJavaKt
|
||||||
))
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,8 +321,10 @@ abstract class AbstractKotlinAndroidWithJackGradleTests(
|
|||||||
fun getEnvJDK_18() = System.getenv()["JDK_18"]
|
fun getEnvJDK_18() = System.getenv()["JDK_18"]
|
||||||
|
|
||||||
override fun defaultBuildOptions() =
|
override fun defaultBuildOptions() =
|
||||||
super.defaultBuildOptions().copy(androidHome = KotlinTestUtils.findAndroidSdk(),
|
super.defaultBuildOptions().copy(
|
||||||
androidGradlePluginVersion = androidGradlePluginVersion, javaHome = File(getEnvJDK_18()))
|
androidHome = KotlinTestUtils.findAndroidSdk(),
|
||||||
|
androidGradlePluginVersion = androidGradlePluginVersion, javaHome = File(getEnvJDK_18())
|
||||||
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testSimpleCompile() {
|
fun testSimpleCompile() {
|
||||||
|
|||||||
+23
-11
@@ -223,12 +223,18 @@ abstract class BaseGradleIT {
|
|||||||
|
|
||||||
private fun getCompiledFiles(regex: Regex, output: String) = regex.findAll(output)
|
private fun getCompiledFiles(regex: Regex, output: String) = regex.findAll(output)
|
||||||
.asIterable()
|
.asIterable()
|
||||||
.flatMap { it.groups[1]!!.value.split(", ")
|
.flatMap {
|
||||||
.map { File(project.projectDir, it).canonicalFile } }
|
it.groups[1]!!.value.split(", ")
|
||||||
|
.map { File(project.projectDir, it).canonicalFile }
|
||||||
|
}
|
||||||
|
|
||||||
fun getCompiledKotlinSources(output: String) = getCompiledFiles(kotlinSourcesListRegex, output)
|
fun getCompiledKotlinSources(output: String) = getCompiledFiles(kotlinSourcesListRegex, output)
|
||||||
|
|
||||||
val compiledJavaSources: Iterable<File> by lazy { javaSourcesListRegex.findAll(output).asIterable().flatMap { it.groups[1]!!.value.split(" ").filter { it.endsWith(".java", ignoreCase = true) }.map { File(it).canonicalFile } } }
|
val compiledJavaSources: Iterable<File> by lazy {
|
||||||
|
javaSourcesListRegex.findAll(output).asIterable().flatMap {
|
||||||
|
it.groups[1]!!.value.split(" ").filter { it.endsWith(".java", ignoreCase = true) }.map { File(it).canonicalFile }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Basically the same as `Project.build`, tells gradle to wait for debug on 5005 port
|
// Basically the same as `Project.build`, tells gradle to wait for debug on 5005 port
|
||||||
@@ -254,8 +260,7 @@ abstract class BaseGradleIT {
|
|||||||
val result = runProcess(cmd, projectDir, env, options)
|
val result = runProcess(cmd, projectDir, env, options)
|
||||||
try {
|
try {
|
||||||
CompiledProject(this, result.output, result.exitCode).check()
|
CompiledProject(this, result.output, result.exitCode).check()
|
||||||
}
|
} catch (t: Throwable) {
|
||||||
catch (t: Throwable) {
|
|
||||||
// to prevent duplication of output
|
// to prevent duplication of output
|
||||||
if (!options.forceOutputToStdout) {
|
if (!options.forceOutputToStdout) {
|
||||||
System.out.println(result.output)
|
System.out.println(result.output)
|
||||||
@@ -370,10 +375,17 @@ abstract class BaseGradleIT {
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun CompiledProject.assertContainFiles(expected: Iterable<String>, actual: Iterable<String>, messagePrefix: String = ""): CompiledProject {
|
fun CompiledProject.assertContainFiles(
|
||||||
|
expected: Iterable<String>,
|
||||||
|
actual: Iterable<String>,
|
||||||
|
messagePrefix: String = ""
|
||||||
|
): CompiledProject {
|
||||||
val expectedNormalized = expected.map(::normalizePath).toSortedSet()
|
val expectedNormalized = expected.map(::normalizePath).toSortedSet()
|
||||||
val actualNormalized = actual.map(::normalizePath).toSortedSet()
|
val actualNormalized = actual.map(::normalizePath).toSortedSet()
|
||||||
assertTrue(actualNormalized.containsAll(expectedNormalized), messagePrefix + "expected files: ${expectedNormalized.joinToString()}\n !in actual files: ${actualNormalized.joinToString()}")
|
assertTrue(
|
||||||
|
actualNormalized.containsAll(expectedNormalized),
|
||||||
|
messagePrefix + "expected files: ${expectedNormalized.joinToString()}\n !in actual files: ${actualNormalized.joinToString()}"
|
||||||
|
)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -412,7 +424,8 @@ abstract class BaseGradleIT {
|
|||||||
fun CompiledProject.assertCompiledKotlinSources(
|
fun CompiledProject.assertCompiledKotlinSources(
|
||||||
sources: Iterable<String>,
|
sources: Iterable<String>,
|
||||||
weakTesting: Boolean = false,
|
weakTesting: Boolean = false,
|
||||||
tasks: List<String>) {
|
tasks: List<String>
|
||||||
|
) {
|
||||||
for (task in tasks) {
|
for (task in tasks) {
|
||||||
assertCompiledKotlinSources(sources, weakTesting, getOutputForTask(task), suffix = " in task ${task}")
|
assertCompiledKotlinSources(sources, weakTesting, getOutputForTask(task), suffix = " in task ${task}")
|
||||||
}
|
}
|
||||||
@@ -428,8 +441,7 @@ abstract class BaseGradleIT {
|
|||||||
val actualSources = getCompiledKotlinSources(output).projectRelativePaths(this.project)
|
val actualSources = getCompiledKotlinSources(output).projectRelativePaths(this.project)
|
||||||
return if (weakTesting) {
|
return if (weakTesting) {
|
||||||
assertContainFiles(expectedSources, actualSources, messagePrefix)
|
assertContainFiles(expectedSources, actualSources, messagePrefix)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
assertSameFiles(expectedSources, actualSources, messagePrefix)
|
assertSameFiles(expectedSources, actualSources, messagePrefix)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -496,7 +508,7 @@ abstract class BaseGradleIT {
|
|||||||
add("-Pkotlin_version=" + options.kotlinVersion)
|
add("-Pkotlin_version=" + options.kotlinVersion)
|
||||||
options.incremental?.let { add("-Pkotlin.incremental=$it") }
|
options.incremental?.let { add("-Pkotlin.incremental=$it") }
|
||||||
options.usePreciseJavaTracking?.let { add("-Pkotlin.incremental.usePreciseJavaTracking=$it") }
|
options.usePreciseJavaTracking?.let { add("-Pkotlin.incremental.usePreciseJavaTracking=$it") }
|
||||||
options.androidGradlePluginVersion?.let { add("-Pandroid_tools_version=$it")}
|
options.androidGradlePluginVersion?.let { add("-Pandroid_tools_version=$it") }
|
||||||
if (options.debug) {
|
if (options.debug) {
|
||||||
add("-Dorg.gradle.debug=true")
|
add("-Dorg.gradle.debug=true")
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -7,7 +7,8 @@ import org.junit.runners.Parameterized.Parameters
|
|||||||
|
|
||||||
@RunWith(Parameterized::class)
|
@RunWith(Parameterized::class)
|
||||||
abstract class BaseMultiGradleVersionIT : BaseGradleIT() {
|
abstract class BaseMultiGradleVersionIT : BaseGradleIT() {
|
||||||
@Parameter lateinit var gradleVersionString: String
|
@Parameter
|
||||||
|
lateinit var gradleVersionString: String
|
||||||
|
|
||||||
protected val gradleVersion get() = GradleVersionRequired.Exact(gradleVersionString)
|
protected val gradleVersion get() = GradleVersionRequired.Exact(gradleVersionString)
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -145,11 +145,13 @@ class BuildCacheIT : BaseGradleIT() {
|
|||||||
assertContains("Caching disabled for task ':kaptKotlin': 'Caching is disabled by default for kapt")
|
assertContains("Caching disabled for task ':kaptKotlin': 'Caching is disabled by default for kapt")
|
||||||
}
|
}
|
||||||
|
|
||||||
File(projectDir, "build.gradle").appendText("\n" + """
|
File(projectDir, "build.gradle").appendText(
|
||||||
|
"\n" + """
|
||||||
afterEvaluate {
|
afterEvaluate {
|
||||||
kaptKotlin.useBuildCache = true
|
kaptKotlin.useBuildCache = true
|
||||||
}
|
}
|
||||||
""".trimIndent())
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
|
||||||
build("clean", "build") {
|
build("clean", "build") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
|
|||||||
+11
-7
@@ -31,7 +31,8 @@ class BuildCacheRelocationIT : BaseGradleIT() {
|
|||||||
super.defaultBuildOptions().copy(
|
super.defaultBuildOptions().copy(
|
||||||
withBuildCache = true,
|
withBuildCache = true,
|
||||||
androidGradlePluginVersion = "3.0.0",
|
androidGradlePluginVersion = "3.0.0",
|
||||||
androidHome = KotlinTestUtils.findAndroidSdk())
|
androidHome = KotlinTestUtils.findAndroidSdk()
|
||||||
|
)
|
||||||
|
|
||||||
@Parameterized.Parameter
|
@Parameterized.Parameter
|
||||||
lateinit var testCase: TestCase
|
lateinit var testCase: TestCase
|
||||||
@@ -70,8 +71,7 @@ class BuildCacheRelocationIT : BaseGradleIT() {
|
|||||||
assertEquals(firstOutputHashes, secondOutputHashes)
|
assertEquals(firstOutputHashes, secondOutputHashes)
|
||||||
cacheableTaskNames.forEach { assertContains(":$it FROM-CACHE") }
|
cacheableTaskNames.forEach { assertContains(":$it FROM-CACHE") }
|
||||||
}
|
}
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
workingDir = originalWorkingDir
|
workingDir = originalWorkingDir
|
||||||
workingDirs.forEach { it.deleteRecursively() }
|
workingDirs.forEach { it.deleteRecursively() }
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,8 @@ class BuildCacheRelocationIT : BaseGradleIT() {
|
|||||||
val cacheableTaskNames: List<String>,
|
val cacheableTaskNames: List<String>,
|
||||||
val projectDirectoryPrefix: String? = null,
|
val projectDirectoryPrefix: String? = null,
|
||||||
val outputRootPaths: List<String> = listOf("build"),
|
val outputRootPaths: List<String> = listOf("build"),
|
||||||
val initProject: Project.() -> Unit = { }) {
|
val initProject: Project.() -> Unit = { }
|
||||||
|
) {
|
||||||
|
|
||||||
override fun toString(): String = (projectDirectoryPrefix?.plus("/") ?: "") + projectName
|
override fun toString(): String = (projectDirectoryPrefix?.plus("/") ?: "") + projectName
|
||||||
|
|
||||||
@@ -96,12 +97,14 @@ class BuildCacheRelocationIT : BaseGradleIT() {
|
|||||||
@JvmStatic
|
@JvmStatic
|
||||||
@Parameterized.Parameters(name = "project: {0}")
|
@Parameterized.Parameters(name = "project: {0}")
|
||||||
fun testCases(): List<Array<TestCase>> = listOf(
|
fun testCases(): List<Array<TestCase>> = listOf(
|
||||||
TestCase("simpleProject",
|
TestCase(
|
||||||
|
"simpleProject",
|
||||||
cacheableTaskNames = listOf("compileKotlin", "compileTestKotlin")
|
cacheableTaskNames = listOf("compileKotlin", "compileTestKotlin")
|
||||||
),
|
),
|
||||||
TestCase("simple", projectDirectoryPrefix = "kapt2",
|
TestCase("simple", projectDirectoryPrefix = "kapt2",
|
||||||
cacheableTaskNames = listOf(
|
cacheableTaskNames = listOf(
|
||||||
"kaptKotlin", "kaptGenerateStubsKotlin", "compileKotlin", "compileTestKotlin", "compileJava"),
|
"kaptKotlin", "kaptGenerateStubsKotlin", "compileKotlin", "compileTestKotlin", "compileJava"
|
||||||
|
),
|
||||||
initProject = { File(projectDir, "build.gradle").appendText("\nkapt.useBuildCache = true") }
|
initProject = { File(projectDir, "build.gradle").appendText("\nkapt.useBuildCache = true") }
|
||||||
),
|
),
|
||||||
TestCase("kotlin2JsDceProject",
|
TestCase("kotlin2JsDceProject",
|
||||||
@@ -120,7 +123,8 @@ class BuildCacheRelocationIT : BaseGradleIT() {
|
|||||||
TestCase("multiplatformProject",
|
TestCase("multiplatformProject",
|
||||||
cacheableTaskNames = listOf(
|
cacheableTaskNames = listOf(
|
||||||
"lib:compileKotlinCommon", "libJvm:compileKotlin", "libJvm:compileTestKotlin",
|
"lib:compileKotlinCommon", "libJvm:compileKotlin", "libJvm:compileTestKotlin",
|
||||||
"libJs:compileKotlin2Js", "libJs:compileTestKotlin2Js"),
|
"libJs:compileKotlin2Js", "libJs:compileTestKotlin2Js"
|
||||||
|
),
|
||||||
outputRootPaths = listOf("lib", "libJvm", "libJs").map { "$it/build" }
|
outputRootPaths = listOf("lib", "libJvm", "libJs").map { "$it/build" }
|
||||||
),
|
),
|
||||||
TestCase("AndroidProject",
|
TestCase("AndroidProject",
|
||||||
|
|||||||
+1
-1
@@ -41,7 +41,7 @@ class ClassFileIsRemovedIT : BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun doTest(buildOptions: BuildOptions, transformDummy: (File)->Unit) {
|
fun doTest(buildOptions: BuildOptions, transformDummy: (File) -> Unit) {
|
||||||
val project = Project("kotlinInJavaRoot")
|
val project = Project("kotlinInJavaRoot")
|
||||||
project.build("build", options = buildOptions) {
|
project.build("build", options = buildOptions) {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.gradle.util.modify
|
|||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class CoroutinesIT: BaseGradleIT() {
|
class CoroutinesIT : BaseGradleIT() {
|
||||||
companion object {
|
companion object {
|
||||||
private const val LOCAL_PROPERTIES = "local.properties"
|
private const val LOCAL_PROPERTIES = "local.properties"
|
||||||
private const val GRADLE_PROPERTIES = "gradle.properties"
|
private const val GRADLE_PROPERTIES = "gradle.properties"
|
||||||
|
|||||||
+4
-2
@@ -9,8 +9,10 @@ class ExecutionStrategyJsIT : ExecutionStrategyIT() {
|
|||||||
override fun setupProject(project: Project) {
|
override fun setupProject(project: Project) {
|
||||||
super.setupProject(project)
|
super.setupProject(project)
|
||||||
val buildGradle = File(project.projectDir, "app/build.gradle")
|
val buildGradle = File(project.projectDir, "app/build.gradle")
|
||||||
buildGradle.modify { it.replace("apply plugin: \"kotlin\"", "apply plugin: \"kotlin2js\"") +
|
buildGradle.modify {
|
||||||
"\ncompileKotlin2Js.kotlinOptions.outputFile = \"web/js/out.js\"" }
|
it.replace("apply plugin: \"kotlin\"", "apply plugin: \"kotlin2js\"") +
|
||||||
|
"\ncompileKotlin2Js.kotlinOptions.outputFile = \"web/js/out.js\""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun CompiledProject.checkOutput() {
|
override fun CompiledProject.checkOutput() {
|
||||||
|
|||||||
+21
-12
@@ -14,10 +14,12 @@ class IncrementalCompilationMultiProjectIT : BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun androidBuildOptions() =
|
private fun androidBuildOptions() =
|
||||||
BuildOptions(withDaemon = true,
|
BuildOptions(
|
||||||
|
withDaemon = true,
|
||||||
androidHome = KotlinTestUtils.findAndroidSdk(),
|
androidHome = KotlinTestUtils.findAndroidSdk(),
|
||||||
androidGradlePluginVersion = ANDROID_GRADLE_PLUGIN_VERSION,
|
androidGradlePluginVersion = ANDROID_GRADLE_PLUGIN_VERSION,
|
||||||
incremental = true)
|
incremental = true
|
||||||
|
)
|
||||||
|
|
||||||
override fun defaultBuildOptions(): BuildOptions =
|
override fun defaultBuildOptions(): BuildOptions =
|
||||||
super.defaultBuildOptions().copy(withDaemon = true, incremental = true)
|
super.defaultBuildOptions().copy(withDaemon = true, incremental = true)
|
||||||
@@ -66,14 +68,16 @@ class IncrementalCompilationMultiProjectIT : BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val aKt = project.projectDir.getFileByName("A.kt")
|
val aKt = project.projectDir.getFileByName("A.kt")
|
||||||
aKt.writeText("""
|
aKt.writeText(
|
||||||
|
"""
|
||||||
package bar
|
package bar
|
||||||
|
|
||||||
open class A {
|
open class A {
|
||||||
fun a() {}
|
fun a() {}
|
||||||
fun newA() {}
|
fun newA() {}
|
||||||
}
|
}
|
||||||
""")
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
project.build("build") {
|
project.build("build") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
@@ -97,7 +101,8 @@ open class A {
|
|||||||
assertFailed()
|
assertFailed()
|
||||||
val affectedSources = project.projectDir.getFilesByNames(
|
val affectedSources = project.projectDir.getFilesByNames(
|
||||||
"B.kt", "barUseAB.kt", "barUseB.kt",
|
"B.kt", "barUseAB.kt", "barUseB.kt",
|
||||||
"BB.kt", "fooCallUseAB.kt", "fooUseB.kt")
|
"BB.kt", "fooCallUseAB.kt", "fooUseB.kt"
|
||||||
|
)
|
||||||
val relativePaths = project.relativize(affectedSources)
|
val relativePaths = project.relativize(affectedSources)
|
||||||
assertCompiledKotlinSources(relativePaths, weakTesting = false)
|
assertCompiledKotlinSources(relativePaths, weakTesting = false)
|
||||||
}
|
}
|
||||||
@@ -176,11 +181,13 @@ open class A {
|
|||||||
|
|
||||||
val libGroovySrcBar = File(lib, "src/main/groovy/bar").apply { mkdirs() }
|
val libGroovySrcBar = File(lib, "src/main/groovy/bar").apply { mkdirs() }
|
||||||
val groovyClass = File(libGroovySrcBar, "GroovyClass.groovy")
|
val groovyClass = File(libGroovySrcBar, "GroovyClass.groovy")
|
||||||
groovyClass.writeText("""
|
groovyClass.writeText(
|
||||||
|
"""
|
||||||
package bar
|
package bar
|
||||||
|
|
||||||
class GroovyClass {}
|
class GroovyClass {}
|
||||||
""")
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
project.build("build") {
|
project.build("build") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
@@ -273,19 +280,21 @@ abstract class IncrementalCompilationJavaChangesBase(val usePreciseJavaTracking:
|
|||||||
|
|
||||||
protected val trackedJavaClass = "TrackedJavaClass.java"
|
protected val trackedJavaClass = "TrackedJavaClass.java"
|
||||||
private val javaClass = "JavaClass.java"
|
private val javaClass = "JavaClass.java"
|
||||||
protected val changeBody: (String)->String = { it.replace("Hello, World!", "Hello, World!!!!") }
|
protected val changeBody: (String) -> String = { it.replace("Hello, World!", "Hello, World!!!!") }
|
||||||
protected val changeSignature: (String)->String = { it.replace("String getString", "Object getString") }
|
protected val changeSignature: (String) -> String = { it.replace("String getString", "Object getString") }
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testModifySignatureJavaInLib() {
|
fun testModifySignatureJavaInLib() {
|
||||||
doTest(javaClass, changeBody,
|
doTest(
|
||||||
|
javaClass, changeBody,
|
||||||
expectedAffectedSources = listOf("JavaClassChild.kt", "useJavaClass.kt", "useJavaClassFooMethodUsage.kt")
|
expectedAffectedSources = listOf("JavaClassChild.kt", "useJavaClass.kt", "useJavaClassFooMethodUsage.kt")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testModifyBodyJavaInLib() {
|
fun testModifyBodyJavaInLib() {
|
||||||
doTest(javaClass, changeBody,
|
doTest(
|
||||||
|
javaClass, changeBody,
|
||||||
expectedAffectedSources = listOf("JavaClassChild.kt", "useJavaClass.kt", "useJavaClassFooMethodUsage.kt")
|
expectedAffectedSources = listOf("JavaClassChild.kt", "useJavaClass.kt", "useJavaClassFooMethodUsage.kt")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -295,7 +304,7 @@ abstract class IncrementalCompilationJavaChangesBase(val usePreciseJavaTracking:
|
|||||||
|
|
||||||
protected fun doTest(
|
protected fun doTest(
|
||||||
fileToModify: String,
|
fileToModify: String,
|
||||||
transformFile: (String)->String,
|
transformFile: (String) -> String,
|
||||||
expectedAffectedSources: Collection<String>
|
expectedAffectedSources: Collection<String>
|
||||||
) {
|
) {
|
||||||
val project = Project("incrementalMultiproject")
|
val project = Project("incrementalMultiproject")
|
||||||
|
|||||||
+4
-2
@@ -19,10 +19,12 @@ open class Kapt3AndroidIT : Kapt3BaseIT() {
|
|||||||
get() = "2.3.0"
|
get() = "2.3.0"
|
||||||
|
|
||||||
private fun androidBuildOptions() =
|
private fun androidBuildOptions() =
|
||||||
BuildOptions(withDaemon = true,
|
BuildOptions(
|
||||||
|
withDaemon = true,
|
||||||
androidHome = KotlinTestUtils.findAndroidSdk(),
|
androidHome = KotlinTestUtils.findAndroidSdk(),
|
||||||
androidGradlePluginVersion = androidGradlePluginVersion,
|
androidGradlePluginVersion = androidGradlePluginVersion,
|
||||||
freeCommandLineArgs = listOf("-Pkapt.verbose=true"))
|
freeCommandLineArgs = listOf("-Pkapt.verbose=true")
|
||||||
|
)
|
||||||
|
|
||||||
override fun defaultBuildOptions() = androidBuildOptions()
|
override fun defaultBuildOptions() = androidBuildOptions()
|
||||||
|
|
||||||
|
|||||||
+10
-6
@@ -129,9 +129,11 @@ open class Kapt3IT : Kapt3BaseIT() {
|
|||||||
Project("arguments", directoryPrefix = "kapt2").build("build") {
|
Project("arguments", directoryPrefix = "kapt2").build("build") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertKaptSuccessful()
|
assertKaptSuccessful()
|
||||||
assertContains("Options: {suffix=Customized, justColon=:, justEquals==, containsColon=a:b, " +
|
assertContains(
|
||||||
|
"Options: {suffix=Customized, justColon=:, justEquals==, containsColon=a:b, " +
|
||||||
"containsEquals=a=b, startsWithColon=:a, startsWithEquals==a, endsWithColon=a:, " +
|
"containsEquals=a=b, startsWithColon=:a, startsWithEquals==a, endsWithColon=a:, " +
|
||||||
"endsWithEquals=a:, withSpace=a b c,")
|
"endsWithEquals=a:, withSpace=a b c,"
|
||||||
|
)
|
||||||
assertContains("-Xmaxerrs=500, -Xlint:all=-Xlint:all") // Javac options test
|
assertContains("-Xmaxerrs=500, -Xlint:all=-Xlint:all") // Javac options test
|
||||||
assertFileExists("build/generated/source/kapt/main/example/TestClassCustomized.java")
|
assertFileExists("build/generated/source/kapt/main/example/TestClassCustomized.java")
|
||||||
assertFileExists(kotlinClassesDir() + "example/TestClass.class")
|
assertFileExists(kotlinClassesDir() + "example/TestClass.class")
|
||||||
@@ -252,7 +254,7 @@ open class Kapt3IT : Kapt3BaseIT() {
|
|||||||
|
|
||||||
// add annotation
|
// add annotation
|
||||||
val exampleAnn = "@example.ExampleAnnotation "
|
val exampleAnn = "@example.ExampleAnnotation "
|
||||||
internalDummyKt.modify { it.addBeforeSubstring(exampleAnn, "internal class InternalDummy")}
|
internalDummyKt.modify { it.addBeforeSubstring(exampleAnn, "internal class InternalDummy") }
|
||||||
|
|
||||||
project.build("classes", options = options) {
|
project.build("classes", options = options) {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
@@ -260,7 +262,7 @@ open class Kapt3IT : Kapt3BaseIT() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// remove annotation
|
// remove annotation
|
||||||
internalDummyKt.modify { it.replace(exampleAnn, "")}
|
internalDummyKt.modify { it.replace(exampleAnn, "") }
|
||||||
|
|
||||||
project.build("classes", options = options) {
|
project.build("classes", options = options) {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
@@ -391,8 +393,10 @@ open class Kapt3IT : Kapt3BaseIT() {
|
|||||||
|
|
||||||
project.build("build") {
|
project.build("build") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertNotContains(":example:kaptKotlin UP-TO-DATE",
|
assertNotContains(
|
||||||
":example:kaptGenerateStubsKotlin UP-TO-DATE")
|
":example:kaptKotlin UP-TO-DATE",
|
||||||
|
":example:kaptGenerateStubsKotlin UP-TO-DATE"
|
||||||
|
)
|
||||||
|
|
||||||
assertContains("Additional warning message from AP")
|
assertContains("Additional warning message from AP")
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ import org.jetbrains.kotlin.gradle.util.modify
|
|||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class KaptIT: BaseGradleIT() {
|
class KaptIT : BaseGradleIT() {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testSimple() {
|
fun testSimple() {
|
||||||
|
|||||||
+25
-18
@@ -11,7 +11,7 @@ class KaptIncrementalWithStubsIT : KaptIncrementalBaseIT(shouldUseStubs = true)
|
|||||||
|
|
||||||
class Kapt3Incremental : KaptIncrementalBaseIT(shouldUseStubs = false, useKapt3 = true)
|
class Kapt3Incremental : KaptIncrementalBaseIT(shouldUseStubs = false, useKapt3 = true)
|
||||||
|
|
||||||
abstract class KaptIncrementalBaseIT(val shouldUseStubs: Boolean, val useKapt3: Boolean = false): BaseGradleIT() {
|
abstract class KaptIncrementalBaseIT(val shouldUseStubs: Boolean, val useKapt3: Boolean = false) : BaseGradleIT() {
|
||||||
init {
|
init {
|
||||||
if (useKapt3) {
|
if (useKapt3) {
|
||||||
assert(!shouldUseStubs)
|
assert(!shouldUseStubs)
|
||||||
@@ -65,12 +65,16 @@ abstract class KaptIncrementalBaseIT(val shouldUseStubs: Boolean, val useKapt3:
|
|||||||
|
|
||||||
project.build("build") {
|
project.build("build") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertContains(":compileKotlin UP-TO-DATE",
|
assertContains(
|
||||||
":compileJava UP-TO-DATE")
|
":compileKotlin UP-TO-DATE",
|
||||||
|
":compileJava UP-TO-DATE"
|
||||||
|
)
|
||||||
|
|
||||||
if (useKapt3) {
|
if (useKapt3) {
|
||||||
assertContains(":kaptKotlin UP-TO-DATE",
|
assertContains(
|
||||||
":kaptGenerateStubsKotlin UP-TO-DATE")
|
":kaptKotlin UP-TO-DATE",
|
||||||
|
":kaptGenerateStubsKotlin UP-TO-DATE"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldUseStubs) {
|
if (shouldUseStubs) {
|
||||||
@@ -171,7 +175,7 @@ abstract class KaptIncrementalBaseIT(val shouldUseStubs: Boolean, val useKapt3:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
with (project.projectDir) {
|
with(project.projectDir) {
|
||||||
getFileByName("B.kt").delete()
|
getFileByName("B.kt").delete()
|
||||||
getFileByName("useB.kt").delete()
|
getFileByName("useB.kt").delete()
|
||||||
}
|
}
|
||||||
@@ -222,14 +226,14 @@ abstract class KaptIncrementalBaseIT(val shouldUseStubs: Boolean, val useKapt3:
|
|||||||
assertCompiledKotlinSources(project.relativize(bKt, useBKt), tasks = listOf("kaptGenerateStubsKotlin"))
|
assertCompiledKotlinSources(project.relativize(bKt, useBKt), tasks = listOf("kaptGenerateStubsKotlin"))
|
||||||
|
|
||||||
// java removal is detected
|
// java removal is detected
|
||||||
assertCompiledKotlinSources(project.relativize(project.projectDir.allKotlinFiles()),
|
assertCompiledKotlinSources(
|
||||||
tasks = listOf("compileKotlin"))
|
project.relativize(project.projectDir.allKotlinFiles()),
|
||||||
}
|
tasks = listOf("compileKotlin")
|
||||||
else if (shouldUseStubs) {
|
)
|
||||||
|
} else if (shouldUseStubs) {
|
||||||
// java removal is detected
|
// java removal is detected
|
||||||
assertCompiledKotlinSources(project.relativize(project.projectDir.allKotlinFiles()))
|
assertCompiledKotlinSources(project.relativize(project.projectDir.allKotlinFiles()))
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
val useBKt = project.projectDir.getFileByName("useB.kt")
|
val useBKt = project.projectDir.getFileByName("useB.kt")
|
||||||
assertCompiledKotlinSources(project.relativize(bKt, useBKt))
|
assertCompiledKotlinSources(project.relativize(bKt, useBKt))
|
||||||
}
|
}
|
||||||
@@ -262,8 +266,10 @@ abstract class KaptIncrementalBaseIT(val shouldUseStubs: Boolean, val useKapt3:
|
|||||||
weakTesting: Boolean = false
|
weakTesting: Boolean = false
|
||||||
) {
|
) {
|
||||||
if (useKapt3) {
|
if (useKapt3) {
|
||||||
assertCompiledKotlinSources(sources, weakTesting,
|
assertCompiledKotlinSources(
|
||||||
tasks = listOf("compileKotlin", "kaptGenerateStubsKotlin"))
|
sources, weakTesting,
|
||||||
|
tasks = listOf("compileKotlin", "kaptGenerateStubsKotlin")
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
assertCompiledKotlinSources(sources, weakTesting)
|
assertCompiledKotlinSources(sources, weakTesting)
|
||||||
}
|
}
|
||||||
@@ -271,8 +277,10 @@ abstract class KaptIncrementalBaseIT(val shouldUseStubs: Boolean, val useKapt3:
|
|||||||
|
|
||||||
private fun CompiledProject.assertKapt3FullyExecuted() {
|
private fun CompiledProject.assertKapt3FullyExecuted() {
|
||||||
if (useKapt3) {
|
if (useKapt3) {
|
||||||
assertNotContains(":kaptKotlin UP-TO-DATE",
|
assertNotContains(
|
||||||
":kaptGenerateStubsKotlin UP-TO-DATE")
|
":kaptKotlin UP-TO-DATE",
|
||||||
|
":kaptGenerateStubsKotlin UP-TO-DATE"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,8 +308,7 @@ abstract class KaptIncrementalBaseIT(val shouldUseStubs: Boolean, val useKapt3:
|
|||||||
|
|
||||||
if (shouldUseStubs) {
|
if (shouldUseStubs) {
|
||||||
assertContains(usingStubs)
|
assertContains(usingStubs)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
assertNotContains(usingStubs)
|
assertNotContains(usingStubs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-7
@@ -25,7 +25,8 @@ class Kotlin2JsGradlePluginIT : BaseGradleIT() {
|
|||||||
":libraryProject:compileKotlin2Js"
|
":libraryProject:compileKotlin2Js"
|
||||||
)
|
)
|
||||||
|
|
||||||
listOf("mainProject/web/js/app.js",
|
listOf(
|
||||||
|
"mainProject/web/js/app.js",
|
||||||
"mainProject/web/js/lib/kotlin.js",
|
"mainProject/web/js/lib/kotlin.js",
|
||||||
"libraryProject/build/kotlin2js/main/test-library.js",
|
"libraryProject/build/kotlin2js/main/test-library.js",
|
||||||
"mainProject/web/js/app.js.map"
|
"mainProject/web/js/app.js.map"
|
||||||
@@ -67,8 +68,10 @@ class Kotlin2JsGradlePluginIT : BaseGradleIT() {
|
|||||||
val jarPath = "build/libs/kotlin2JsNoOutputFileProject.jar"
|
val jarPath = "build/libs/kotlin2JsNoOutputFileProject.jar"
|
||||||
assertFileExists(jarPath)
|
assertFileExists(jarPath)
|
||||||
val jar = ZipFile(fileInWorkingDir(jarPath))
|
val jar = ZipFile(fileInWorkingDir(jarPath))
|
||||||
assertEquals(1, jar.entries().asSequence().count { it.name == "kotlin2JsNoOutputFileProject.js" },
|
assertEquals(
|
||||||
"The jar should contain an entry `kotlin2JsNoOutputFileProject.js` with no duplicates")
|
1, jar.entries().asSequence().count { it.name == "kotlin2JsNoOutputFileProject.js" },
|
||||||
|
"The jar should contain an entry `kotlin2JsNoOutputFileProject.js` with no duplicates"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,8 +86,10 @@ class Kotlin2JsGradlePluginIT : BaseGradleIT() {
|
|||||||
val jarPath = "build/libs/kotlin2JsModuleKind.jar"
|
val jarPath = "build/libs/kotlin2JsModuleKind.jar"
|
||||||
assertFileExists(jarPath)
|
assertFileExists(jarPath)
|
||||||
val jar = ZipFile(fileInWorkingDir(jarPath))
|
val jar = ZipFile(fileInWorkingDir(jarPath))
|
||||||
assertEquals(1, jar.entries().asSequence().count { it.name == "app.js" },
|
assertEquals(
|
||||||
"The jar should contain an entry `app.js` with no duplicates")
|
1, jar.entries().asSequence().count { it.name == "app.js" },
|
||||||
|
"The jar should contain an entry `app.js` with no duplicates"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,8 +157,10 @@ class Kotlin2JsGradlePluginIT : BaseGradleIT() {
|
|||||||
val jarPath = "build/libs/kotlin2JsProjectWithCustomSourceset-inttests.jar"
|
val jarPath = "build/libs/kotlin2JsProjectWithCustomSourceset-inttests.jar"
|
||||||
assertFileExists(jarPath)
|
assertFileExists(jarPath)
|
||||||
val jar = ZipFile(fileInWorkingDir(jarPath))
|
val jar = ZipFile(fileInWorkingDir(jarPath))
|
||||||
assertEquals(1, jar.entries().asSequence().count { it.name == "module-inttests.js" },
|
assertEquals(
|
||||||
"The jar should contain an entry `module-inttests.js` with no duplicates")
|
1, jar.entries().asSequence().count { it.name == "module-inttests.js" },
|
||||||
|
"The jar should contain an entry `module-inttests.js` with no duplicates"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -45,7 +45,11 @@ class KotlinDaemonIT : BaseGradleIT() {
|
|||||||
assert(createdSessions.size == 1) { "Created multiple sessions per build ${createdSessions.joinToString()}" }
|
assert(createdSessions.size == 1) { "Created multiple sessions per build ${createdSessions.joinToString()}" }
|
||||||
|
|
||||||
val existingSessions = output.findAllStringsPrefixed(EXISTING_SESSION_FILE_PREFIX)
|
val existingSessions = output.findAllStringsPrefixed(EXISTING_SESSION_FILE_PREFIX)
|
||||||
Assert.assertArrayEquals("Existing sessions don't match created sessions for two module projects", createdSessions, existingSessions)
|
Assert.assertArrayEquals(
|
||||||
|
"Existing sessions don't match created sessions for two module projects",
|
||||||
|
createdSessions,
|
||||||
|
existingSessions
|
||||||
|
)
|
||||||
|
|
||||||
val deletedSessions = output.findAllStringsPrefixed(DELETED_SESSION_FILE_PREFIX)
|
val deletedSessions = output.findAllStringsPrefixed(DELETED_SESSION_FILE_PREFIX)
|
||||||
Assert.assertArrayEquals("Deleted sessions don't match created sessions", createdSessions, deletedSessions)
|
Assert.assertArrayEquals("Deleted sessions don't match created sessions", createdSessions, deletedSessions)
|
||||||
|
|||||||
+52
-26
@@ -28,7 +28,7 @@ import kotlin.test.assertNotEquals
|
|||||||
import kotlin.test.assertNotNull
|
import kotlin.test.assertNotNull
|
||||||
import kotlin.test.assertTrue
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
class KotlinGradleIT: BaseGradleIT() {
|
class KotlinGradleIT : BaseGradleIT() {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testCrossCompile() {
|
fun testCrossCompile() {
|
||||||
@@ -42,7 +42,12 @@ class KotlinGradleIT: BaseGradleIT() {
|
|||||||
|
|
||||||
project.build("compileDeployKotlin", "build") {
|
project.build("compileDeployKotlin", "build") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertContains(":compileKotlin UP-TO-DATE", ":compileTestKotlin UP-TO-DATE", ":compileDeployKotlin UP-TO-DATE", ":compileJava UP-TO-DATE")
|
assertContains(
|
||||||
|
":compileKotlin UP-TO-DATE",
|
||||||
|
":compileTestKotlin UP-TO-DATE",
|
||||||
|
":compileDeployKotlin UP-TO-DATE",
|
||||||
|
":compileJava UP-TO-DATE"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,15 +136,16 @@ class KotlinGradleIT: BaseGradleIT() {
|
|||||||
val totalMaximum = usedMemory.max()!!
|
val totalMaximum = usedMemory.max()!!
|
||||||
|
|
||||||
val maxGrowth = totalMaximum - establishedMaximum
|
val maxGrowth = totalMaximum - establishedMaximum
|
||||||
assertTrue(maxGrowth <= MEMORY_MAX_GROWTH_LIMIT_KB,
|
assertTrue(
|
||||||
"Maximum used memory over series of builds growth $maxGrowth (from $establishedMaximum to $totalMaximum) kb > $MEMORY_MAX_GROWTH_LIMIT_KB kb")
|
maxGrowth <= MEMORY_MAX_GROWTH_LIMIT_KB,
|
||||||
|
"Maximum used memory over series of builds growth $maxGrowth (from $establishedMaximum to $totalMaximum) kb > $MEMORY_MAX_GROWTH_LIMIT_KB kb"
|
||||||
|
)
|
||||||
|
|
||||||
// testing that nothing remains locked by daemon, see KT-9440
|
// testing that nothing remains locked by daemon, see KT-9440
|
||||||
project.build(userVariantArg, "clean", options = BaseGradleIT.BuildOptions(withDaemon = true)) {
|
project.build(userVariantArg, "clean", options = BaseGradleIT.BuildOptions(withDaemon = true)) {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
}
|
}
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
exitTestDaemon()
|
exitTestDaemon()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -194,8 +200,10 @@ class KotlinGradleIT: BaseGradleIT() {
|
|||||||
project.build("build", options = options) {
|
project.build("build", options = options) {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertNoWarnings()
|
assertNoWarnings()
|
||||||
val affectedSources = project.projectDir.getFilesByNames("Greeter.kt", "KotlinGreetingJoiner.kt",
|
val affectedSources = project.projectDir.getFilesByNames(
|
||||||
"TestGreeter.kt", "TestKotlinGreetingJoiner.kt")
|
"Greeter.kt", "KotlinGreetingJoiner.kt",
|
||||||
|
"TestGreeter.kt", "TestKotlinGreetingJoiner.kt"
|
||||||
|
)
|
||||||
assertCompiledKotlinSources(project.relativize(affectedSources), weakTesting = false)
|
assertCompiledKotlinSources(project.relativize(affectedSources), weakTesting = false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -520,7 +528,8 @@ class KotlinGradleIT: BaseGradleIT() {
|
|||||||
apiVersion = '$apiVersion'
|
apiVersion = '$apiVersion'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
""".trimIndent())
|
""".trimIndent()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(buildGradleContentCopy.indexOf("languageVersion") < 0) { "build.gradle should not contain 'languageVersion'" }
|
assert(buildGradleContentCopy.indexOf("languageVersion") < 0) { "build.gradle should not contain 'languageVersion'" }
|
||||||
@@ -606,16 +615,19 @@ class KotlinGradleIT: BaseGradleIT() {
|
|||||||
// Check that the Java source in a non-full-depth package structure was located correctly:
|
// Check that the Java source in a non-full-depth package structure was located correctly:
|
||||||
checkBytecodeContains(
|
checkBytecodeContains(
|
||||||
File(project.projectDir, kotlinClassesDir() + "my/pack/name/app/MyApp.class"),
|
File(project.projectDir, kotlinClassesDir() + "my/pack/name/app/MyApp.class"),
|
||||||
"my/pack/name/util/JUtil.util")
|
"my/pack/name/util/JUtil.util"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDisableSeparateClassesDirs() {
|
fun testDisableSeparateClassesDirs() {
|
||||||
|
|
||||||
fun CompiledProject.check(copyClassesToJavaOutput: Boolean?,
|
fun CompiledProject.check(
|
||||||
|
copyClassesToJavaOutput: Boolean?,
|
||||||
expectBuildCacheWarning: Boolean,
|
expectBuildCacheWarning: Boolean,
|
||||||
expectGradleLowVersionWarning: Boolean) {
|
expectGradleLowVersionWarning: Boolean
|
||||||
|
) {
|
||||||
|
|
||||||
val separateDirPath = kotlinClassesDir() + "demo/KotlinGreetingJoiner.class"
|
val separateDirPath = kotlinClassesDir() + "demo/KotlinGreetingJoiner.class"
|
||||||
val singleDirPath = javaClassesDir() + "demo/KotlinGreetingJoiner.class"
|
val singleDirPath = javaClassesDir() + "demo/KotlinGreetingJoiner.class"
|
||||||
@@ -645,20 +657,26 @@ class KotlinGradleIT: BaseGradleIT() {
|
|||||||
|
|
||||||
Project("simpleProject", GradleVersionRequired.Exact("4.0")).apply {
|
Project("simpleProject", GradleVersionRequired.Exact("4.0")).apply {
|
||||||
build("build") {
|
build("build") {
|
||||||
check(copyClassesToJavaOutput = false,
|
check(
|
||||||
|
copyClassesToJavaOutput = false,
|
||||||
expectBuildCacheWarning = false,
|
expectBuildCacheWarning = false,
|
||||||
expectGradleLowVersionWarning = false)
|
expectGradleLowVersionWarning = false
|
||||||
|
)
|
||||||
}
|
}
|
||||||
File(projectDir, "build.gradle").appendText("\nkotlin.copyClassesToJavaOutput = true")
|
File(projectDir, "build.gradle").appendText("\nkotlin.copyClassesToJavaOutput = true")
|
||||||
build("clean", "build") {
|
build("clean", "build") {
|
||||||
check(copyClassesToJavaOutput = true,
|
check(
|
||||||
|
copyClassesToJavaOutput = true,
|
||||||
expectBuildCacheWarning = false,
|
expectBuildCacheWarning = false,
|
||||||
expectGradleLowVersionWarning = false)
|
expectGradleLowVersionWarning = false
|
||||||
|
)
|
||||||
}
|
}
|
||||||
build("clean", "build", options = defaultBuildOptions().copy(withBuildCache = true)) {
|
build("clean", "build", options = defaultBuildOptions().copy(withBuildCache = true)) {
|
||||||
check(copyClassesToJavaOutput = true,
|
check(
|
||||||
|
copyClassesToJavaOutput = true,
|
||||||
expectBuildCacheWarning = true,
|
expectBuildCacheWarning = true,
|
||||||
expectGradleLowVersionWarning = false)
|
expectGradleLowVersionWarning = false
|
||||||
|
)
|
||||||
}
|
}
|
||||||
projectDir.deleteRecursively()
|
projectDir.deleteRecursively()
|
||||||
}
|
}
|
||||||
@@ -667,9 +685,11 @@ class KotlinGradleIT: BaseGradleIT() {
|
|||||||
setupWorkingDir()
|
setupWorkingDir()
|
||||||
File(projectDir, "build.gradle").appendText("\nkotlin.copyClassesToJavaOutput = true")
|
File(projectDir, "build.gradle").appendText("\nkotlin.copyClassesToJavaOutput = true")
|
||||||
build("build") {
|
build("build") {
|
||||||
check(copyClassesToJavaOutput = null,
|
check(
|
||||||
|
copyClassesToJavaOutput = null,
|
||||||
expectBuildCacheWarning = false,
|
expectBuildCacheWarning = false,
|
||||||
expectGradleLowVersionWarning = true)
|
expectGradleLowVersionWarning = true
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -678,7 +698,8 @@ class KotlinGradleIT: BaseGradleIT() {
|
|||||||
fun testSrcDirTaskDependency() {
|
fun testSrcDirTaskDependency() {
|
||||||
Project("simpleProject", GradleVersionRequired.AtLeast("4.1")).apply {
|
Project("simpleProject", GradleVersionRequired.AtLeast("4.1")).apply {
|
||||||
setupWorkingDir()
|
setupWorkingDir()
|
||||||
File(projectDir, "build.gradle").appendText("""${'\n'}
|
File(projectDir, "build.gradle").appendText(
|
||||||
|
"""${'\n'}
|
||||||
task generateSources {
|
task generateSources {
|
||||||
outputs.dir('generated')
|
outputs.dir('generated')
|
||||||
doLast {
|
doLast {
|
||||||
@@ -692,10 +713,13 @@ class KotlinGradleIT: BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
sourceSets.main.java.srcDir(tasks.generateSources)
|
sourceSets.main.java.srcDir(tasks.generateSources)
|
||||||
""".trimIndent())
|
""".trimIndent()
|
||||||
File(projectDir, "src/main/kotlin/helloWorld.kt").appendText("""${'\n'}
|
)
|
||||||
|
File(projectDir, "src/main/kotlin/helloWorld.kt").appendText(
|
||||||
|
"""${'\n'}
|
||||||
fun usageOfGeneratedSource() = test.TestClass()
|
fun usageOfGeneratedSource() = test.TestClass()
|
||||||
""".trimIndent())
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
|
||||||
build("build") {
|
build("build") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
@@ -712,7 +736,8 @@ class KotlinGradleIT: BaseGradleIT() {
|
|||||||
File(projectDir, additionalSrcDir).mkdirs()
|
File(projectDir, additionalSrcDir).mkdirs()
|
||||||
File(projectDir, "$additionalSrcDir/additionalSource.kt").writeText("fun hello() = 123")
|
File(projectDir, "$additionalSrcDir/additionalSource.kt").writeText("fun hello() = 123")
|
||||||
|
|
||||||
File(projectDir, "build.gradle").appendText("""${'\n'}
|
File(projectDir, "build.gradle").appendText(
|
||||||
|
"""${'\n'}
|
||||||
task sourcesJar(type: Jar) {
|
task sourcesJar(type: Jar) {
|
||||||
from sourceSets.main.allSource
|
from sourceSets.main.allSource
|
||||||
classifier 'source'
|
classifier 'source'
|
||||||
@@ -720,7 +745,8 @@ class KotlinGradleIT: BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sourceSets.main.kotlin.srcDir('$additionalSrcDir') // test that additional srcDir is included
|
sourceSets.main.kotlin.srcDir('$additionalSrcDir') // test that additional srcDir is included
|
||||||
""".trimIndent())
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
|
||||||
build("sourcesJar") {
|
build("sourcesJar") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
|
|||||||
+6
-3
@@ -113,7 +113,8 @@ class KotlinGradlePluginMultiVersionIT : BaseMultiGradleVersionIT() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun testApplyPluginFromBuildSrc() {
|
@Test
|
||||||
|
fun testApplyPluginFromBuildSrc() {
|
||||||
val project = Project("kotlinProjectWithBuildSrc", gradleVersion)
|
val project = Project("kotlinProjectWithBuildSrc", gradleVersion)
|
||||||
project.setupWorkingDir()
|
project.setupWorkingDir()
|
||||||
File(project.projectDir, "buildSrc/build.gradle").modify { it.replace("\$kotlin_version", KOTLIN_VERSION) }
|
File(project.projectDir, "buildSrc/build.gradle").modify { it.replace("\$kotlin_version", KOTLIN_VERSION) }
|
||||||
@@ -135,8 +136,10 @@ class KotlinGradlePluginMultiVersionIT : BaseMultiGradleVersionIT() {
|
|||||||
fun testJavaLibraryCompatibility() {
|
fun testJavaLibraryCompatibility() {
|
||||||
val project = Project("javaLibraryProject", gradleVersion)
|
val project = Project("javaLibraryProject", gradleVersion)
|
||||||
|
|
||||||
Assume.assumeTrue("The java-library plugin is supported only in Gradle 3.4+ (current: $gradleVersion)",
|
Assume.assumeTrue(
|
||||||
project.testGradleVersionAtLeast("3.4"))
|
"The java-library plugin is supported only in Gradle 3.4+ (current: $gradleVersion)",
|
||||||
|
project.testGradleVersionAtLeast("3.4")
|
||||||
|
)
|
||||||
|
|
||||||
val compileKotlinTasks = listOf(":libA:compileKotlin", ":libB:compileKotlin", ":app:compileKotlin")
|
val compileKotlinTasks = listOf(":libA:compileKotlin", ":libB:compileKotlin", ":app:compileKotlin")
|
||||||
project.build("build") {
|
project.build("build") {
|
||||||
|
|||||||
+12
-6
@@ -33,12 +33,14 @@ class MultiplatformGradleIT : BaseGradleIT() {
|
|||||||
|
|
||||||
project.build("build") {
|
project.build("build") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertContains(":lib:compileKotlinCommon",
|
assertContains(
|
||||||
|
":lib:compileKotlinCommon",
|
||||||
":lib:compileTestKotlinCommon",
|
":lib:compileTestKotlinCommon",
|
||||||
":libJvm:compileKotlin",
|
":libJvm:compileKotlin",
|
||||||
":libJvm:compileTestKotlin",
|
":libJvm:compileTestKotlin",
|
||||||
":libJs:compileKotlin2Js",
|
":libJs:compileKotlin2Js",
|
||||||
":libJs:compileTestKotlin2Js")
|
":libJs:compileTestKotlin2Js"
|
||||||
|
)
|
||||||
assertFileExists("lib/build/classes/kotlin/main/foo/PlatformClass.kotlin_metadata")
|
assertFileExists("lib/build/classes/kotlin/main/foo/PlatformClass.kotlin_metadata")
|
||||||
assertFileExists("lib/build/classes/kotlin/test/foo/PlatformTest.kotlin_metadata")
|
assertFileExists("lib/build/classes/kotlin/test/foo/PlatformTest.kotlin_metadata")
|
||||||
assertFileExists("libJvm/build/classes/kotlin/main/foo/PlatformClass.class")
|
assertFileExists("libJvm/build/classes/kotlin/main/foo/PlatformClass.class")
|
||||||
@@ -74,7 +76,8 @@ class MultiplatformGradleIT : BaseGradleIT() {
|
|||||||
|
|
||||||
File(projectDir, "lib/build.gradle").appendText(
|
File(projectDir, "lib/build.gradle").appendText(
|
||||||
"\ncompileKotlinCommon.kotlinOptions.freeCompilerArgs = ['-Xno-inline']" +
|
"\ncompileKotlinCommon.kotlinOptions.freeCompilerArgs = ['-Xno-inline']" +
|
||||||
"\ncompileKotlinCommon.kotlinOptions.suppressWarnings = true")
|
"\ncompileKotlinCommon.kotlinOptions.suppressWarnings = true"
|
||||||
|
)
|
||||||
|
|
||||||
build("build") {
|
build("build") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
@@ -205,7 +208,8 @@ class MultiplatformGradleIT : BaseGradleIT() {
|
|||||||
@Test
|
@Test
|
||||||
fun testCommonModuleAsTransitiveDependency() = with(Project("multiplatformProject")) {
|
fun testCommonModuleAsTransitiveDependency() = with(Project("multiplatformProject")) {
|
||||||
setupWorkingDir()
|
setupWorkingDir()
|
||||||
gradleBuildScript("libJvm").appendText("""
|
gradleBuildScript("libJvm").appendText(
|
||||||
|
"""
|
||||||
${'\n'}
|
${'\n'}
|
||||||
task printCompileConfiguration(type: DefaultTask) {
|
task printCompileConfiguration(type: DefaultTask) {
|
||||||
doFirst {
|
doFirst {
|
||||||
@@ -214,7 +218,8 @@ class MultiplatformGradleIT : BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
""".trimIndent())
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
|
||||||
build("printCompileConfiguration") {
|
build("printCompileConfiguration") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
@@ -242,7 +247,8 @@ class MultiplatformGradleIT : BaseGradleIT() {
|
|||||||
setupWorkingDir()
|
setupWorkingDir()
|
||||||
val successMarker = "Found JavaCompile task:"
|
val successMarker = "Found JavaCompile task:"
|
||||||
|
|
||||||
gradleBuildScript("lib").appendText("\n" + """
|
gradleBuildScript("lib").appendText(
|
||||||
|
"\n" + """
|
||||||
afterEvaluate {
|
afterEvaluate {
|
||||||
println('$successMarker ' + tasks.getByName('compileJava').path)
|
println('$successMarker ' + tasks.getByName('compileJava').path)
|
||||||
println('$successMarker ' + tasks.getByName('compileTestJava').path)
|
println('$successMarker ' + tasks.getByName('compileTestJava').path)
|
||||||
|
|||||||
+3
-5
@@ -38,7 +38,8 @@ class PluginsDslIT : BaseGradleIT() {
|
|||||||
"org.jetbrains.kotlin.allopen.gradle.AllOpenGradleSubplugin",
|
"org.jetbrains.kotlin.allopen.gradle.AllOpenGradleSubplugin",
|
||||||
"org.jetbrains.kotlin.allopen.gradle.SpringGradleSubplugin",
|
"org.jetbrains.kotlin.allopen.gradle.SpringGradleSubplugin",
|
||||||
"org.jetbrains.kotlin.noarg.gradle.NoArgGradleSubplugin",
|
"org.jetbrains.kotlin.noarg.gradle.NoArgGradleSubplugin",
|
||||||
"org.jetbrains.kotlin.noarg.gradle.KotlinJpaSubplugin")
|
"org.jetbrains.kotlin.noarg.gradle.KotlinJpaSubplugin"
|
||||||
|
)
|
||||||
|
|
||||||
project.build("build") {
|
project.build("build") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
@@ -97,10 +98,7 @@ class PluginsDslIT : BaseGradleIT() {
|
|||||||
private object MavenLocalUrlProvider {
|
private object MavenLocalUrlProvider {
|
||||||
/** The URL that points to the Gradle's mavenLocal() repository. */
|
/** The URL that points to the Gradle's mavenLocal() repository. */
|
||||||
val mavenLocalUrl by lazy {
|
val mavenLocalUrl by lazy {
|
||||||
val path = propertyMavenLocalRepoPath ?:
|
val path = propertyMavenLocalRepoPath ?: homeSettingsLocalRepoPath ?: m2HomeSettingsLocalRepoPath ?: defaultM2RepoPath
|
||||||
homeSettingsLocalRepoPath ?:
|
|
||||||
m2HomeSettingsLocalRepoPath ?:
|
|
||||||
defaultM2RepoPath
|
|
||||||
File(path).toURI().toString()
|
File(path).toURI().toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+23
-9
@@ -24,7 +24,12 @@ class SimpleKotlinGradleIT : BaseGradleIT() {
|
|||||||
|
|
||||||
project.build("compileDeployKotlin", "build") {
|
project.build("compileDeployKotlin", "build") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertContains(":compileKotlin UP-TO-DATE", ":compileTestKotlin UP-TO-DATE", ":compileDeployKotlin UP-TO-DATE", ":compileJava UP-TO-DATE")
|
assertContains(
|
||||||
|
":compileKotlin UP-TO-DATE",
|
||||||
|
":compileTestKotlin UP-TO-DATE",
|
||||||
|
":compileDeployKotlin UP-TO-DATE",
|
||||||
|
":compileJava UP-TO-DATE"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,6 +65,7 @@ class SimpleKotlinGradleIT : BaseGradleIT() {
|
|||||||
assertContains("This type is sealed")
|
assertContains("This type is sealed")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testJvmTarget() {
|
fun testJvmTarget() {
|
||||||
Project("jvmTarget").build("build") {
|
Project("jvmTarget").build("build") {
|
||||||
@@ -115,13 +121,17 @@ class SimpleKotlinGradleIT : BaseGradleIT() {
|
|||||||
assertTrue(openClass.exists())
|
assertTrue(openClass.exists())
|
||||||
assertTrue(closedClass.exists())
|
assertTrue(closedClass.exists())
|
||||||
|
|
||||||
checkBytecodeContains(openClass,
|
checkBytecodeContains(
|
||||||
|
openClass,
|
||||||
"public class test/OpenClass {",
|
"public class test/OpenClass {",
|
||||||
"public method()V")
|
"public method()V"
|
||||||
|
)
|
||||||
|
|
||||||
checkBytecodeContains(closedClass,
|
checkBytecodeContains(
|
||||||
|
closedClass,
|
||||||
"public final class test/ClosedClass {",
|
"public final class test/ClosedClass {",
|
||||||
"public final method()V")
|
"public final method()V"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,13 +146,17 @@ class SimpleKotlinGradleIT : BaseGradleIT() {
|
|||||||
assertTrue(openClass.exists())
|
assertTrue(openClass.exists())
|
||||||
assertTrue(closedClass.exists())
|
assertTrue(closedClass.exists())
|
||||||
|
|
||||||
checkBytecodeContains(openClass,
|
checkBytecodeContains(
|
||||||
|
openClass,
|
||||||
"public class test/OpenClass {",
|
"public class test/OpenClass {",
|
||||||
"public method()V")
|
"public method()V"
|
||||||
|
)
|
||||||
|
|
||||||
checkBytecodeContains(closedClass,
|
checkBytecodeContains(
|
||||||
|
closedClass,
|
||||||
"public final class test/ClosedClass {",
|
"public final class test/ClosedClass {",
|
||||||
"public final method()V")
|
"public final method()V"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+21
-10
@@ -10,26 +10,36 @@ import java.io.File
|
|||||||
class UpToDateIT : BaseGradleIT() {
|
class UpToDateIT : BaseGradleIT() {
|
||||||
@Test
|
@Test
|
||||||
fun testLanguageVersionChange() {
|
fun testLanguageVersionChange() {
|
||||||
testMutations(*propertyMutationChain("compileKotlin.kotlinOptions.languageVersion",
|
testMutations(
|
||||||
"null", "'1.1'", "'1.0'", "null"))
|
*propertyMutationChain(
|
||||||
|
"compileKotlin.kotlinOptions.languageVersion",
|
||||||
|
"null", "'1.1'", "'1.0'", "null"
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testApiVersionChange() {
|
fun testApiVersionChange() {
|
||||||
testMutations(*propertyMutationChain("compileKotlin.kotlinOptions.apiVersion",
|
testMutations(
|
||||||
"null", "'1.1'", "'1.0'", "null"))
|
*propertyMutationChain(
|
||||||
|
"compileKotlin.kotlinOptions.apiVersion",
|
||||||
|
"null", "'1.1'", "'1.0'", "null"
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testOther() {
|
fun testOther() {
|
||||||
testMutations(emptyMutation,
|
testMutations(
|
||||||
|
emptyMutation,
|
||||||
OptionMutation("compileKotlin.kotlinOptions.jvmTarget", "'1.6'", "'1.8'"),
|
OptionMutation("compileKotlin.kotlinOptions.jvmTarget", "'1.6'", "'1.8'"),
|
||||||
OptionMutation("compileKotlin.kotlinOptions.freeCompilerArgs", "[]", "['-Xallow-kotlin-package']"),
|
OptionMutation("compileKotlin.kotlinOptions.freeCompilerArgs", "[]", "['-Xallow-kotlin-package']"),
|
||||||
OptionMutation("kotlin.experimental.coroutines", "'error'", "'enable'"),
|
OptionMutation("kotlin.experimental.coroutines", "'error'", "'enable'"),
|
||||||
OptionMutation("archivesBaseName", "'someName'", "'otherName'"),
|
OptionMutation("archivesBaseName", "'someName'", "'otherName'"),
|
||||||
subpluginOptionMutation,
|
subpluginOptionMutation,
|
||||||
externalOutputMutation,
|
externalOutputMutation,
|
||||||
compilerClasspathMutation)
|
compilerClasspathMutation
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun testMutations(vararg mutations: ProjectMutation) {
|
private fun testMutations(vararg mutations: ProjectMutation) {
|
||||||
@@ -44,8 +54,7 @@ class UpToDateIT : BaseGradleIT() {
|
|||||||
try {
|
try {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
it.checkAfterRebuild(this)
|
it.checkAfterRebuild(this)
|
||||||
}
|
} catch (e: Throwable) {
|
||||||
catch (e: Throwable) {
|
|
||||||
throw RuntimeException("Mutation '${it.name}' has failed", e)
|
throw RuntimeException("Mutation '${it.name}' has failed", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,11 +112,13 @@ class UpToDateIT : BaseGradleIT() {
|
|||||||
override val name: String get() = "subpluginOptionMutation"
|
override val name: String get() = "subpluginOptionMutation"
|
||||||
|
|
||||||
override fun initProject(project: Project) = with(project) {
|
override fun initProject(project: Project) = with(project) {
|
||||||
buildGradle.appendText("\n" + """
|
buildGradle.appendText(
|
||||||
|
"\n" + """
|
||||||
buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-allopen:${'$'}kotlin_version" } }
|
buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-allopen:${'$'}kotlin_version" } }
|
||||||
apply plugin: "kotlin-allopen"
|
apply plugin: "kotlin-allopen"
|
||||||
allOpen { annotation("allopen.Foo"); annotation("allopen.Bar") }
|
allOpen { annotation("allopen.Foo"); annotation("allopen.Bar") }
|
||||||
""".trimIndent())
|
""".trimIndent()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun mutateProject(project: Project) = with(project) {
|
override fun mutateProject(project: Project) = with(project) {
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ fun File.allJavaFiles(): Iterable<File> =
|
|||||||
fun File.allFilesWithExtension(ext: String): Iterable<File> =
|
fun File.allFilesWithExtension(ext: String): Iterable<File> =
|
||||||
walk().filter { it.isFile && it.extension.equals(ext, ignoreCase = true) }.toList()
|
walk().filter { it.isFile && it.extension.equals(ext, ignoreCase = true) }.toList()
|
||||||
|
|
||||||
fun File.modify(transform: (String)->String) {
|
fun File.modify(transform: (String) -> String) {
|
||||||
writeText(transform(readText()))
|
writeText(transform(readText()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-7
@@ -42,13 +42,15 @@ abstract class BaseIncrementalGradleIT : BaseGradleIT() {
|
|||||||
assertReportExists()
|
assertReportExists()
|
||||||
}
|
}
|
||||||
|
|
||||||
val buildLogFile = buildLogFinder.findBuildLog(resourcesRoot) ?:
|
val buildLogFile =
|
||||||
throw IllegalStateException("build log file not found in $resourcesRoot")
|
buildLogFinder.findBuildLog(resourcesRoot) ?: throw IllegalStateException("build log file not found in $resourcesRoot")
|
||||||
val buildLogSteps = parseTestBuildLog(buildLogFile)
|
val buildLogSteps = parseTestBuildLog(buildLogFile)
|
||||||
val modifications = getModificationsToPerform(resourcesRoot,
|
val modifications = getModificationsToPerform(
|
||||||
|
resourcesRoot,
|
||||||
moduleNames = null,
|
moduleNames = null,
|
||||||
allowNoFilesWithSuffixInTestData = false,
|
allowNoFilesWithSuffixInTestData = false,
|
||||||
touchPolicy = TouchPolicy.CHECKSUM)
|
touchPolicy = TouchPolicy.CHECKSUM
|
||||||
|
)
|
||||||
|
|
||||||
assert(modifications.size == buildLogSteps.size) {
|
assert(modifications.size == buildLogSteps.size) {
|
||||||
"Modifications count (${modifications.size}) != expected build log steps count (${buildLogSteps.size})"
|
"Modifications count (${modifications.size}) != expected build log steps count (${buildLogSteps.size})"
|
||||||
@@ -67,14 +69,17 @@ abstract class BaseIncrementalGradleIT : BaseGradleIT() {
|
|||||||
rebuildAndCompareOutput(rebuildSucceedExpected = buildLogSteps.last().compileSucceeded)
|
rebuildAndCompareOutput(rebuildSucceedExpected = buildLogSteps.last().compileSucceeded)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun JpsTestProject.buildAndAssertStageResults(expected: BuildStep, options: BuildOptions = defaultBuildOptions(), weakTesting: Boolean = false) {
|
private fun JpsTestProject.buildAndAssertStageResults(
|
||||||
|
expected: BuildStep,
|
||||||
|
options: BuildOptions = defaultBuildOptions(),
|
||||||
|
weakTesting: Boolean = false
|
||||||
|
) {
|
||||||
build("build", options = options) {
|
build("build", options = options) {
|
||||||
if (expected.compileSucceeded) {
|
if (expected.compileSucceeded) {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertCompiledJavaSources(expected.compiledJavaFiles, weakTesting)
|
assertCompiledJavaSources(expected.compiledJavaFiles, weakTesting)
|
||||||
assertCompiledKotlinSources(expected.compiledKotlinFiles, weakTesting)
|
assertCompiledKotlinSources(expected.compiledKotlinFiles, weakTesting)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
assertFailed()
|
assertFailed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-2
@@ -5,6 +5,7 @@ import org.junit.Test
|
|||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.junit.runners.Parameterized
|
import org.junit.runners.Parameterized
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@RunWith(Parameterized::class)
|
@RunWith(Parameterized::class)
|
||||||
class KotlinGradlePluginJpsParametrizedIT : BaseIncrementalGradleIT() {
|
class KotlinGradlePluginJpsParametrizedIT : BaseIncrementalGradleIT() {
|
||||||
|
|
||||||
@@ -23,10 +24,12 @@ class KotlinGradlePluginJpsParametrizedIT : BaseIncrementalGradleIT() {
|
|||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private val jpsResourcesPath = File("../../../jps-plugin/testData/incremental")
|
private val jpsResourcesPath = File("../../../jps-plugin/testData/incremental")
|
||||||
private val ignoredDirs = setOf(File(jpsResourcesPath, "cacheVersionChanged"),
|
private val ignoredDirs = setOf(
|
||||||
|
File(jpsResourcesPath, "cacheVersionChanged"),
|
||||||
File(jpsResourcesPath, "changeIncrementalOption"),
|
File(jpsResourcesPath, "changeIncrementalOption"),
|
||||||
File(jpsResourcesPath, "custom"),
|
File(jpsResourcesPath, "custom"),
|
||||||
File(jpsResourcesPath, "lookupTracker"))
|
File(jpsResourcesPath, "lookupTracker")
|
||||||
|
)
|
||||||
private val buildLogFinder = BuildLogFinder(isGradleEnabled = true)
|
private val buildLogFinder = BuildLogFinder(isGradleEnabled = true)
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
|
|||||||
Reference in New Issue
Block a user