[Gradle, JS] Fix muted JS gradle integration tests

This commit is contained in:
Ilya Goncharov
2023-10-03 12:40:27 +00:00
committed by Space Team
parent f9d117cc9e
commit 68b55181fe
11 changed files with 44 additions and 231 deletions
@@ -42,8 +42,8 @@ class Kotlin2JsIrGradlePluginIT : KGPBaseTest() {
build("build") {
checkIrCompilationMessage()
assertFileInProjectExists("build/kotlin2js/main/lib.js")
val dts = projectPath.resolve("build/kotlin2js/main/lib.d.ts")
assertFileInProjectExists("build/js/packages/kotlin2JsIrDtsGeneration/kotlin/kotlin2JsIrDtsGeneration.js")
val dts = projectPath.resolve("build/js/packages/kotlin2JsIrDtsGeneration/kotlin/kotlin2JsIrDtsGeneration.d.ts")
assertFileExists(dts)
assertFileContains(dts, "function bar(): string")
}
@@ -696,26 +696,6 @@ class Kotlin2JsIrGradlePluginIT : KGPBaseTest() {
assertOutputContains(USING_JS_IR_BACKEND_MESSAGE)
}
@DisplayName("js customized output is included into jar")
@GradleTest
fun testJarIncludesJsOutputSetExplicitly(gradleVersion: GradleVersion) {
project("kotlin2JsModuleKind", gradleVersion) {
build(":jar") {
checkIrCompilationMessage()
assertTasksExecuted(":compileKotlin2Js")
val jarPath = projectPath.resolve("build/libs/kotlin2JsModuleKind.jar")
assertFileExists(jarPath)
ZipFile(jarPath.toFile()).use { jar ->
assertEquals(
1, jar.entries().asSequence().count { it.name == "app.js" },
"The jar should contain an entry `app.js` with no duplicates"
)
}
}
}
}
@DisplayName("test compilation can access main compilation")
@GradleTest
fun testCompileTestCouldAccessProduction(gradleVersion: GradleVersion) {
@@ -724,12 +704,12 @@ class Kotlin2JsIrGradlePluginIT : KGPBaseTest() {
checkIrCompilationMessage()
assertTasksExecuted(
":compileKotlin2Js",
":compileTestKotlin2Js"
":compileKotlinJs",
":compileTestKotlinJs"
)
assertFileInProjectExists("build/kotlin2js/main/default/manifest")
assertFileInProjectExists("build/classes/kotlin/main/default/manifest")
assertFileInProjectExists("build/kotlin2js/test/module-tests.js")
assertFileInProjectExists("build/js/packages/kotlin2JsProjectWithTests-test/kotlin/kotlin2JsProjectWithTests-test.js")
}
}
}
@@ -1,30 +0,0 @@
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
plugins {
id 'java'
}
apply plugin: 'org.jetbrains.kotlin.platform.js'
def outDir = "${buildDir}/kotlin2js/main/"
compileKotlin2Js.kotlinOptions.moduleKind = "plain"
compileKotlin2Js.kotlinOptions.outputFile = outDir + "lib.js"
compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js", "-Xgenerate-dts"]
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
}
@@ -0,0 +1,16 @@
plugins {
kotlin("js")
}
repositories {
mavenLocal()
mavenCentral()
}
kotlin {
js {
nodejs()
binaries.executable()
generateTypeScriptDefinitions()
}
}
@@ -1,31 +0,0 @@
(function(global) {
var modules = {};
// Hard-code expected dependency order since we are unable to refer to modules by filename here.
var names = ["kotlin", "app", "check"];
function define(name, dependencies, body) {
if (Array.isArray(name)) {
body = dependencies;
dependencies = name;
name = names.shift();
}
else {
if (name !== names.shift()) throw new Error("Unexpected dependency")
}
var resolvedDependencies = [];
var currentModule = {};
modules[name] = currentModule;
for (var i = 0; i < dependencies.length; ++i) {
var dependencyName = dependencies[i];
resolvedDependencies[i] = dependencyName === 'exports' ? currentModule : modules[dependencyName];
}
currentModule = body.apply(body, resolvedDependencies);
if (currentModule) {
modules[name] = currentModule;
}
}
define.amd = {};
global.define = define;
})(this);
@@ -1,61 +0,0 @@
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
plugins {
id 'java'
}
apply plugin: 'org.jetbrains.kotlin.platform.js'
def outDir = "${buildDir}/kotlin2js/main/"
compileKotlin2Js.kotlinOptions.moduleKind = "amd"
compileKotlin2Js.kotlinOptions.outputFile = outDir + "app.js"
compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"]
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
implementation "org.mozilla:rhino:1.7.7.1"
}
tasks.register("runRhino", JavaExec) {
classpath = sourceSets.main.runtimeClasspath
workingDir = "${buildDir}/kotlin2js/main/"
mainClass = 'org.mozilla.javascript.tools.shell.Main'
args = ["-opt", "-1", "-f", "amd.js", "-f", "kotlin.js", "-f", "app.js", "-f", "check.js"]
}
build.doLast {
configurations.compileClasspath.each { File file ->
copy {
includeEmptyDirs = false
from zipTree(file.absolutePath)
into "${buildDir}/kotlin2js/main/"
include { fileTreeElement ->
def path = fileTreeElement.path
path.endsWith(".js") && (path.startsWith("META-INF/resources/") || !path.startsWith("META-INF/"))
}
}
}
copy {
from "."
include "amd.js"
include "check.js"
into "${buildDir}/kotlin2js/main/"
}
}
runRhino.dependsOn build
@@ -1,21 +0,0 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
define("check", ["app"], function(app) {
if (app.foo.bar() != "OK") {
throw new Error("Unexpected result");
}
});
@@ -1 +0,0 @@
kotlin.internal.mpp12x.deprecation.suppress=true
@@ -1,20 +0,0 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package foo
@JsExport
fun bar() = "OK"
@@ -1,35 +0,0 @@
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'org.jetbrains.kotlin.platform.js'
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
testImplementation"org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
}
tasks.register("jarSources", Jar) {
from sourceSets.main.allSource
archiveClassifier = 'source'
}
artifacts {
implementation jarSources
}
compileTestKotlin2Js.kotlinOptions.outputFile = "${buildDir}/kotlin2js/test/module-tests.js"
compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir", "-Xir-only"]
compileTestKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"]
compileKotlin2Js.kotlinOptions.outputFile = "${buildDir}/kotlin2js/main/"
@@ -0,0 +1,21 @@
plugins {
kotlin("js")
}
repositories {
mavenLocal()
mavenCentral()
}
val kotlin_version: String by extra
dependencies {
testImplementation("org.jetbrains.kotlin:kotlin-test-js:$kotlin_version")
}
kotlin {
js {
binaries.executable()
nodejs()
}
}
+1 -6
View File
@@ -96,9 +96,4 @@ org.jetbrains.kotlin.jps.build.IncrementalK2LightTreeJvmJpsTestGenerated.Increme
org.jetbrains.kotlin.jps.build.IncrementalK2FirICLightTreeJvmJpsTestGenerated.IncrementalJvmCompilerOnly.testAddAnnotationToJavaClass, KT-55696,,
org.jetbrains.kotlin.jps.build.IncrementalK2JvmJpsTestGenerated.PureKotlin.testAllConstants, test should be changed and fixed in next commits - KT-54991,,
org.jetbrains.kotlin.jps.build.IncrementalK2LightTreeJvmJpsTestGenerated.PureKotlin.testAllConstants, test should be changed and fixed in next commits - KT-54991,,
org.jetbrains.kotlin.jps.build.IncrementalK2FirICLightTreeJvmJpsTestGenerated.PureKotlin.testAllConstants, test should be changed and fixed in next commits - KT-54991,,
org.jetbrains.kotlin.gradle.Kotlin2JsIrGradlePluginIT.generateDts, org.jetbrains.kotlin.platform.js legacy plugin,,
org.jetbrains.kotlin.gradle.Kotlin2JsIrGradlePluginIT.testJarIncludesJsOutputSetExplicitly, org.jetbrains.kotlin.platform.js legacy plugin,,
org.jetbrains.kotlin.gradle.Kotlin2JsIrGradlePluginIT.testCompileTestCouldAccessProduction, org.jetbrains.kotlin.platform.js legacy plugin,,
org.jetbrains.kotlin.gradle.Kotlin2JsGradlePluginIT.testJarIncludesJsOutputSetExplicitly, org.jetbrains.kotlin.platform.js legacy plugin,,
org.jetbrains.kotlin.gradle.Kotlin2JsGradlePluginIT.testCompileTestCouldAccessProduction, org.jetbrains.kotlin.platform.js legacy plugin,,
org.jetbrains.kotlin.jps.build.IncrementalK2FirICLightTreeJvmJpsTestGenerated.PureKotlin.testAllConstants, test should be changed and fixed in next commits - KT-54991,,
1 Test key Issue State (optional: MUTE or FAIL) Status (optional: FLAKY)
96 org.jetbrains.kotlin.jps.build.IncrementalK2FirICLightTreeJvmJpsTestGenerated.IncrementalJvmCompilerOnly.testAddAnnotationToJavaClass KT-55696
97 org.jetbrains.kotlin.jps.build.IncrementalK2JvmJpsTestGenerated.PureKotlin.testAllConstants test should be changed and fixed in next commits - KT-54991
98 org.jetbrains.kotlin.jps.build.IncrementalK2LightTreeJvmJpsTestGenerated.PureKotlin.testAllConstants test should be changed and fixed in next commits - KT-54991
99 org.jetbrains.kotlin.jps.build.IncrementalK2FirICLightTreeJvmJpsTestGenerated.PureKotlin.testAllConstants test should be changed and fixed in next commits - KT-54991
org.jetbrains.kotlin.gradle.Kotlin2JsIrGradlePluginIT.generateDts org.jetbrains.kotlin.platform.js legacy plugin
org.jetbrains.kotlin.gradle.Kotlin2JsIrGradlePluginIT.testJarIncludesJsOutputSetExplicitly org.jetbrains.kotlin.platform.js legacy plugin
org.jetbrains.kotlin.gradle.Kotlin2JsIrGradlePluginIT.testCompileTestCouldAccessProduction org.jetbrains.kotlin.platform.js legacy plugin
org.jetbrains.kotlin.gradle.Kotlin2JsGradlePluginIT.testJarIncludesJsOutputSetExplicitly org.jetbrains.kotlin.platform.js legacy plugin
org.jetbrains.kotlin.gradle.Kotlin2JsGradlePluginIT.testCompileTestCouldAccessProduction org.jetbrains.kotlin.platform.js legacy plugin