Migrate KotlinJsLibraryGradlePluginIT tests to new dsl

^KT-45745 In Progress
This commit is contained in:
Yahor Berdnikau
2022-02-22 18:59:19 +01:00
parent 637d45c539
commit d0ee0d8c38
4 changed files with 50 additions and 63 deletions
@@ -5,86 +5,73 @@
package org.jetbrains.kotlin.gradle
import org.gradle.api.logging.LogLevel
import org.gradle.util.GradleVersion
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
import org.jetbrains.kotlin.gradle.util.modify
import org.junit.Test
import org.jetbrains.kotlin.gradle.testbase.*
import org.junit.jupiter.api.DisplayName
import java.util.zip.ZipFile
import kotlin.test.assertNotNull
class KotlinJsIrLibraryGradlePluginIT : BaseGradleIT() {
// TODO: This suite is failing with deprecation error on Gradle <7.0 versions
// Should be fixed via planned fixes in Kotlin/JS plugin: https://youtrack.jetbrains.com/issue/KFC-252
override val defaultGradleVersion: GradleVersionRequired
get() = GradleVersionRequired.AtLeast("7.0")
// TODO: This suite is failing with deprecation error on Gradle <7.0 versions
// Should be fixed via planned fixes in Kotlin/JS plugin: https://youtrack.jetbrains.com/issue/KFC-252
@GradleTestVersions(minVersion = TestVersions.Gradle.G_7_0)
@DisplayName("Kotlin/JS IR library")
@JsGradlePluginTests
class KotlinJsIrLibraryGradlePluginIT : KGPBaseTest() {
override fun defaultBuildOptions(): BuildOptions =
super.defaultBuildOptions().copy(
jsIrBackend = true,
override val defaultBuildOptions = super.defaultBuildOptions.copy(
jsOptions = BuildOptions.JsOptions(
useIrBackend = true,
jsCompilerType = KotlinJsCompilerType.IR
)
)
@Test
fun testSimpleJsBinaryLibrary() {
val project = Project("simple-js-library")
project.setupWorkingDir()
project.gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl)
project.build("build") {
assertSuccessful()
assertFileExists("build/productionLibrary/js-library.js")
assertFileExists("build/productionLibrary/package.json")
assertFileExists("build/productionLibrary/main.js")
@DisplayName("simple binary library")
@GradleTest
fun testSimpleJsBinaryLibrary(gradleVersion: GradleVersion) {
project("simple-js-library", gradleVersion) {
build("build") {
assertFileInProjectExists("build/productionLibrary/js-library.js")
assertFileInProjectExists("build/productionLibrary/package.json")
assertFileInProjectExists("build/productionLibrary/main.js")
}
}
}
@Test
fun testJsBinaryLibraryAndExecutable() {
val project = Project("js-library-with-executable")
project.setupWorkingDir()
project.gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl)
project.build("build") {
assertSuccessful()
assertFileExists("build/productionLibrary/js-library.js")
assertFileExists("build/productionLibrary/package.json")
assertFileExists("build/productionLibrary/main.js")
@DisplayName("binary library and executable")
@GradleTest
fun testJsBinaryLibraryAndExecutable(gradleVersion: GradleVersion) {
project("js-library-with-executable", gradleVersion) {
build("build") {
assertFileInProjectExists("build/productionLibrary/js-library.js")
assertFileInProjectExists("build/productionLibrary/package.json")
assertFileInProjectExists("build/productionLibrary/main.js")
}
}
}
@Test
fun testJsBinaryLibraryAndExecutableForBrowserAndNodejs() {
val project = Project("js-library-with-executable-browser-nodejs")
@DisplayName("binary library and executable both for browser and nodejs")
@GradleTest
fun testJsBinaryLibraryAndExecutableForBrowserAndNodejs(gradleVersion: GradleVersion) {
project("js-library-with-executable-browser-nodejs", gradleVersion) {
build("build") {
assertFileInProjectExists("build/productionLibrary/js-library.js")
assertFileInProjectExists("build/productionLibrary/package.json")
assertFileInProjectExists("build/productionLibrary/main.js")
project.setupWorkingDir()
project.gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl)
project.build("build") {
assertSuccessful()
assertFileExists("build/productionLibrary/js-library.js")
assertFileExists("build/productionLibrary/package.json")
assertFileExists("build/productionLibrary/main.js")
assertFileExists("build/distributions/js-library.js")
assertFileInProjectExists("build/distributions/js-library.js")
}
}
}
@Test
fun testPublishSourcesJarTaskShouldAlsoIncludeDukatTaskOutputs() {
with(
Project(
"js-library-ir",
minLogLevel = LogLevel.INFO
)
) {
setupWorkingDir()
@DisplayName("publish sources jar task should also include dukat outputs")
@GradleTest
fun testPublishSourcesJarTaskShouldAlsoIncludeDukatTaskOutputs(gradleVersion: GradleVersion) {
project("js-library-ir", gradleVersion) {
build("sourcesJar") {
assertSuccessful()
val sourcesJarFilePath = "build/libs/js-library-ir-kotlin-sources.jar"
assertFileExists(sourcesJarFilePath)
ZipFile(projectDir.resolve(sourcesJarFilePath)).use {
assertFileInProjectExists(sourcesJarFilePath)
ZipFile(projectPath.resolve(sourcesJarFilePath).toFile()).use {
assertNotNull(it.getEntry("jsMain/index.module_decamelize.kt"))
}
}
@@ -1,5 +1,5 @@
plugins {
kotlin("js") version "<pluginMarkerVersion>"
kotlin("js")
}
group = "com.example"
@@ -1,5 +1,5 @@
plugins {
kotlin("js") version "<pluginMarkerVersion>"
kotlin("js")
}
group = "com.example"
@@ -1,5 +1,5 @@
plugins {
kotlin("js") version "<pluginMarkerVersion>"
kotlin("js")
}
group = "com.example"