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