Skip to content

Commit fd3fa71

Browse files
committed
Fix JS tests
1 parent f238179 commit fd3fa71

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

core/build.gradle

+19-2
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,35 @@ buildConfig {
1717
}
1818
}
1919

20+
/* Multiple variants are offered of the dependencies kotlin-dom-api-compat and kotlin-stdlib-js. Usually, Gradle picks
21+
* them automatically based on what kind of build it is, i.e. it would look for a platform JVM variant for this JVM build.
22+
* Naturally, there is no JVM version for JS libraries. We need to fix the variant attributes manually so the right variant
23+
* will be picked for runtime use in the JS compile tests. */
2024
configurations.all {
2125
resolutionStrategy.dependencySubstitution {
2226
substitute(module("org.jetbrains.kotlin:kotlin-dom-api-compat"))
2327
.using variant(module("org.jetbrains.kotlin:kotlin-dom-api-compat:$embedded_kotlin_version")) {
2428
attributes {
25-
attribute(KotlinPlatformType.attribute, KotlinPlatformType.js)
29+
attribute(Attribute.of("org.jetbrains.kotlin.platform.type", KotlinPlatformType.class), KotlinPlatformType.js)
2630
attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage, "kotlin-runtime"))
2731
}
2832
}
2933
}
3034
}
3135

36+
configurations.all {
37+
resolutionStrategy.dependencySubstitution {
38+
substitute(module("org.jetbrains.kotlin:kotlin-stdlib-js"))
39+
.using variant(module("org.jetbrains.kotlin:kotlin-stdlib-js:$embedded_kotlin_version")) {
40+
attributes {
41+
attribute(Attribute.of("org.jetbrains.kotlin.platform.type", KotlinPlatformType.class), KotlinPlatformType.js)
42+
attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage, "kotlin-runtime"))
43+
attribute(Attribute.of("org.jetbrains.kotlin.js.compiler", String), "ir")
44+
}
45+
}
46+
}
47+
}
48+
3249
dependencies {
3350
compileOnly 'com.google.auto.service:auto-service:1.1.1'
3451
kapt "com.google.auto.service:auto-service:1.1.1"
@@ -44,7 +61,7 @@ dependencies {
4461
// running compiler plugins passed via the pluginClasspath CLI option works
4562
testRuntimeOnly "org.jetbrains.kotlin:kotlin-scripting-compiler:$embedded_kotlin_version"
4663

47-
// Include Kotlin/JS standard library in test classpath for auto loading
64+
// Include Kotlin/JS standard library in test classpath for auto loading
4865
testRuntimeOnly "org.jetbrains.kotlin:kotlin-stdlib-js"
4966
testRuntimeOnly "org.jetbrains.kotlin:kotlin-dom-api-compat"
5067

core/src/test/kotlin/com/tschuchort/compiletesting/CompilerPluginsTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class CompilerPluginsTest {
8787
Assertions.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.OK)
8888
}
8989

90-
@Disabled("JS tests don't currently work with the new compiler IR")
90+
//@Disabled("JS tests don't currently work with the new compiler IR")
9191
@Test
9292
fun `when JS compiler plugins are added they get executed`() {
9393
val mockLegacyPlugin = Mockito.mock(ComponentRegistrar::class.java)

core/src/test/kotlin/com/tschuchort/compiletesting/KotlinJsCompilationTests.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import kotlin.io.path.createDirectory
1616
import kotlin.io.path.createFile
1717
import kotlin.io.path.writeText
1818

19-
@Disabled("These JS tests don't currently work with the new compiler IR")
19+
//@Disabled("These JS tests don't currently work with the new compiler IR")
2020
@Suppress("MemberVisibilityCanBePrivate")
2121
class KotlinJsCompilationTests {
2222

0 commit comments

Comments
 (0)