[Gradle, JS] Remove test with lib and app with not only legace

Because of performance reasons

- Fix usage of compiler type property
This commit is contained in:
Ilya Goncharov
2020-02-18 18:06:28 +03:00
parent 13594c80aa
commit 16eb23c6b1
2 changed files with 23 additions and 98 deletions
@@ -53,7 +53,8 @@ class Kotlin2JsIrGradlePluginIT : AbstractKotlin2JsGradlePluginIT(true) {
gradleBuildScript().appendText( gradleBuildScript().appendText(
"""${"\n"} """${"\n"}
tasks { tasks {
compileProductionKotlinJs { named("compileProductionKotlinJs").configure {
this as org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrLink
type = org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrType.DEVELOPMENT type = org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrType.DEVELOPMENT
} }
} }
@@ -6,7 +6,6 @@ package org.jetbrains.kotlin.gradle
import org.jdom.input.SAXBuilder import org.jdom.input.SAXBuilder
import org.jetbrains.kotlin.gradle.internals.* import org.jetbrains.kotlin.gradle.internals.*
import org.jetbrains.kotlin.gradle.plugin.JsCompilerType
import org.jetbrains.kotlin.gradle.plugin.ProjectLocalConfigurations import org.jetbrains.kotlin.gradle.plugin.ProjectLocalConfigurations
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmWithJavaTargetPreset import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmWithJavaTargetPreset
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin
@@ -66,49 +65,18 @@ class NewMultiplatformIT : BaseGradleIT() {
@Test @Test
fun testLibAndApp() = doTestLibAndApp( fun testLibAndApp() = doTestLibAndApp(
"sample-lib", "sample-lib",
"sample-app", "sample-app"
JsCompilerType.legacy
)
@Test
fun testLibAndAppJsIr() = doTestLibAndApp(
"sample-lib",
"sample-app",
JsCompilerType.ir
)
@Test
fun testLibAndAppJsMixed() = doTestLibAndApp(
"sample-lib",
"sample-app",
JsCompilerType.both
) )
@Test @Test
fun testLibAndAppWithGradleKotlinDsl() = doTestLibAndApp( fun testLibAndAppWithGradleKotlinDsl() = doTestLibAndApp(
"sample-lib-gradle-kotlin-dsl", "sample-lib-gradle-kotlin-dsl",
"sample-app-gradle-kotlin-dsl", "sample-app-gradle-kotlin-dsl"
JsCompilerType.legacy
)
@Test
fun testLibAndAppWithGradleKotlinDslJsIr() = doTestLibAndApp(
"sample-lib-gradle-kotlin-dsl",
"sample-app-gradle-kotlin-dsl",
JsCompilerType.ir
)
@Test
fun testLibAndAppWithGradleKotlinDslJsMixed() = doTestLibAndApp(
"sample-lib-gradle-kotlin-dsl",
"sample-app-gradle-kotlin-dsl",
JsCompilerType.both
) )
private fun doTestLibAndApp( private fun doTestLibAndApp(
libProjectName: String, libProjectName: String,
appProjectName: String, appProjectName: String
jsCompilerType: JsCompilerType
) { ) {
val libProject = transformProjectWithPluginsDsl(libProjectName, directoryPrefix = "new-mpp-lib-and-app") val libProject = transformProjectWithPluginsDsl(libProjectName, directoryPrefix = "new-mpp-lib-and-app")
val appProject = transformProjectWithPluginsDsl(appProjectName, directoryPrefix = "new-mpp-lib-and-app") val appProject = transformProjectWithPluginsDsl(appProjectName, directoryPrefix = "new-mpp-lib-and-app")
@@ -119,15 +87,14 @@ class NewMultiplatformIT : BaseGradleIT() {
with(libProject) { with(libProject) {
build( build(
"publish", "publish"
options = defaultBuildOptions().copy(jsCompilerType = jsCompilerType)
) { ) {
assertSuccessful() assertSuccessful()
assertTasksExecuted(*compileTasksNames.toTypedArray(), ":jvm6Jar", ":nodeJsJar", ":metadataJar") assertTasksExecuted(*compileTasksNames.toTypedArray(), ":jvm6Jar", ":nodeJsJar", ":metadataJar")
val groupDir = projectDir.resolve("repo/com/example") val groupDir = projectDir.resolve("repo/com/example")
val jvmJarName = "sample-lib-jvm6/1.0/sample-lib-jvm6-1.0.jar" val jvmJarName = "sample-lib-jvm6/1.0/sample-lib-jvm6-1.0.jar"
val jsExtension = if (jsCompilerType == JsCompilerType.legacy) "jar" else "klib" val jsExtension = "jar"
val jsJarName = "sample-lib-nodejs/1.0/sample-lib-nodejs-1.0.$jsExtension" val jsJarName = "sample-lib-nodejs/1.0/sample-lib-nodejs-1.0.$jsExtension"
val metadataJarName = "sample-lib-metadata/1.0/sample-lib-metadata-1.0.jar" val metadataJarName = "sample-lib-metadata/1.0/sample-lib-metadata-1.0.jar"
val wasmKlibName = "sample-lib-wasm32/1.0/sample-lib-wasm32-1.0.klib" val wasmKlibName = "sample-lib-wasm32/1.0/sample-lib-wasm32-1.0.klib"
@@ -156,19 +123,12 @@ class NewMultiplatformIT : BaseGradleIT() {
Assert.assertTrue("com/example/lib/CommonKt.class" in jvmJarEntries) Assert.assertTrue("com/example/lib/CommonKt.class" in jvmJarEntries)
Assert.assertTrue("com/example/lib/MainKt.class" in jvmJarEntries) Assert.assertTrue("com/example/lib/MainKt.class" in jvmJarEntries)
when (jsCompilerType) { val jsJar = ZipFile(groupDir.resolve(jsJarName))
JsCompilerType.legacy -> { val compiledJs = jsJar.getInputStream(jsJar.getEntry("sample-lib.js")).reader().readText()
val jsJar = ZipFile(groupDir.resolve(jsJarName)) Assert.assertTrue("function id(" in compiledJs)
val compiledJs = jsJar.getInputStream(jsJar.getEntry("sample-lib.js")).reader().readText() Assert.assertTrue("function idUsage(" in compiledJs)
Assert.assertTrue("function id(" in compiledJs) Assert.assertTrue("function expectedFun(" in compiledJs)
Assert.assertTrue("function idUsage(" in compiledJs) Assert.assertTrue("function main(" in compiledJs)
Assert.assertTrue("function expectedFun(" in compiledJs)
Assert.assertTrue("function main(" in compiledJs)
}
JsCompilerType.ir -> {
groupDir.resolve(jsJarName).exists()
}
}
val metadataJarEntries = ZipFile(groupDir.resolve(metadataJarName)).entries().asSequence().map { it.name }.toSet() val metadataJarEntries = ZipFile(groupDir.resolve(metadataJarName)).entries().asSequence().map { it.name }.toSet()
Assert.assertTrue("com/example/lib/CommonKt.kotlin_metadata" in metadataJarEntries) Assert.assertTrue("com/example/lib/CommonKt.kotlin_metadata" in metadataJarEntries)
@@ -213,11 +173,9 @@ class NewMultiplatformIT : BaseGradleIT() {
Assert.assertTrue(resolve("com/example/app/AKt.kotlin_metadata").exists()) Assert.assertTrue(resolve("com/example/app/AKt.kotlin_metadata").exists())
} }
if (jsCompilerType == JsCompilerType.legacy) { projectDir.resolve(targetClassesDir("nodeJs")).resolve("sample-app.js").readText().run {
projectDir.resolve(targetClassesDir("nodeJs")).resolve("sample-app.js").readText().run { Assert.assertTrue(contains("console.info"))
Assert.assertTrue(contains("console.info")) Assert.assertTrue(contains("function nodeJsMain("))
Assert.assertTrue(contains("function nodeJsMain("))
}
} }
projectDir.resolve(targetClassesDir("wasm32")).run { projectDir.resolve(targetClassesDir("wasm32")).run {
@@ -241,30 +199,12 @@ class NewMultiplatformIT : BaseGradleIT() {
build( build(
"assemble", "assemble",
"resolveRuntimeDependencies", "resolveRuntimeDependencies"
options = defaultBuildOptions().copy(jsCompilerType = jsCompilerType)
) { ) {
checkAppBuild() checkAppBuild()
assertTasksExecuted(":resolveRuntimeDependencies") // KT-26301 assertTasksExecuted(":resolveRuntimeDependencies") // KT-26301
} }
if (jsCompilerType == JsCompilerType.both) {
listOf(
JsCompilerType.legacy,
JsCompilerType.ir
).forEach {
build(
"assemble",
"resolveRuntimeDependencies",
"--rerun-tasks",
options = defaultBuildOptions().copy(jsCompilerType = it)
) {
checkAppBuild()
assertTasksExecuted(":resolveRuntimeDependencies") // KT-26301
}
}
}
// Now run again with a project dependency instead of a module one: // Now run again with a project dependency instead of a module one:
libProject.projectDir.copyRecursively(projectDir.resolve(libProject.projectDir.name)) libProject.projectDir.copyRecursively(projectDir.resolve(libProject.projectDir.name))
gradleSettingsScript().appendText("\ninclude(\"${libProject.projectDir.name}\")") gradleSettingsScript().appendText("\ninclude(\"${libProject.projectDir.name}\")")
@@ -277,15 +217,12 @@ class NewMultiplatformIT : BaseGradleIT() {
build( build(
"clean", "clean",
"assemble", "assemble",
"--rerun-tasks", "--rerun-tasks"
options = defaultBuildOptions().copy(jsCompilerType = jsCompilerType)
) { ) {
checkAppBuild() checkAppBuild()
} }
} }
if (jsCompilerType != JsCompilerType.legacy) return
with(oldStyleAppProject) { with(oldStyleAppProject) {
setupWorkingDir() setupWorkingDir()
gradleBuildScript().appendText("\nallprojects { repositories { maven { url '$libLocalRepoUri' } } }") gradleBuildScript().appendText("\nallprojects { repositories { maven { url '$libLocalRepoUri' } } }")
@@ -899,8 +836,7 @@ class NewMultiplatformIT : BaseGradleIT() {
setupWorkingDir() setupWorkingDir()
projectDir.resolve("settings.gradle").modify { it.replace("enableFeaturePreview", "// enableFeaturePreview") } projectDir.resolve("settings.gradle").modify { it.replace("enableFeaturePreview", "// enableFeaturePreview") }
build( build(
"publish", "publish"
options = defaultBuildOptions().copy(jsCompilerType = JsCompilerType.legacy)
) { assertSuccessful() } ) { assertSuccessful() }
projectDir.resolve("repo") projectDir.resolve("repo")
} }
@@ -2308,15 +2244,10 @@ class NewMultiplatformIT : BaseGradleIT() {
@Test @Test
fun testAssociateCompilations() { fun testAssociateCompilations() {
testAssociateCompilationsImpl(JsCompilerType.legacy) testAssociateCompilationsImpl()
} }
@Test private fun testAssociateCompilationsImpl() {
fun testAssociateCompilationsWithJsIr() {
testAssociateCompilationsImpl(JsCompilerType.ir)
}
private fun testAssociateCompilationsImpl(jsCompilerType: JsCompilerType) {
with(Project("new-mpp-associate-compilations", GradleVersionRequired.AtLeast("5.0"))) { with(Project("new-mpp-associate-compilations", GradleVersionRequired.AtLeast("5.0"))) {
setupWorkingDir() setupWorkingDir()
gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl) gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl)
@@ -2324,10 +2255,7 @@ class NewMultiplatformIT : BaseGradleIT() {
val tasks = listOf("jvm", "js", nativeHostTargetName).map { ":compileIntegrationTestKotlin${it.capitalize()}" } val tasks = listOf("jvm", "js", nativeHostTargetName).map { ":compileIntegrationTestKotlin${it.capitalize()}" }
build( build(
*tasks.toTypedArray(), *tasks.toTypedArray()
options = defaultBuildOptions().copy(
jsCompilerType = jsCompilerType
)
) { ) {
assertSuccessful() assertSuccessful()
assertTasksExecuted(*tasks.toTypedArray()) assertTasksExecuted(*tasks.toTypedArray())
@@ -2342,11 +2270,7 @@ class NewMultiplatformIT : BaseGradleIT() {
// JS: // JS:
assertFileExists( assertFileExists(
if (jsCompilerType == JsCompilerType.ir) { "build/classes/kotlin/js/integrationTest/new-mpp-associate-compilations_integrationTest.js"
"build/classes/kotlin/js/integrationTest/default/manifest"
} else {
"build/classes/kotlin/js/integrationTest/new-mpp-associate-compilations_integrationTest.js"
}
) )
// Native: // Native: