[BTA tests] Introduce BaseTest providing CompilationService instance
^KT-61860 In Progress
This commit is contained in:
committed by
Space Team
parent
cf8e65b3c5
commit
3f6b5ae86d
+1
-1
@@ -10,7 +10,7 @@ import org.junit.jupiter.api.io.TempDir
|
||||
import java.nio.file.Path
|
||||
|
||||
@TestDataPath("\$CONTENT_ROOT/../main/resources/modules")
|
||||
abstract class BaseCompilationTest {
|
||||
abstract class BaseCompilationTest : BaseTest() {
|
||||
@TempDir
|
||||
lateinit var workingDirectory: Path
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright 2010-2024 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.buildtools.api.tests.compilation.model
|
||||
|
||||
import org.jetbrains.kotlin.buildtools.api.CompilationService
|
||||
|
||||
abstract class BaseTest {
|
||||
companion object {
|
||||
val compilationService: CompilationService by lazy {
|
||||
CompilationService.loadImplementation(BaseTest::class.java.classLoader)
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-3
@@ -5,7 +5,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.buildtools.api.tests.compilation.model
|
||||
|
||||
import org.jetbrains.kotlin.buildtools.api.CompilationService
|
||||
import org.junit.jupiter.api.Named.named
|
||||
import org.junit.jupiter.api.extension.ExtensionContext
|
||||
import org.junit.jupiter.params.provider.Arguments
|
||||
@@ -14,9 +13,8 @@ import java.util.stream.Stream
|
||||
import kotlin.streams.asStream
|
||||
|
||||
class DefaultStrategyAgnosticCompilationTestArgumentProvider : ArgumentsProvider {
|
||||
private val compilationService = CompilationService.loadImplementation(this.javaClass.classLoader)
|
||||
|
||||
override fun provideArguments(context: ExtensionContext): Stream<out Arguments> {
|
||||
val compilationService = BaseTest.compilationService
|
||||
return sequenceOf(
|
||||
named("in-process", compilationService.makeCompilerExecutionStrategyConfiguration().useInProcessStrategy()),
|
||||
named("within daemon", compilationService.makeCompilerExecutionStrategyConfiguration().useDaemonStrategy(emptyList())),
|
||||
|
||||
+6
-4
@@ -40,7 +40,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 = project.compilationService.makeJvmCompilationConfiguration()
|
||||
val compilationConfig = BaseTest.compilationService.makeJvmCompilationConfiguration()
|
||||
compilationConfigAction(compilationConfig)
|
||||
compilationConfig.useLogger(kotlinLogger)
|
||||
val defaultCompilationArguments = listOf(
|
||||
@@ -50,7 +50,7 @@ class JvmModule(
|
||||
"-cp", dependencyFiles.joinToString(File.pathSeparator),
|
||||
"-module-name", moduleName,
|
||||
)
|
||||
return project.compilationService.compileJvm(
|
||||
return BaseTest.compilationService.compileJvm(
|
||||
project.projectId,
|
||||
strategyConfig,
|
||||
compilationConfig,
|
||||
@@ -60,8 +60,10 @@ class JvmModule(
|
||||
}
|
||||
|
||||
private fun generateClasspathSnapshot(dependency: Dependency): Path {
|
||||
val snapshot =
|
||||
project.compilationService.calculateClasspathSnapshot(dependency.location.toFile(), ClassSnapshotGranularity.CLASS_MEMBER_LEVEL)
|
||||
val snapshot = BaseTest.compilationService.calculateClasspathSnapshot(
|
||||
dependency.location.toFile(),
|
||||
ClassSnapshotGranularity.CLASS_MEMBER_LEVEL
|
||||
)
|
||||
val hash = snapshot.classSnapshots.values
|
||||
.filterIsInstance<AccessibleClassSnapshot>()
|
||||
.withIndex()
|
||||
|
||||
+1
-3
@@ -5,7 +5,6 @@
|
||||
|
||||
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
|
||||
@@ -18,7 +17,6 @@ class Project(
|
||||
val projectDirectory: Path,
|
||||
) {
|
||||
val projectId = ProjectId.ProjectUUID(UUID.randomUUID())
|
||||
val compilationService = CompilationService.loadImplementation(this.javaClass.classLoader)
|
||||
|
||||
fun module(
|
||||
moduleName: String,
|
||||
@@ -37,7 +35,7 @@ class Project(
|
||||
}
|
||||
|
||||
fun endCompilationRound() {
|
||||
compilationService.finishProjectCompilation(projectId)
|
||||
BaseTest.compilationService.finishProjectCompilation(projectId)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-4
@@ -5,16 +5,14 @@
|
||||
|
||||
package org.jetbrains.kotlin.buildtools.api.tests
|
||||
|
||||
import org.jetbrains.kotlin.buildtools.api.CompilationService
|
||||
import org.jetbrains.kotlin.buildtools.api.tests.compilation.model.BaseTest
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Disabled
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
@Disabled("Example tests for evaluation purposes of the DSL")
|
||||
class ExampleCompatibilityTest {
|
||||
private val compilationService = CompilationService.loadImplementation(ExampleCompatibilityTest::class.java.classLoader)
|
||||
|
||||
class ExampleCompatibilityTest : BaseTest() {
|
||||
@Test
|
||||
@DisplayName("Sample compatibility test that is run as part of each test suit")
|
||||
fun testDefaultNonIncrementalSettings() {
|
||||
|
||||
Reference in New Issue
Block a user