[Gradle, JS] Fix WorkersIT tests
This commit is contained in:
+27
-4
@@ -5,23 +5,45 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.gradle
|
package org.jetbrains.kotlin.gradle
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.JsMode
|
||||||
|
import org.jetbrains.kotlin.gradle.util.jsMode
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
class WorkersIT : BaseGradleIT() {
|
class WorkersIT : BaseGradleIT() {
|
||||||
@Test
|
@Test
|
||||||
fun testParallelTasks() {
|
fun testParallelTasks() {
|
||||||
parallelTasksImpl(isParallel = true)
|
parallelTasksImpl(
|
||||||
|
isParallel = true,
|
||||||
|
jsIr = true
|
||||||
|
)
|
||||||
|
parallelTasksImpl(
|
||||||
|
isParallel = true,
|
||||||
|
jsIr = false
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testNoParallelTasks() {
|
fun testNoParallelTasks() {
|
||||||
parallelTasksImpl(isParallel = false)
|
parallelTasksImpl(
|
||||||
|
isParallel = false,
|
||||||
|
jsIr = true
|
||||||
|
)
|
||||||
|
parallelTasksImpl(
|
||||||
|
isParallel = false,
|
||||||
|
jsIr = false
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parallelTasksImpl(isParallel: Boolean) =
|
private fun parallelTasksImpl(
|
||||||
|
isParallel: Boolean,
|
||||||
|
jsIr: Boolean
|
||||||
|
) =
|
||||||
with(Project("new-mpp-parallel")) {
|
with(Project("new-mpp-parallel")) {
|
||||||
val options = defaultBuildOptions().copy(parallelTasksInProject = isParallel, withDaemon = false)
|
val options = defaultBuildOptions().copy(parallelTasksInProject = isParallel, withDaemon = false)
|
||||||
val traceLoading = "-Dorg.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.trace.loading=true"
|
val traceLoading = "-Dorg.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.trace.loading=true"
|
||||||
|
if (!jsIr) {
|
||||||
|
gradleProperties().appendText(jsMode(JsMode.LEGACY))
|
||||||
|
}
|
||||||
build("assemble", traceLoading, options = options) {
|
build("assemble", traceLoading, options = options) {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
val tasks = arrayOf(":compileKotlinMetadata", ":compileKotlinJvm", ":compileKotlinJs")
|
val tasks = arrayOf(":compileKotlinMetadata", ":compileKotlinJvm", ":compileKotlinJs")
|
||||||
@@ -33,7 +55,8 @@ class WorkersIT : BaseGradleIT() {
|
|||||||
val expectedKotlinOutputFiles = listOf(
|
val expectedKotlinOutputFiles = listOf(
|
||||||
kotlinClassesDir(sourceSet = "metadata/main") + "common/A.kotlin_metadata",
|
kotlinClassesDir(sourceSet = "metadata/main") + "common/A.kotlin_metadata",
|
||||||
kotlinClassesDir(sourceSet = "jvm/main") + "common/A.class",
|
kotlinClassesDir(sourceSet = "jvm/main") + "common/A.class",
|
||||||
kotlinClassesDir(sourceSet = "js/main") + "new-mpp-parallel.js"
|
kotlinClassesDir(sourceSet = "js/main") +
|
||||||
|
if (jsIr) "manifest" else "new-mpp-parallel.js"
|
||||||
)
|
)
|
||||||
expectedKotlinOutputFiles.forEach { assertFileExists(it) }
|
expectedKotlinOutputFiles.forEach { assertFileExists(it) }
|
||||||
assertSubstringCount("Loaded GradleKotlinCompilerWork", 1)
|
assertSubstringCount("Loaded GradleKotlinCompilerWork", 1)
|
||||||
|
|||||||
-1
@@ -355,7 +355,6 @@ internal class KotlinJsIrSourceSetProcessor(
|
|||||||
return tasksProvider.registerKotlinJsIrTask(
|
return tasksProvider.registerKotlinJsIrTask(
|
||||||
project,
|
project,
|
||||||
taskName,
|
taskName,
|
||||||
KotlinJsIrLink::class.java,
|
|
||||||
kotlinCompilation
|
kotlinCompilation
|
||||||
) { task ->
|
) { task ->
|
||||||
task.type = type
|
task.type = type
|
||||||
|
|||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.gradle.targets.js.ir
|
||||||
|
|
||||||
|
import org.gradle.api.tasks.CacheableTask
|
||||||
|
import org.gradle.workers.WorkerExecutor
|
||||||
|
import org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@CacheableTask
|
||||||
|
internal open class KotlinJsIrLinkWithWorkers
|
||||||
|
@Inject
|
||||||
|
constructor(
|
||||||
|
private val workerExecutor: WorkerExecutor
|
||||||
|
) : KotlinJsIrLink() {
|
||||||
|
override fun compilerRunner() = GradleCompilerRunnerWithWorkers(this, workerExecutor)
|
||||||
|
}
|
||||||
+2
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile
|
|||||||
import org.jetbrains.kotlin.gradle.utils.newFileProperty
|
import org.jetbrains.kotlin.gradle.utils.newFileProperty
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
|
@CacheableTask
|
||||||
open class KotlinJsIrLink : Kotlin2JsCompile() {
|
open class KotlinJsIrLink : Kotlin2JsCompile() {
|
||||||
@Input
|
@Input
|
||||||
lateinit var type: KotlinJsIrType
|
lateinit var type: KotlinJsIrType
|
||||||
@@ -25,6 +26,7 @@ open class KotlinJsIrLink : Kotlin2JsCompile() {
|
|||||||
|
|
||||||
@get:SkipWhenEmpty
|
@get:SkipWhenEmpty
|
||||||
@get:InputDirectory
|
@get:InputDirectory
|
||||||
|
@get:PathSensitive(PathSensitivity.RELATIVE)
|
||||||
val entryModule: File
|
val entryModule: File
|
||||||
get() = File(
|
get() = File(
|
||||||
(taskData.compilation as KotlinJsIrCompilation)
|
(taskData.compilation as KotlinJsIrCompilation)
|
||||||
|
|||||||
+6
-4
@@ -25,6 +25,8 @@ import org.jetbrains.kotlin.gradle.plugin.mapKotlinTaskProperties
|
|||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.AbstractKotlinCompilation
|
import org.jetbrains.kotlin.gradle.plugin.mpp.AbstractKotlinCompilation
|
||||||
import org.jetbrains.kotlin.gradle.plugin.runOnceAfterEvaluated
|
import org.jetbrains.kotlin.gradle.plugin.runOnceAfterEvaluated
|
||||||
import org.jetbrains.kotlin.gradle.plugin.sources.applyLanguageSettingsToKotlinOptions
|
import org.jetbrains.kotlin.gradle.plugin.sources.applyLanguageSettingsToKotlinOptions
|
||||||
|
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrLink
|
||||||
|
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrLinkWithWorkers
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers the task with [name] and [type] and initialization script [body]
|
* Registers the task with [name] and [type] and initialization script [body]
|
||||||
@@ -100,14 +102,14 @@ internal open class KotlinTasksProvider(val targetName: String) {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T : Kotlin2JsCompile> registerKotlinJsIrTask(
|
fun registerKotlinJsIrTask(
|
||||||
project: Project,
|
project: Project,
|
||||||
name: String,
|
name: String,
|
||||||
taskClass: Class<out T>,
|
|
||||||
compilation: AbstractKotlinCompilation<*>,
|
compilation: AbstractKotlinCompilation<*>,
|
||||||
configureAction: (T) -> Unit
|
configureAction: (KotlinJsIrLink) -> Unit
|
||||||
): TaskProvider<out T> {
|
): TaskProvider<out KotlinJsIrLink> {
|
||||||
val properties = PropertiesProvider(project)
|
val properties = PropertiesProvider(project)
|
||||||
|
val taskClass = taskOrWorkersTask<KotlinJsIrLink, KotlinJsIrLinkWithWorkers>(properties)
|
||||||
val result = project.registerTask(name, taskClass) {
|
val result = project.registerTask(name, taskClass) {
|
||||||
configureAction(it)
|
configureAction(it)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user