[Gradle, JS] Add configuration cache test for nodejs project

#KT-49808 In Progress
This commit is contained in:
Alexander Likhachev
2021-11-19 17:24:03 +03:00
parent e6ae5db6ef
commit 439f69a20d
3 changed files with 36 additions and 2 deletions
@@ -59,7 +59,7 @@ class Kotlin2JsIrGradlePluginIT : AbstractKotlin2JsGradlePluginIT(true) {
@GradleTest
fun testCleanOutputWithEmptySources(gradleVersion: GradleVersion) {
project("kotlin-js-nodejs-project", gradleVersion) {
build("build") {
build("assemble") {
assertTasksExecuted(":compileProductionExecutableKotlinJs")
assertFileInProjectExists("build/js/packages/kotlin-js-nodejs-project/kotlin/kotlin-js-nodejs-project.js")
@@ -783,7 +783,7 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
gradleProperties.appendText(jsCompilerType(KotlinJsCompilerType.IR))
}
build("build") {
build("assemble") {
assertTasksExecuted(":app:browserProductionWebpack")
assertDirectoryInProjectExists("build/js/packages/kotlin-js-browser-base-js-ir")
@@ -1047,6 +1047,25 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
}
}
@DisplayName("configuration cache is working for kotlin/js node project")
@GradleTest
fun testConfigurationCacheNode(gradleVersion: GradleVersion) {
project("kotlin-js-nodejs-project", gradleVersion) {
assertSimpleConfigurationCacheScenarioWorks(
":build",
buildOptions = defaultBuildOptions.withConfigurationCache,
executedTaskNames = listOf(
":packageJson",
":publicPackageJson",
":rootPackageJson",
":kotlinNpmInstall",
":compileKotlinJs",
":nodeTest",
) + if (irBackend) listOf(":compileProductionExecutableKotlinJs") else emptyList()
)
}
}
private fun TestProject.getSubprojectPackageJson(subProject: String, projectName: String? = null) =
projectPath.resolve("build/js/packages/${projectName ?: projectName}-$subProject")
.resolve(NpmProject.PACKAGE_JSON)
@@ -4,6 +4,7 @@ plugins {
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-js")
testImplementation("org.jetbrains.kotlin:kotlin-test-js")
}
repositories {
@@ -0,0 +1,14 @@
/*
* Copyright 2010-2021 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.assertEquals
class Tests {
@Test
fun testHello() {
assertEquals(73, com.example.simpleBest())
}
}