[BTA tests] Finish project compilation after a test
^KT-61860 In Progress
This commit is contained in:
committed by
Space Team
parent
a234e4149b
commit
566d9852a3
+3
-5
@@ -36,8 +36,6 @@ class JvmModule(
|
||||
dependencies,
|
||||
additionalCompilationArguments,
|
||||
) {
|
||||
private val compilationService = CompilationService.loadImplementation(this.javaClass.classLoader)
|
||||
|
||||
override fun compileImpl(
|
||||
strategyConfig: CompilerExecutionStrategyConfiguration,
|
||||
compilationConfigAction: (JvmCompilationConfiguration) -> Unit,
|
||||
@@ -46,7 +44,7 @@ class JvmModule(
|
||||
val stdlibLocation =
|
||||
KotlinVersion::class.java.protectionDomain.codeSource.location.toURI().toPath() // compile against the provided stdlib
|
||||
val dependencyFiles = dependencies.map { it.location }.plusElement(stdlibLocation)
|
||||
val compilationConfig = compilationService.makeJvmCompilationConfiguration()
|
||||
val compilationConfig = project.compilationService.makeJvmCompilationConfiguration()
|
||||
compilationConfigAction(compilationConfig)
|
||||
compilationConfig.useLogger(kotlinLogger)
|
||||
val defaultCompilationArguments = listOf(
|
||||
@@ -56,7 +54,7 @@ class JvmModule(
|
||||
"-cp", dependencyFiles.joinToString(File.pathSeparator),
|
||||
"-module-name", moduleName,
|
||||
)
|
||||
return compilationService.compileJvm(
|
||||
return project.compilationService.compileJvm(
|
||||
project.projectId,
|
||||
strategyConfig,
|
||||
compilationConfig,
|
||||
@@ -67,7 +65,7 @@ class JvmModule(
|
||||
|
||||
private fun generateClasspathSnapshot(dependency: Dependency): Path {
|
||||
val snapshot =
|
||||
compilationService.calculateClasspathSnapshot(dependency.location.toFile(), ClassSnapshotGranularity.CLASS_MEMBER_LEVEL)
|
||||
project.compilationService.calculateClasspathSnapshot(dependency.location.toFile(), ClassSnapshotGranularity.CLASS_MEMBER_LEVEL)
|
||||
val hash = snapshot.classSnapshots.values
|
||||
.filterIsInstance<AccessibleClassSnapshot>()
|
||||
.withIndex()
|
||||
|
||||
+10
-1
@@ -5,6 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.buildtools.api.tests.compilation.model
|
||||
|
||||
import org.jetbrains.kotlin.buildtools.api.CompilationService
|
||||
import org.jetbrains.kotlin.buildtools.api.ProjectId
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
@@ -17,6 +18,7 @@ class Project(
|
||||
val projectDirectory: Path,
|
||||
) {
|
||||
val projectId = ProjectId.ProjectUUID(UUID.randomUUID())
|
||||
val compilationService = CompilationService.loadImplementation(this.javaClass.classLoader)
|
||||
|
||||
fun module(
|
||||
moduleName: String,
|
||||
@@ -33,8 +35,15 @@ class Project(
|
||||
templatePath.copyToRecursively(module.sourcesDirectory, followLinks = false)
|
||||
return module
|
||||
}
|
||||
|
||||
fun endCompilationRound() {
|
||||
compilationService.finishProjectCompilation(projectId)
|
||||
}
|
||||
}
|
||||
|
||||
fun BaseCompilationTest.project(action: Project.() -> Unit) {
|
||||
Project(workingDirectory).action()
|
||||
Project(workingDirectory).apply {
|
||||
action()
|
||||
endCompilationRound()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user