Skip to content

Commit

Permalink
Fix JS tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tschuchortdev committed May 26, 2024
1 parent f238179 commit fd3fa71
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
21 changes: 19 additions & 2 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,35 @@ buildConfig {
}
}

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

configurations.all {
resolutionStrategy.dependencySubstitution {
substitute(module("org.jetbrains.kotlin:kotlin-stdlib-js"))
.using variant(module("org.jetbrains.kotlin:kotlin-stdlib-js:$embedded_kotlin_version")) {
attributes {
attribute(Attribute.of("org.jetbrains.kotlin.platform.type", KotlinPlatformType.class), KotlinPlatformType.js)
attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage, "kotlin-runtime"))
attribute(Attribute.of("org.jetbrains.kotlin.js.compiler", String), "ir")
}
}
}
}

dependencies {
compileOnly 'com.google.auto.service:auto-service:1.1.1'
kapt "com.google.auto.service:auto-service:1.1.1"
Expand All @@ -44,7 +61,7 @@ dependencies {
// running compiler plugins passed via the pluginClasspath CLI option works
testRuntimeOnly "org.jetbrains.kotlin:kotlin-scripting-compiler:$embedded_kotlin_version"

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class CompilerPluginsTest {
Assertions.assertThat(result.exitCode).isEqualTo(KotlinCompilation.ExitCode.OK)
}

@Disabled("JS tests don't currently work with the new compiler IR")
//@Disabled("JS tests don't currently work with the new compiler IR")
@Test
fun `when JS compiler plugins are added they get executed`() {
val mockLegacyPlugin = Mockito.mock(ComponentRegistrar::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import kotlin.io.path.createDirectory
import kotlin.io.path.createFile
import kotlin.io.path.writeText

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

Expand Down

0 comments on commit fd3fa71

Please sign in to comment.