[atomicfu-K/N] Tests for K/N atomicfu-compiler-plugin
* `nativeTest` task now allows to provide compiler plugins that may be enabled during test compilation * test sets for JVM and K/N backends are equal KT-60800 describes all the issues with native tests that were solved in this commit. Co-authored-by: Dmitriy Dolovov <Dmitriy.Dolovov@jetbrains.com> Merge-request: KT-MR-11401 Merged-by: Maria Sokolova <maria.sokolova@jetbrains.com>
This commit is contained in:
+11
-1
@@ -267,6 +267,16 @@ fun main() {
|
||||
}
|
||||
}
|
||||
|
||||
// Atomicfu compiler plugin native tests.
|
||||
testGroup("plugins/atomicfu/atomicfu-compiler/test", "plugins/atomicfu/atomicfu-compiler/testData") {
|
||||
testClass<AbstractNativeBlackBoxTest>(
|
||||
suiteTestClassName = "AtomicfuNativeTestGenerated",
|
||||
annotations = listOf(atomicfuNative(), provider<UseStandardTestCaseGroupProvider>())
|
||||
) {
|
||||
model("nativeBox")
|
||||
}
|
||||
}
|
||||
|
||||
generateTestGroupSuiteWithJUnit5 {
|
||||
testGroup("native/native.tests/tests-gen", "compiler/util-klib-abi/testData") {
|
||||
testClass<AbstractNativeLibraryAbiReaderTest>(
|
||||
@@ -345,4 +355,4 @@ private fun debugger() = annotation(Tag::class.java, "debugger")
|
||||
private fun infrastructure() = annotation(Tag::class.java, "infrastructure")
|
||||
private fun k1libContents() = annotation(Tag::class.java, "k1libContents")
|
||||
private fun k2libContents() = annotation(Tag::class.java, "k2libContents")
|
||||
private fun atomicfu() = annotation(Tag::class.java, "atomicfu")
|
||||
private fun atomicfuNative() = annotation(Tag::class.java, "atomicfu-native")
|
||||
|
||||
+1
@@ -56,6 +56,7 @@ internal class EnforcedProperties(testClass: Class<*>) {
|
||||
internal enum class ClassLevelProperty(shortName: String) {
|
||||
TEST_TARGET("target"),
|
||||
TEST_MODE("mode"),
|
||||
COMPILER_PLUGINS("compilerPlugins"),
|
||||
CUSTOM_KLIBS("customKlibs"),
|
||||
FORCE_STANDALONE("forceStandalone"),
|
||||
COMPILE_ONLY("compileOnly"),
|
||||
|
||||
+10
@@ -190,6 +190,7 @@ private object NativeTestSupport {
|
||||
output += sanitizer
|
||||
output += CacheMode::class to cacheMode
|
||||
output += computeTestMode(enforcedProperties)
|
||||
output += computeCompilerPlugins(enforcedProperties)
|
||||
output += computeCustomKlibs(enforcedProperties)
|
||||
output += computeForcedStandaloneTestKind(enforcedProperties)
|
||||
output += computeForcedNoopTestRunner(enforcedProperties)
|
||||
@@ -277,6 +278,15 @@ private object NativeTestSupport {
|
||||
private fun computeTestMode(enforcedProperties: EnforcedProperties): TestMode =
|
||||
ClassLevelProperty.TEST_MODE.readValue(enforcedProperties, TestMode.values(), default = TestMode.TWO_STAGE_MULTI_MODULE)
|
||||
|
||||
private fun computeCompilerPlugins(enforcedProperties: EnforcedProperties): CompilerPlugins =
|
||||
CompilerPlugins(
|
||||
ClassLevelProperty.COMPILER_PLUGINS.readValue(
|
||||
enforcedProperties,
|
||||
{ it.split(':', ';').mapToSet(::File) },
|
||||
default = emptySet()
|
||||
)
|
||||
)
|
||||
|
||||
private fun computeCustomKlibs(enforcedProperties: EnforcedProperties): CustomKlibs =
|
||||
CustomKlibs(
|
||||
ClassLevelProperty.CUSTOM_KLIBS.readValue(
|
||||
|
||||
+12
@@ -35,6 +35,7 @@ internal abstract class BasicCompilation<A : TestCompilationArtifact>(
|
||||
private val optimizationMode: OptimizationMode,
|
||||
private val compilerOutputInterceptor: CompilerOutputInterceptor,
|
||||
protected val freeCompilerArgs: TestCompilerArgs,
|
||||
protected val compilerPlugins: CompilerPlugins,
|
||||
protected val dependencies: CategorizedDependencies,
|
||||
protected val expectedArtifact: A
|
||||
) : TestCompilation<A>() {
|
||||
@@ -67,6 +68,10 @@ internal abstract class BasicCompilation<A : TestCompilationArtifact>(
|
||||
add(freeCompilerArgs.compilerArgs)
|
||||
}
|
||||
|
||||
private fun ArgsBuilder.applyCompilerPlugins() {
|
||||
add(compilerPlugins.compilerPluginJars) { compilerPluginJar -> "-Xplugin=${compilerPluginJar.path}" }
|
||||
}
|
||||
|
||||
private fun ArgsBuilder.applySources() {
|
||||
addFlattenedTwice(sourceModules, { it.files }) { it.location.path }
|
||||
}
|
||||
@@ -79,6 +84,7 @@ internal abstract class BasicCompilation<A : TestCompilationArtifact>(
|
||||
applySpecificArgs(this)
|
||||
applyDependencies(this)
|
||||
applyFreeArgs()
|
||||
applyCompilerPlugins()
|
||||
applySources()
|
||||
}
|
||||
|
||||
@@ -135,6 +141,7 @@ internal abstract class SourceBasedCompilation<A : TestCompilationArtifact>(
|
||||
private val allocator: Allocator,
|
||||
private val pipelineType: PipelineType,
|
||||
freeCompilerArgs: TestCompilerArgs,
|
||||
compilerPlugins: CompilerPlugins,
|
||||
override val sourceModules: Collection<TestModule>,
|
||||
dependencies: CategorizedDependencies,
|
||||
expectedArtifact: A
|
||||
@@ -145,6 +152,7 @@ internal abstract class SourceBasedCompilation<A : TestCompilationArtifact>(
|
||||
optimizationMode = optimizationMode,
|
||||
compilerOutputInterceptor = compilerOutputInterceptor,
|
||||
freeCompilerArgs = freeCompilerArgs,
|
||||
compilerPlugins = compilerPlugins,
|
||||
dependencies = dependencies,
|
||||
expectedArtifact = expectedArtifact
|
||||
) {
|
||||
@@ -197,6 +205,7 @@ internal class LibraryCompilation(
|
||||
allocator = settings.get(),
|
||||
pipelineType = settings.get(),
|
||||
freeCompilerArgs = freeCompilerArgs,
|
||||
compilerPlugins = settings.get(),
|
||||
sourceModules = sourceModules,
|
||||
dependencies = CategorizedDependencies(dependencies),
|
||||
expectedArtifact = expectedArtifact
|
||||
@@ -231,6 +240,7 @@ internal class ObjCFrameworkCompilation(
|
||||
allocator = settings.get(),
|
||||
pipelineType = settings.getStageDependentPipelineType(),
|
||||
freeCompilerArgs = freeCompilerArgs,
|
||||
compilerPlugins = settings.get(),
|
||||
sourceModules = sourceModules,
|
||||
dependencies = CategorizedDependencies(dependencies),
|
||||
expectedArtifact = expectedArtifact
|
||||
@@ -317,6 +327,7 @@ internal class ExecutableCompilation(
|
||||
allocator = settings.get(),
|
||||
pipelineType = settings.getStageDependentPipelineType(),
|
||||
freeCompilerArgs = freeCompilerArgs,
|
||||
compilerPlugins = settings.get(),
|
||||
sourceModules = sourceModules,
|
||||
dependencies = CategorizedDependencies(dependencies),
|
||||
expectedArtifact = expectedArtifact
|
||||
@@ -409,6 +420,7 @@ internal class StaticCacheCompilation(
|
||||
optimizationMode = settings.get(),
|
||||
compilerOutputInterceptor = settings.get(),
|
||||
freeCompilerArgs = freeCompilerArgs,
|
||||
compilerPlugins = settings.get(),
|
||||
dependencies = CategorizedDependencies(dependencies),
|
||||
expectedArtifact = expectedArtifact
|
||||
) {
|
||||
|
||||
+13
@@ -77,6 +77,19 @@ internal enum class TestMode(private val description: String) {
|
||||
override fun toString() = description
|
||||
}
|
||||
|
||||
/**
|
||||
* Kotlin compiler plugins to be used together with the the Kotlin/Native compiler.
|
||||
*/
|
||||
@JvmInline
|
||||
internal value class CompilerPlugins(val compilerPluginJars: Set<File>) {
|
||||
init {
|
||||
val invalidJars = compilerPluginJars.filterNot { it.isDirectory || (it.isFile && it.extension == "jar") }
|
||||
assertTrue(invalidJars.isEmpty()) {
|
||||
"There are invalid compiler plugin JARs that should be passed for the Kotlin/Native compiler: ${invalidJars.joinToString { "[$it]" }}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The set of custom (external) klibs that should be passed to the Kotlin/Native compiler.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user