Add tests for separate classes dirs

(cherry picked from commit b07d79b)
This commit is contained in:
Sergey Igushkin
2017-06-25 21:47:27 +03:00
parent 700b162233
commit 351f810797
2 changed files with 35 additions and 0 deletions
@@ -225,4 +225,14 @@ class Kotlin2JsGradlePluginIT : BaseGradleIT() {
assertSuccessful()
}
}
/** Issue: KT-18495 */
@Test
fun testNoSeparateClassesDirWarning() {
val project = Project("kotlin2JsProject", "4.0")
project.build("build") {
assertSuccessful()
assertNotContains("this build assumes a single directory for all classes from a source set")
}
}
}
@@ -24,6 +24,8 @@ import org.jetbrains.kotlin.gradle.util.getFilesByNames
import org.jetbrains.kotlin.gradle.util.modify
import org.junit.Test
import java.io.File
import java.util.zip.ZipFile
import kotlin.test.assertEquals
import kotlin.test.assertNotEquals
import kotlin.test.assertTrue
@@ -542,4 +544,27 @@ class KotlinGradleIT: BaseGradleIT() {
assertContains("-api-version 1.1")
}
}
@Test
fun testSeparateOutputGradle40() {
val project = Project("kotlinJavaProject", "4.0")
project.build("compileDeployKotlin", "assemble") {
assertSuccessful()
// Check that the Kotlin classes are placed under directories following the guideline:
assertFileExists("build/classes/kotlin/main/demo/KotlinGreetingJoiner.class")
assertFileExists("build/classes/kotlin/deploy/demo/ExampleSource.class")
// Check that the resulting JAR contains the Kotlin classes, without duplicates:
val jar = ZipFile(fileInWorkingDir("build/libs/${project.projectName}.jar"))
assertEquals(1, jar.entries().asSequence().count { it.name == "demo/KotlinGreetingJoiner.class" })
// Check that the Java output is intact:
assertFileExists("build/classes/java/main/demo/Greeter.class")
// Check that the sync output task is not used with Gradle 4.0+ and there's no old Kotlin output layout
assertNotContains(":copyMainKotlinClasses")
assertNoSuchFile("build/kotlin-classes")
}
}
}