Replace assertContains with assertTasksExecuted/assertTasksUpToDate

This commit is contained in:
Alexey Tsvetkov
2018-05-04 22:51:39 +03:00
parent f00e243822
commit 89da660186
11 changed files with 85 additions and 107 deletions
@@ -1,5 +1,6 @@
package org.jetbrains.kotlin.gradle package org.jetbrains.kotlin.gradle
import org.gradle.api.logging.LogLevel
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
@@ -46,7 +47,7 @@ abstract class KotlinAndroid3GradleIT(
project.build(":Lib:assemble") { project.build(":Lib:assemble") {
assertSuccessful() assertSuccessful()
assertContains(*kotlinTaskNames.toTypedArray()) assertTasksExecuted(*kotlinTaskNames.toTypedArray())
} }
} }
} }
@@ -112,15 +113,21 @@ abstract class AbstractKotlinAndroidGradleTests(
@Test @Test
fun testAssembleAndroidTestFirst() { fun testAssembleAndroidTestFirst() {
val project = Project("AndroidProject", gradleVersion) val project = Project("AndroidProject", gradleVersion, minLogLevel = LogLevel.INFO)
// Execute 'assembleAndroidTest' first, without 'build' side effects // Execute 'assembleAndroidTest' first, without 'build' side effects
project.build("assembleAndroidTest") { project.build("assembleAndroidTest") {
assertSuccessful() assertSuccessful()
if (isLegacyAndroidGradleVersion(androidGradlePluginVersion)) { if (isLegacyAndroidGradleVersion(androidGradlePluginVersion)) {
val tasks = ArrayList<String>().apply {
for (subProject in listOf("Android", "Lib")) {
for (flavor in listOf("Flavor1", "Flavor2")) {
add(":$subProject:copy${flavor}DebugKotlinClasses")
}
}
}
// with the new AGP we don't need copy classes tasks // with the new AGP we don't need copy classes tasks
assertContains(":copyFlavor1DebugKotlinClasses") assertTasksExecuted(tasks)
assertContains(":copyFlavor2DebugKotlinClasses")
} }
} }
} }
@@ -153,19 +160,19 @@ fun getSomething() = 10
@Test @Test
fun testIncrementalBuildWithNoChanges() { fun testIncrementalBuildWithNoChanges() {
val project = Project("AndroidIncrementalSingleModuleProject", gradleVersion) val project = Project("AndroidIncrementalSingleModuleProject", gradleVersion)
val tasksToExecute = arrayOf( val tasksToExecute = listOf(
":app:compileDebugKotlin", ":app:compileDebugKotlin",
":app:compileDebugJavaWithJavac" ":app:compileDebugJavaWithJavac"
) )
project.build("assembleDebug") { project.build("assembleDebug") {
assertSuccessful() assertSuccessful()
assertContains(*tasksToExecute) assertTasksExecuted(tasksToExecute)
} }
project.build("assembleDebug") { project.build("assembleDebug") {
assertSuccessful() assertSuccessful()
assertContains(*tasksToExecute.map { it + " UP-TO-DATE" }.toTypedArray()) assertTasksUpToDate(tasksToExecute)
} }
} }
@@ -287,7 +294,7 @@ fun getSomething() = 10
project.build("build") { project.build("build") {
assertSuccessful() assertSuccessful()
assertContains( assertTasksExecuted(
":lib:compileKotlinCommon", ":lib:compileKotlinCommon",
":lib:compileTestKotlinCommon", ":lib:compileTestKotlinCommon",
":libJvm:compileKotlin", ":libJvm:compileKotlin",
@@ -59,7 +59,7 @@ class ClassFileIsRemovedIT : BaseGradleIT() {
// check that class removal does not trigger rebuild // check that class removal does not trigger rebuild
project.build("build", options = buildOptions) { project.build("build", options = buildOptions) {
assertSuccessful() assertSuccessful()
assertContains(":compileKotlin UP-TO-DATE", ":compileJava UP-TO-DATE") assertTasksUpToDate(":compileKotlin", ":compileJava")
} }
} }
} }
@@ -47,8 +47,7 @@ open class Kapt3AndroidIT : Kapt3BaseIT() {
project.build("build", options = options) { project.build("build", options = options) {
assertSuccessful() assertSuccessful()
assertContains(":compileReleaseKotlin UP-TO-DATE") assertTasksUpToDate(":compileReleaseKotlin", ":compileReleaseJavaWithJavac")
assertContains(":compileReleaseJavaWithJavac UP-TO-DATE")
} }
} }
@@ -42,8 +42,7 @@ open class Kapt3IT : Kapt3BaseIT() {
project.build("build") { project.build("build") {
assertSuccessful() assertSuccessful()
assertKaptSuccessful() assertKaptSuccessful()
assertContains(":compileKotlin") assertTasksExecuted(":compileKotlin", ":compileJava")
assertContains(":compileJava")
assertFileExists("build/generated/source/kapt/main/example/TestClassGenerated.java") assertFileExists("build/generated/source/kapt/main/example/TestClassGenerated.java")
assertFileExists(kotlinClassesDir() + "example/TestClass.class") assertFileExists(kotlinClassesDir() + "example/TestClass.class")
assertFileExists(javaClassesDir() + "example/TestClassGenerated.class") assertFileExists(javaClassesDir() + "example/TestClassGenerated.class")
@@ -57,8 +56,7 @@ open class Kapt3IT : Kapt3BaseIT() {
project.build("build") { project.build("build") {
assertSuccessful() assertSuccessful()
assertKaptSuccessful() assertKaptSuccessful()
assertContains(":compileKotlin") assertTasksExecuted(":compileKotlin", ":compileJava")
assertContains(":compileJava")
assertFileExists("build/generated/source/kapt/main/example/TestClassGenerated.java") assertFileExists("build/generated/source/kapt/main/example/TestClassGenerated.java")
assertFileExists(kotlinClassesDir() + "example/TestClass.class") assertFileExists(kotlinClassesDir() + "example/TestClass.class")
val javaClassesDir = javaClassesDir() val javaClassesDir = javaClassesDir()
@@ -74,8 +72,7 @@ open class Kapt3IT : Kapt3BaseIT() {
project.build("build") { project.build("build") {
assertSuccessful() assertSuccessful()
assertContains(":compileKotlin UP-TO-DATE") assertTasksUpToDate(":compileKotlin", ":compileJava")
assertContains(":compileJava UP-TO-DATE")
} }
} }
@@ -88,8 +85,7 @@ open class Kapt3IT : Kapt3BaseIT() {
project.build("clean", "build", options = options) { project.build("clean", "build", options = options) {
assertSuccessful() assertSuccessful()
assertKaptSuccessful() assertKaptSuccessful()
assertContains(":compileKotlin") assertTasksExecuted(":compileKotlin", ":compileJava")
assertContains(":compileJava")
assertClassFilesNotContain(javaClassesDir, "ExampleSourceAnnotation") assertClassFilesNotContain(javaClassesDir, "ExampleSourceAnnotation")
} }
@@ -97,8 +93,9 @@ open class Kapt3IT : Kapt3BaseIT() {
project.build("build", options = options) { project.build("build", options = options) {
assertSuccessful() assertSuccessful()
assertKaptSuccessful() assertKaptSuccessful()
assertContains(":compileKotlin") assertTasksExecuted(":compileKotlin")
assertContains(":compileJava") // there are no actual changes in Java sources, generated sources, Kotlin classes
assertTasksUpToDate(":compileJava")
assertClassFilesNotContain(javaClassesDir, "ExampleSourceAnnotation") assertClassFilesNotContain(javaClassesDir, "ExampleSourceAnnotation")
} }
@@ -106,9 +103,7 @@ open class Kapt3IT : Kapt3BaseIT() {
javaClassesDir.deleteRecursively() javaClassesDir.deleteRecursively()
project.build("build", options = options) { project.build("build", options = options) {
assertSuccessful() assertSuccessful()
assertContains(":compileKotlin UP-TO-DATE") assertTasksUpToDate(":kaptGenerateStubsKotlin", ":kaptKotlin", ":compileKotlin")
assertContains(":kaptGenerateStubsKotlin UP-TO-DATE")
assertContains(":kaptKotlin UP-TO-DATE")
assertFileExists(kotlinClassesDir() + "example/TestClass.class") assertFileExists(kotlinClassesDir() + "example/TestClass.class")
assertClassFilesNotContain(javaClassesDir, "ExampleSourceAnnotation") assertClassFilesNotContain(javaClassesDir, "ExampleSourceAnnotation")
} }
@@ -119,7 +114,7 @@ open class Kapt3IT : Kapt3BaseIT() {
val project = Project("simple", directoryPrefix = "kapt2") val project = Project("simple", directoryPrefix = "kapt2")
project.build("build", options = defaultBuildOptions().copy(incremental = false)) { project.build("build", options = defaultBuildOptions().copy(incremental = false)) {
assertSuccessful() assertSuccessful()
assertContains(":kaptGenerateStubsKotlin") assertTasksExecuted(":kaptGenerateStubsKotlin")
assertNotContains(USING_INCREMENTAL_COMPILATION_MESSAGE) assertNotContains(USING_INCREMENTAL_COMPILATION_MESSAGE)
} }
} }
@@ -161,8 +156,7 @@ open class Kapt3IT : Kapt3BaseIT() {
project.build("build") { project.build("build") {
assertSuccessful() assertSuccessful()
assertKaptSuccessful() assertKaptSuccessful()
assertContains(":compileKotlin") assertTasksExecuted(":compileKotlin", ":compileJava")
assertContains(":compileJava")
assertFileExists(kotlinClassesDir() + "example/TestClass.class") assertFileExists(kotlinClassesDir() + "example/TestClass.class")
assertFileExists("build/generated/source/kapt/main/example/TestClassGenerated.java") assertFileExists("build/generated/source/kapt/main/example/TestClassGenerated.java")
@@ -181,8 +175,7 @@ open class Kapt3IT : Kapt3BaseIT() {
project.build("build") { project.build("build") {
assertSuccessful() assertSuccessful()
assertContains(":compileKotlin") assertTasksExecuted(":compileKotlin", ":compileJava")
assertContains(":compileJava")
assertFileExists(kotlinClassesDir() + "example/TestClass.class") assertFileExists(kotlinClassesDir() + "example/TestClass.class")
assertFileExists("build/generated/source/kapt/main/example/TestClassGenerated.java") assertFileExists("build/generated/source/kapt/main/example/TestClassGenerated.java")
@@ -16,8 +16,7 @@ class KaptIT : BaseGradleIT() {
project.build("build") { project.build("build") {
assertSuccessful() assertSuccessful()
assertContains("kapt: Class file stubs are not used") assertContains("kapt: Class file stubs are not used")
assertContains(":compileKotlin") assertTasksExecuted(":compileKotlin", ":compileJava")
assertContains(":compileJava")
assertFileExists("build/tmp/kapt/main/wrappers/annotations.main.txt") assertFileExists("build/tmp/kapt/main/wrappers/annotations.main.txt")
assertFileExists("build/generated/source/kapt/main/example/TestClassGenerated.java") assertFileExists("build/generated/source/kapt/main/example/TestClassGenerated.java")
assertFileExists(kotlinClassesDir() + "example/TestClass.class") assertFileExists(kotlinClassesDir() + "example/TestClass.class")
@@ -45,8 +44,7 @@ class KaptIT : BaseGradleIT() {
project.build("build") { project.build("build") {
assertSuccessful() assertSuccessful()
assertContains(":compileKotlin") assertTasksExecuted(":compileKotlin", ":compileJava")
assertContains(":compileJava")
assertFileExists("build/tmp/kapt/main/wrappers/annotations.main.txt") assertFileExists("build/tmp/kapt/main/wrappers/annotations.main.txt")
} }
@@ -63,8 +61,7 @@ class KaptIT : BaseGradleIT() {
project.build("build") { project.build("build") {
assertSuccessful() assertSuccessful()
assertContains("kapt: Using class file stubs") assertContains("kapt: Using class file stubs")
assertContains(":compileKotlin") assertTasksExecuted(":compileKotlin", ":compileJava")
assertContains(":compileJava")
assertFileExists("build/tmp/kapt/main/wrappers/annotations.main.txt") assertFileExists("build/tmp/kapt/main/wrappers/annotations.main.txt")
assertFileExists("build/generated/source/kapt/main/example/TestClassGenerated.java") assertFileExists("build/generated/source/kapt/main/example/TestClassGenerated.java")
assertFileExists(kotlinClassesDir() + "example/TestClass.class") assertFileExists(kotlinClassesDir() + "example/TestClass.class")
@@ -90,8 +87,7 @@ class KaptIT : BaseGradleIT() {
project.build("build") { project.build("build") {
assertSuccessful() assertSuccessful()
assertContains("kapt: Using class file stubs") assertContains("kapt: Using class file stubs")
assertContains(":compileKotlin") assertTasksExecuted(":compileKotlin", ":compileJava")
assertContains(":compileJava")
assertFileExists(kotlinClassesDir() + "example/TestClass.class") assertFileExists(kotlinClassesDir() + "example/TestClass.class")
assertFileExists(javaClassesDir() + "example/TestClassGenerated.class") assertFileExists(javaClassesDir() + "example/TestClassGenerated.class")
} }
@@ -99,16 +95,15 @@ class KaptIT : BaseGradleIT() {
@Test @Test
fun testSimpleIncrementalBuild() { fun testSimpleIncrementalBuild() {
doTestIncrementalBuild("kaptSimple", arrayOf(":compileKotlin", ":compileJava")) doTestIncrementalBuild("kaptSimple", listOf(":compileKotlin", ":compileJava"))
} }
@Test @Test
fun testStubsIncrementalBuild() { fun testStubsIncrementalBuild() {
doTestIncrementalBuild("kaptStubs", arrayOf(":compileKotlin", ":compileJava", ":compileKotlinAfterJava")) doTestIncrementalBuild("kaptStubs", listOf(":compileKotlin", ":compileJava", ":compileKotlinAfterJava"))
} }
private fun doTestIncrementalBuild(projectName: String, compileTasks: Array<String>) { private fun doTestIncrementalBuild(projectName: String, compileTasks: List<String>) {
val compileTasksUpToDate = compileTasks.map { it + " UP-TO-DATE" }.toTypedArray()
val project = Project(projectName, GradleVersionRequired.Exact("3.5")) val project = Project(projectName, GradleVersionRequired.Exact("3.5"))
project.allowOriginalKapt() project.allowOriginalKapt()
@@ -119,27 +114,25 @@ class KaptIT : BaseGradleIT() {
project.projectDir.getFileByName("test.kt").appendText(" ") project.projectDir.getFileByName("test.kt").appendText(" ")
project.build("build") { project.build("build") {
assertSuccessful() assertSuccessful()
assertContains(*compileTasks) assertTasksExecuted(compileTasks)
assertNotContains(*compileTasksUpToDate)
} }
repeat(2) { repeat(2) {
project.build("build") { project.build("build") {
assertSuccessful() assertSuccessful()
assertContains(*compileTasksUpToDate) assertTasksUpToDate(compileTasks)
} }
} }
project.build("clean", "build") { project.build("clean", "build") {
assertSuccessful() assertSuccessful()
assertContains(*compileTasks) assertTasksExecuted(compileTasks)
assertNotContains(*compileTasksUpToDate)
} }
repeat(2) { repeat(2) {
project.build("build") { project.build("build") {
assertSuccessful() assertSuccessful()
assertContains(*compileTasksUpToDate) assertTasksUpToDate(compileTasks)
} }
} }
} }
@@ -152,8 +145,7 @@ class KaptIT : BaseGradleIT() {
project.build("build") { project.build("build") {
assertSuccessful() assertSuccessful()
assertContains("kapt: Using class file stubs") assertContains("kapt: Using class file stubs")
assertContains(":compileKotlin") assertTasksExecuted(":compileKotlin", ":compileJava")
assertContains(":compileJava")
assertFileExists("build/tmp/kapt/main/wrappers/annotations.main.txt") assertFileExists("build/tmp/kapt/main/wrappers/annotations.main.txt")
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")
@@ -183,8 +175,7 @@ class KaptIT : BaseGradleIT() {
project.build("build") { project.build("build") {
assertSuccessful() assertSuccessful()
assertContains("kapt: Using class file stubs") assertContains("kapt: Using class file stubs")
assertContains(":compileKotlin") assertTasksExecuted(":compileKotlin", ":compileJava")
assertContains(":compileJava")
assertFileExists("build/tmp/kapt/main/wrappers/annotations.main.txt") assertFileExists("build/tmp/kapt/main/wrappers/annotations.main.txt")
assertFileExists("build/generated/source/kapt/main/example/TestClassCustomized.java") assertFileExists("build/generated/source/kapt/main/example/TestClassCustomized.java")
assertFileExists("build/tmp/kapt/main/kotlinGenerated/TestClass.kt") assertFileExists("build/tmp/kapt/main/kotlinGenerated/TestClass.kt")
@@ -65,20 +65,20 @@ abstract class KaptIncrementalBaseIT(val shouldUseStubs: Boolean, val useKapt3:
project.build("build") { project.build("build") {
assertSuccessful() assertSuccessful()
assertContains( assertTasksUpToDate(
":compileKotlin UP-TO-DATE", ":compileKotlin",
":compileJava UP-TO-DATE" ":compileJava"
) )
if (useKapt3) { if (useKapt3) {
assertContains( assertTasksUpToDate(
":kaptKotlin UP-TO-DATE", ":kaptKotlin",
":kaptGenerateStubsKotlin UP-TO-DATE" ":kaptGenerateStubsKotlin"
) )
} }
if (shouldUseStubs) { if (shouldUseStubs) {
assertContains(":compileKotlinAfterJava UP-TO-DATE") assertTasksUpToDate(":compileKotlinAfterJava")
} }
} }
} }
@@ -106,8 +106,8 @@ abstract class KaptIncrementalBaseIT(val shouldUseStubs: Boolean, val useKapt3:
checkStubUsage() checkStubUsage()
if (useKapt3) { if (useKapt3) {
assertNotContains(":kaptGenerateStubsKotlin UP-TO-DATE") assertTasksExecuted(":kaptGenerateStubsKotlin")
assertContains(":kaptKotlin UP-TO-DATE") assertTasksUpToDate(":kaptKotlin")
} }
} }
} }
@@ -19,7 +19,7 @@ class Kotlin2JsGradlePluginIT : BaseGradleIT() {
assertSuccessful() assertSuccessful()
assertReportExists() assertReportExists()
assertContains( assertTasksExecuted(
":libraryProject:jarSources", ":libraryProject:jarSources",
":mainProject:compileKotlin2Js", ":mainProject:compileKotlin2Js",
":libraryProject:compileKotlin2Js" ":libraryProject:compileKotlin2Js"
@@ -35,7 +35,7 @@ class Kotlin2JsGradlePluginIT : BaseGradleIT() {
project.build("build") { project.build("build") {
assertSuccessful() assertSuccessful()
assertContains(":mainProject:compileKotlin2Js UP-TO-DATE") assertTasksUpToDate(":mainProject:compileKotlin2Js")
assertContainsRegex(":libraryProject:compileTestKotlin2Js (UP-TO-DATE|NO-SOURCE)".toRegex()) assertContainsRegex(":libraryProject:compileTestKotlin2Js (UP-TO-DATE|NO-SOURCE)".toRegex())
} }
@@ -64,7 +64,7 @@ class Kotlin2JsGradlePluginIT : BaseGradleIT() {
project.build("jar") { project.build("jar") {
assertSuccessful() assertSuccessful()
assertContains(":compileKotlin2Js") assertTasksExecuted(":compileKotlin2Js")
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))
@@ -82,7 +82,7 @@ class Kotlin2JsGradlePluginIT : BaseGradleIT() {
project.build(":jar") { project.build(":jar") {
assertSuccessful() assertSuccessful()
assertContains(":compileKotlin2Js") assertTasksExecuted(":compileKotlin2Js")
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))
@@ -120,7 +120,7 @@ class Kotlin2JsGradlePluginIT : BaseGradleIT() {
project.build("build") { project.build("build") {
assertSuccessful() assertSuccessful()
assertContains( assertTasksExecuted(
":compileKotlin2Js", ":compileKotlin2Js",
":compileTestKotlin2Js" ":compileTestKotlin2Js"
) )
@@ -146,7 +146,7 @@ class Kotlin2JsGradlePluginIT : BaseGradleIT() {
project.build("build") { project.build("build") {
assertSuccessful() assertSuccessful()
assertContains( assertTasksExecuted(
":compileKotlin2Js", ":compileKotlin2Js",
":compileIntegrationTestKotlin2Js" ":compileIntegrationTestKotlin2Js"
) )
@@ -37,16 +37,16 @@ class KotlinGradleIT : BaseGradleIT() {
project.build("compileDeployKotlin", "build") { project.build("compileDeployKotlin", "build") {
assertSuccessful() assertSuccessful()
assertReportExists() assertReportExists()
assertContains(":compileKotlin", ":compileTestKotlin", ":compileDeployKotlin") assertTasksExecuted(":compileKotlin", ":compileTestKotlin", ":compileDeployKotlin")
} }
project.build("compileDeployKotlin", "build") { project.build("compileDeployKotlin", "build") {
assertSuccessful() assertSuccessful()
assertContains( assertTasksUpToDate(
":compileKotlin UP-TO-DATE", ":compileKotlin",
":compileTestKotlin UP-TO-DATE", ":compileTestKotlin",
":compileDeployKotlin UP-TO-DATE", ":compileDeployKotlin",
":compileJava UP-TO-DATE" ":compileJava"
) )
} }
} }
@@ -82,13 +82,13 @@ class KotlinGradleIT : BaseGradleIT() {
assertSuccessful() assertSuccessful()
assertFileExists(kotlinClassesDir() + "META-INF/kotlinProject.kotlin_module") assertFileExists(kotlinClassesDir() + "META-INF/kotlinProject.kotlin_module")
assertReportExists() assertReportExists()
assertContains(":compileKotlin", ":compileTestKotlin") assertTasksExecuted(":compileKotlin", ":compileTestKotlin")
assertNotContains("Forcing System.gc") assertNotContains("Forcing System.gc")
} }
project.build("build") { project.build("build") {
assertSuccessful() assertSuccessful()
assertContains(":compileKotlin UP-TO-DATE", ":compileTestKotlin UP-TO-DATE") assertTasksUpToDate(":compileKotlin", ":compileTestKotlin")
} }
} }
@@ -168,7 +168,7 @@ class KotlinGradleIT : BaseGradleIT() {
Project("classpathTest").build("build") { Project("classpathTest").build("build") {
assertSuccessful() assertSuccessful()
assertReportExists() assertReportExists()
assertContains(":compileKotlin", ":compileTestKotlin") assertTasksExecuted(":compileKotlin", ":compileTestKotlin")
} }
} }
@@ -177,7 +177,7 @@ class KotlinGradleIT : BaseGradleIT() {
Project("multiprojectClassPathTest").build("build") { Project("multiprojectClassPathTest").build("build") {
assertSuccessful() assertSuccessful()
assertReportExists("subproject") assertReportExists("subproject")
assertContains(":subproject:compileKotlin", ":subproject:compileTestKotlin") assertTasksExecuted(":subproject:compileKotlin", ":subproject:compileTestKotlin")
checkKotlinGradleBuildServices() checkKotlinGradleBuildServices()
} }
} }
@@ -210,23 +210,15 @@ class KotlinGradleIT : BaseGradleIT() {
@Test @Test
fun testSimpleMultiprojectIncremental() { fun testSimpleMultiprojectIncremental() {
fun Project.modify(body: Project.() -> Unit): Project {
this.body()
return this
}
val incremental = defaultBuildOptions().copy(incremental = true) val incremental = defaultBuildOptions().copy(incremental = true)
Project("multiprojectWithDependency").build("assemble", options = incremental) { Project("multiprojectWithDependency").build("assemble", options = incremental) {
assertSuccessful() assertSuccessful()
assertReportExists("projA") assertReportExists("projA")
assertContains(":projA:compileKotlin")
assertNotContains("projA:compileKotlin UP-TO-DATE")
assertReportExists("projB") assertReportExists("projB")
assertContains(":projB:compileKotlin") assertTasksExecuted(":projA:compileKotlin", ":projB:compileKotlin")
assertNotContains("projB:compileKotlin UP-TO-DATE")
} }
Project("multiprojectWithDependency").modify { Project("multiprojectWithDependency").apply {
val oldSrc = File(this.projectDir, "projA/src/main/kotlin/a.kt") val oldSrc = File(this.projectDir, "projA/src/main/kotlin/a.kt")
val newSrc = File(this.projectDir, "projA/src/main/kotlin/a.kt.new") val newSrc = File(this.projectDir, "projA/src/main/kotlin/a.kt.new")
assertTrue { oldSrc.exists() } assertTrue { oldSrc.exists() }
@@ -235,11 +227,8 @@ class KotlinGradleIT : BaseGradleIT() {
}.build("assemble", options = incremental) { }.build("assemble", options = incremental) {
assertSuccessful() assertSuccessful()
assertReportExists("projA") assertReportExists("projA")
assertContains(":projA:compileKotlin")
assertNotContains("projA:compileKotlin UP-TO-DATE")
assertReportExists("projB") assertReportExists("projB")
assertContains(":projB:compileKotlin") assertTasksExecuted(":projA:compileKotlin", ":projB:compileKotlin")
assertNotContains("projB:compileKotlin UP-TO-DATE")
} }
} }
@@ -248,7 +237,8 @@ class KotlinGradleIT : BaseGradleIT() {
Project("kotlinInJavaRoot").build("build") { Project("kotlinInJavaRoot").build("build") {
assertSuccessful() assertSuccessful()
assertReportExists() assertReportExists()
assertContains(":compileKotlin", ":compileTestKotlin") assertTasksExecuted(":compileKotlin")
assertContains(":compileTestKotlin NO-SOURCE")
} }
} }
@@ -319,7 +309,7 @@ class KotlinGradleIT : BaseGradleIT() {
project.build("build") { project.build("build") {
assertSuccessful() assertSuccessful()
assertContains(":compileKotlin UP-TO-DATE") assertTasksUpToDate(":compileKotlin")
} }
} }
@@ -470,7 +460,7 @@ class KotlinGradleIT : BaseGradleIT() {
project.build("build", "install") { project.build("build", "install") {
assertSuccessful() assertSuccessful()
assertContains(":compileKotlin", ":compileTestKotlin") assertTasksExecuted(":compileKotlin", ":compileTestKotlin")
val pomLines = File(project.projectDir, "build/poms/pom-default.xml").readLines() val pomLines = File(project.projectDir, "build/poms/pom-default.xml").readLines()
val stdlibVersionLineNumber = pomLines.indexOfFirst { "<artifactId>kotlin-stdlib</artifactId>" in it } + 1 val stdlibVersionLineNumber = pomLines.indexOfFirst { "<artifactId>kotlin-stdlib</artifactId>" in it } + 1
val versionLine = pomLines[stdlibVersionLineNumber] val versionLine = pomLines[stdlibVersionLineNumber]
@@ -15,7 +15,6 @@ class KotlinGradlePluginMultiVersionIT : BaseMultiGradleVersionIT() {
project.build("build") { project.build("build") {
assertSuccessful() assertSuccessful()
assertContains()
assertContainsRegex("""-processorpath \S*.build.tmp.kapt.main.wrappers""".toRegex()) assertContainsRegex("""-processorpath \S*.build.tmp.kapt.main.wrappers""".toRegex())
assertFileExists("build/generated/source/kapt/main/example/TestClassGenerated.java") assertFileExists("build/generated/source/kapt/main/example/TestClassGenerated.java")
assertClassFilesNotContain(File(project.projectDir, "build/classes"), "ExampleSourceAnnotation") assertClassFilesNotContain(File(project.projectDir, "build/classes"), "ExampleSourceAnnotation")
@@ -104,8 +103,7 @@ class KotlinGradlePluginMultiVersionIT : BaseMultiGradleVersionIT() {
} }
project.build("build") { project.build("build") {
assertSuccessful() assertSuccessful()
assertContains(":compileKotlin") assertTasksExecuted(":compileKotlin", ":compileJava")
assertNotContains(":compileJava UP-TO-DATE")
if (expectIncrementalCompilation) if (expectIncrementalCompilation)
assertNotContains("not incremental") else assertNotContains("not incremental") else
assertContains("not incremental") assertContains("not incremental")
@@ -128,7 +126,7 @@ class KotlinGradlePluginMultiVersionIT : BaseMultiGradleVersionIT() {
Project("internalTest", gradleVersion).build("build") { Project("internalTest", gradleVersion).build("build") {
assertSuccessful() assertSuccessful()
assertReportExists() assertReportExists()
assertContains(":compileKotlin", ":compileTestKotlin") assertTasksExecuted(":compileKotlin", ":compileTestKotlin")
} }
} }
@@ -33,7 +33,7 @@ class MultiplatformGradleIT : BaseGradleIT() {
project.build("build") { project.build("build") {
assertSuccessful() assertSuccessful()
assertContains( assertTasksExecuted(
":lib:compileKotlinCommon", ":lib:compileKotlinCommon",
":lib:compileTestKotlinCommon", ":lib:compileTestKotlinCommon",
":libJvm:compileKotlin", ":libJvm:compileKotlin",
@@ -19,16 +19,16 @@ class SimpleKotlinGradleIT : BaseGradleIT() {
fileInWorkingDir("build/reports/tests/classes/demo.TestSource.html").exists() || fileInWorkingDir("build/reports/tests/classes/demo.TestSource.html").exists() ||
fileInWorkingDir("build/reports/tests/test/classes/demo.TestSource.html").exists() fileInWorkingDir("build/reports/tests/test/classes/demo.TestSource.html").exists()
} }
assertContains(":compileKotlin", ":compileTestKotlin", ":compileDeployKotlin") assertTasksExecuted(":compileKotlin", ":compileTestKotlin", ":compileDeployKotlin")
} }
project.build("compileDeployKotlin", "build") { project.build("compileDeployKotlin", "build") {
assertSuccessful() assertSuccessful()
assertContains( assertTasksUpToDate(
":compileKotlin UP-TO-DATE", ":compileKotlin",
":compileTestKotlin UP-TO-DATE", ":compileTestKotlin",
":compileDeployKotlin UP-TO-DATE", ":compileDeployKotlin",
":compileJava UP-TO-DATE" ":compileJava"
) )
} }
} }
@@ -39,7 +39,7 @@ class SimpleKotlinGradleIT : BaseGradleIT() {
project.build("build") { project.build("build") {
assertSuccessful() assertSuccessful()
assertContains(":compileKotlin") assertTasksExecuted(":compileKotlin")
assertNotContains("""w: [^\r\n]*?\.kt""".toRegex()) assertNotContains("""w: [^\r\n]*?\.kt""".toRegex())
} }
} }
@@ -91,14 +91,14 @@ class SimpleKotlinGradleIT : BaseGradleIT() {
assertSuccessful() assertSuccessful()
assertContains("ExampleSubplugin loaded") assertContains("ExampleSubplugin loaded")
assertContains("Project component registration: exampleValue") assertContains("Project component registration: exampleValue")
assertContains(":compileKotlin") assertTasksExecuted(":compileKotlin")
} }
project.build("compileKotlin", "build") { project.build("compileKotlin", "build") {
assertSuccessful() assertSuccessful()
assertContains("ExampleSubplugin loaded") assertContains("ExampleSubplugin loaded")
assertNotContains("Project component registration: exampleValue") assertNotContains("Project component registration: exampleValue")
assertContains(":compileKotlin UP-TO-DATE") assertTasksUpToDate(":compileKotlin")
} }
} }