[LL] Add LL API module for JDK 11 tests to support Lincheck tests

- Lincheck is compiled with JDK 11 and the `low-level-api-fir` module is
  based on the JDK 8 toolchain, so we need to add a new module with a
  JDK 11 toolchain to support Lincheck tests. We cannot bump
  `low-level-api-fir` to JDK 11 because `low-level-api-fir-for-ide`
  requires it to be based on a JDK 8 toolchain.
- Using a Gradle test suite is unfortunately not an option, because
  `low-level-api-fir-for-ide` will think that the whole
  `low-level-api-fir` module is compiled with JDK 11 if just a single
  test suite has this toolchain.

^KT-62136
This commit is contained in:
Marco Pennekamp
2023-11-21 18:35:54 +01:00
committed by Space Team
parent c0c6667876
commit ee7c67ba11
6 changed files with 132 additions and 0 deletions
+1
View File
@@ -13,6 +13,7 @@ tasks.register("analysisAllTests") {
":analysis:analysis-api-fe10:test",
":analysis:analysis-api-standalone:test",
":analysis:low-level-api-fir:test",
":analysis:low-level-api-fir:tests-jdk11:test",
":analysis:symbol-light-classes:test"
)
@@ -0,0 +1,37 @@
plugins {
kotlin("jvm")
id("jps-compatible")
}
dependencies {
testImplementation(libs.junit.jupiter.api)
testRuntimeOnly(libs.junit.jupiter.engine)
testImplementation(project(":analysis:analysis-api"))
testImplementation(project(":analysis:low-level-api-fir"))
testImplementation("org.jetbrains.kotlinx:lincheck:2.23")
}
sourceSets {
"test" { projectDefault() }
}
configureJvmToolchain(JdkMajorVersion.JDK_11_0)
projectTest(jUnitMode = JUnitMode.JUnit5) {
dependsOn(":dist")
workingDir = rootDir
useJUnitPlatform()
// This is required by lincheck model checking to be able to use `jdk.internal.misc.Unsafe` and similar classes under the hood.
jvmArgs(
"--add-opens",
"java.base/jdk.internal.misc=ALL-UNNAMED",
"--add-exports",
"java.base/jdk.internal.util=ALL-UNNAMED",
"--add-exports",
"java.base/sun.security.action=ALL-UNNAMED"
)
}
testsJar()
@@ -0,0 +1,32 @@
/*
* Copyright 2010-2023 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.analysis.low.level.api.fir.caches
import org.jetbrains.kotlinx.lincheck.annotations.Operation
import org.jetbrains.kotlinx.lincheck.check
import org.jetbrains.kotlinx.lincheck.strategy.managed.modelchecking.ModelCheckingOptions
import org.jetbrains.kotlinx.lincheck.strategy.stress.StressOptions
import org.junit.jupiter.api.Test
import java.util.concurrent.atomic.AtomicInteger
// This is an example Lincheck test to ensure that the test infrastructure is working. It will be replaced with proper "cleanable soft value
// cache" tests in the scope of KT-62136.
class ExampleLincheckTest {
private val c = AtomicInteger(0)
@Operation
fun inc(): Int = c.incrementAndGet()
@Operation
fun get(): Int = c.get()
@Test
fun stressTest() = StressOptions().check(this::class)
@Test
fun modelCheckingTest() = ModelCheckingOptions().check(this::class)
}