[Gradle, JS] KT-36784 Move test only to IR
#KT-32466 fixed #KT-36784 fixed #KT-36864 fixed
This commit is contained in:
+39
-41
@@ -74,6 +74,45 @@ class Kotlin2JsIrGradlePluginIT : AbstractKotlin2JsGradlePluginIT(true) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testJsCompositeBuild() {
|
||||||
|
val rootProjectName = "js-composite-build"
|
||||||
|
val appProject = transformProjectWithPluginsDsl(
|
||||||
|
projectName = "app",
|
||||||
|
directoryPrefix = rootProjectName,
|
||||||
|
wrapperVersion = GradleVersionRequired.AtLeast("5.3")
|
||||||
|
)
|
||||||
|
|
||||||
|
val libProject = transformProjectWithPluginsDsl(
|
||||||
|
projectName = "lib",
|
||||||
|
directoryPrefix = rootProjectName,
|
||||||
|
wrapperVersion = GradleVersionRequired.AtLeast("5.3")
|
||||||
|
)
|
||||||
|
|
||||||
|
libProject.gradleProperties().appendText(jsCompilerType(KotlinJsCompilerType.IR))
|
||||||
|
appProject.gradleProperties().appendText(jsCompilerType(KotlinJsCompilerType.IR))
|
||||||
|
|
||||||
|
libProject.projectDir.copyRecursively(appProject.projectDir.resolve(libProject.projectDir.name))
|
||||||
|
|
||||||
|
fun Project.asyncVersion(rootModulePath: String, moduleName: String): String =
|
||||||
|
NpmProjectModules(projectDir.resolve(rootModulePath))
|
||||||
|
.require(moduleName)
|
||||||
|
.let { File(it).parentFile.parentFile.resolve(NpmProject.PACKAGE_JSON) }
|
||||||
|
.let { fromSrcPackageJson(it) }
|
||||||
|
.let { it!!.version }
|
||||||
|
|
||||||
|
with(appProject) {
|
||||||
|
build("build") {
|
||||||
|
assertSuccessful()
|
||||||
|
val appAsyncVersion = asyncVersion("build/js/node_modules/app", "async")
|
||||||
|
assertEquals("3.2.0", appAsyncVersion)
|
||||||
|
|
||||||
|
val libAsyncVersion = asyncVersion("build/js/node_modules/lib2", "async")
|
||||||
|
assertEquals("2.6.2", libAsyncVersion)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Kotlin2JsGradlePluginIT : AbstractKotlin2JsGradlePluginIT(false) {
|
class Kotlin2JsGradlePluginIT : AbstractKotlin2JsGradlePluginIT(false) {
|
||||||
@@ -551,47 +590,6 @@ abstract class AbstractKotlin2JsGradlePluginIT(private val irBackend: Boolean) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
fun testJsCompositeBuild() {
|
|
||||||
val rootProjectName = "js-composite-build"
|
|
||||||
val appProject = transformProjectWithPluginsDsl(
|
|
||||||
projectName = "app",
|
|
||||||
directoryPrefix = rootProjectName,
|
|
||||||
wrapperVersion = GradleVersionRequired.AtLeast("5.3")
|
|
||||||
)
|
|
||||||
|
|
||||||
val libProject = transformProjectWithPluginsDsl(
|
|
||||||
projectName = "lib",
|
|
||||||
directoryPrefix = rootProjectName,
|
|
||||||
wrapperVersion = GradleVersionRequired.AtLeast("5.3")
|
|
||||||
)
|
|
||||||
|
|
||||||
if (irBackend) {
|
|
||||||
libProject.gradleProperties().appendText(jsCompilerType(KotlinJsCompilerType.IR))
|
|
||||||
appProject.gradleProperties().appendText(jsCompilerType(KotlinJsCompilerType.IR))
|
|
||||||
}
|
|
||||||
|
|
||||||
libProject.projectDir.copyRecursively(appProject.projectDir.resolve(libProject.projectDir.name))
|
|
||||||
|
|
||||||
fun Project.asyncVersion(rootModulePath: String, moduleName: String): String =
|
|
||||||
NpmProjectModules(projectDir.resolve(rootModulePath))
|
|
||||||
.require(moduleName)
|
|
||||||
.let { File(it).parentFile.parentFile.resolve(NpmProject.PACKAGE_JSON) }
|
|
||||||
.let { fromSrcPackageJson(it) }
|
|
||||||
.let { it!!.version }
|
|
||||||
|
|
||||||
with(appProject) {
|
|
||||||
build("build", "browserDevelopmentWebpack") {
|
|
||||||
assertSuccessful()
|
|
||||||
val appAsyncVersion = asyncVersion("build/js/node_modules/app", "async")
|
|
||||||
assertEquals("3.2.0", appAsyncVersion)
|
|
||||||
|
|
||||||
val libAsyncVersion = asyncVersion("build/js/node_modules/lib2", "async")
|
|
||||||
assertEquals("2.6.2", libAsyncVersion)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testBrowserDistribution() = with(Project("kotlin-js-browser-project", GradleVersionRequired.AtLeast("5.0"))) {
|
fun testBrowserDistribution() = with(Project("kotlin-js-browser-project", GradleVersionRequired.AtLeast("5.0"))) {
|
||||||
setupWorkingDir()
|
setupWorkingDir()
|
||||||
|
|||||||
+2
-5
@@ -10,11 +10,7 @@ repositories {
|
|||||||
|
|
||||||
kotlin.js {
|
kotlin.js {
|
||||||
binaries.executable()
|
binaries.executable()
|
||||||
browser()
|
nodejs()
|
||||||
}
|
|
||||||
|
|
||||||
tasks.named("browserTest").configure {
|
|
||||||
enabled = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rootProject.tasks
|
rootProject.tasks
|
||||||
@@ -35,4 +31,5 @@ dependencies {
|
|||||||
implementation(kotlin("stdlib-js"))
|
implementation(kotlin("stdlib-js"))
|
||||||
implementation("com.example:lib2")
|
implementation("com.example:lib2")
|
||||||
implementation(npm("async", "3.2.0"))
|
implementation(npm("async", "3.2.0"))
|
||||||
|
testImplementation(kotlin("test-js"))
|
||||||
}
|
}
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
import kotlin.test.Test
|
||||||
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
|
class SimpleTest {
|
||||||
|
@Test
|
||||||
|
fun simpleTest() {
|
||||||
|
assertTrue {
|
||||||
|
Singleton.test() is Long
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-5
@@ -10,11 +10,7 @@ repositories {
|
|||||||
mavenLocal()
|
mavenLocal()
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin.target.browser()
|
kotlin.target.nodejs()
|
||||||
|
|
||||||
tasks.named("browserTest").configure {
|
|
||||||
enabled = false
|
|
||||||
}
|
|
||||||
|
|
||||||
rootProject.tasks
|
rootProject.tasks
|
||||||
.withType(org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask::class.java)
|
.withType(org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask::class.java)
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
object Singleton {
|
object Singleton {
|
||||||
fun test(): String {
|
fun test(): Long {
|
||||||
return "42"
|
return 42L
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user