aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormvicsokolova <82594708+mvicsokolova@users.noreply.github.com>2022-10-25 12:54:39 +0200
committerGitHub <noreply@github.com>2022-10-25 12:54:39 +0200
commit4a6eac1aefbd271196f7bb81f1d3f975930f0793 (patch)
tree441dd37974872c72f0b551df3ca146a9fae814b7
parentd6ecd362540ac03adf62447bf6f9bdd003832535 (diff)
downloadkotlinx.atomicfu-4a6eac1aefbd271196f7bb81f1d3f975930f0793.tar.gz
More tests for atomicfu-gradle-plugin (#255)
* Added tests for atomicfu-gradle-plugin
-rw-r--r--atomicfu-gradle-plugin/src/test/kotlin/kotlinx/atomicfu/plugin/gradle/internal/TestDsl.kt10
-rw-r--r--atomicfu-gradle-plugin/src/test/kotlin/kotlinx/atomicfu/plugin/gradle/test/BaseKotlinGradleTest.kt78
-rw-r--r--atomicfu-gradle-plugin/src/test/kotlin/kotlinx/atomicfu/plugin/gradle/test/JsProjectTest.kt49
-rw-r--r--atomicfu-gradle-plugin/src/test/kotlin/kotlinx/atomicfu/plugin/gradle/test/JvmProjectTest.kt104
-rw-r--r--atomicfu-gradle-plugin/src/test/kotlin/kotlinx/atomicfu/plugin/gradle/test/MppProjectTest.kt217
-rw-r--r--atomicfu-gradle-plugin/src/test/resources/projects/jvm-simple/gradle.properties1
-rw-r--r--atomicfu-gradle-plugin/src/test/resources/projects/mpp-simple/gradle.properties_both3
-rw-r--r--atomicfu-gradle-plugin/src/test/resources/projects/mpp-simple/gradle.properties_js2
-rw-r--r--atomicfu-gradle-plugin/src/test/resources/projects/mpp-simple/gradle.properties_jvm1
9 files changed, 376 insertions, 89 deletions
diff --git a/atomicfu-gradle-plugin/src/test/kotlin/kotlinx/atomicfu/plugin/gradle/internal/TestDsl.kt b/atomicfu-gradle-plugin/src/test/kotlin/kotlinx/atomicfu/plugin/gradle/internal/TestDsl.kt
index 2a51f1b..2541b41 100644
--- a/atomicfu-gradle-plugin/src/test/kotlin/kotlinx/atomicfu/plugin/gradle/internal/TestDsl.kt
+++ b/atomicfu-gradle-plugin/src/test/kotlin/kotlinx/atomicfu/plugin/gradle/internal/TestDsl.kt
@@ -62,6 +62,14 @@ internal fun FileContainer.settingsGradleKts(fn: AppendableScope.() -> Unit) {
}
/**
+ * Shortcut for creating a `gradle.properties` by using [file][FileContainer.file]
+ */
+internal fun FileContainer.gradleProperties(fn: AppendableScope.() -> Unit) {
+ val fileName = "gradle.properties"
+ file(fileName, fn)
+}
+
+/**
* Declares a directory with the given [dirName] inside the current container.
* All calls creating files within this scope will create the files nested in this directory.
*
@@ -128,4 +136,4 @@ internal fun getFile(fileName: String): File {
internal fun GradleRunner.addPluginTestRuntimeClasspath() = apply {
val pluginClasspath = getFile("plugin-classpath.txt").readLines().map { File(it) }
withPluginClasspath(pluginClasspath)
-} \ No newline at end of file
+}
diff --git a/atomicfu-gradle-plugin/src/test/kotlin/kotlinx/atomicfu/plugin/gradle/test/BaseKotlinGradleTest.kt b/atomicfu-gradle-plugin/src/test/kotlin/kotlinx/atomicfu/plugin/gradle/test/BaseKotlinGradleTest.kt
index f6ec8ef..e9ff7bb 100644
--- a/atomicfu-gradle-plugin/src/test/kotlin/kotlinx/atomicfu/plugin/gradle/test/BaseKotlinGradleTest.kt
+++ b/atomicfu-gradle-plugin/src/test/kotlin/kotlinx/atomicfu/plugin/gradle/test/BaseKotlinGradleTest.kt
@@ -5,10 +5,14 @@
package kotlinx.atomicfu.plugin.gradle.test
import kotlinx.atomicfu.plugin.gradle.internal.*
+import org.objectweb.asm.*
import java.io.File
+import kotlin.test.*
-open class BaseKotlinGradleTest(private val projectName: String) {
+abstract class BaseKotlinGradleTest(private val projectName: String) {
internal val rootProjectDir: File
+ private val ATOMIC_FU_REF = "Lkotlinx/atomicfu/".toByteArray()
+ private val KOTLIN_METADATA_DESC = "Lkotlin/Metadata;"
init {
rootProjectDir = File("build${File.separator}test-$projectName").absoluteFile
@@ -16,21 +20,48 @@ open class BaseKotlinGradleTest(private val projectName: String) {
rootProjectDir.mkdirs()
}
+ internal abstract fun BaseKotlinScope.createProject()
+
+ val runner = test {
+ createProject()
+ runner {
+ arguments.add(":build")
+ }
+ }
+
+ fun checkTaskOutcomes(executedTasks: List<String>, excludedTasks: List<String>) {
+ runner.build().apply {
+ val tasks = tasks.map { it.path }
+ excludedTasks.forEach {
+ check(it !in tasks) { "Post-compilation transformation task $it was added in the compiler plugin mode" }
+ }
+ executedTasks.forEach {
+ assertTaskSuccess(it)
+ }
+ }
+ // check that task outcomes are cached for the second build
+ runner.build().apply {
+ executedTasks.forEach {
+ assertTaskUpToDate(it)
+ }
+ }
+ }
+
fun checkJvmCompilationClasspath(originalClassFile: String, transformedClassFile: String) {
- // check that test compilation depends on transformed main sources
+ // check that test compile and runtime classpath does not contain original non-transformed classes
val testCompileClasspathFiles = rootProjectDir.filesFrom("build/test_compile_jvm_classpath.txt")
val testRuntimeClasspathFiles = rootProjectDir.filesFrom("build/test_runtime_jvm_classpath.txt")
rootProjectDir.resolve(transformedClassFile).let {
it.checkExists()
- check(it in testCompileClasspathFiles) { "Original '$it' is missing from test compile classpath" }
- check(it in testRuntimeClasspathFiles) { "Original '$it' is missing from test runtime classpath" }
+ check(it in testCompileClasspathFiles) { "Transformed '$it' is missing from test compile classpath" }
+ check(it in testRuntimeClasspathFiles) { "Transformed '$it' is missing from test runtime classpath" }
}
rootProjectDir.resolve(originalClassFile).let {
it.checkExists()
- check(it !in testCompileClasspathFiles) { "Transformed '$it' is present in test compile classpath" }
- check(it !in testRuntimeClasspathFiles) { "Transformed '$it' is present in test runtime classpath" }
+ check(it !in testCompileClasspathFiles) { "Original '$it' is present in test compile classpath" }
+ check(it !in testRuntimeClasspathFiles) { "Original '$it' is present in test runtime classpath" }
}
}
@@ -40,7 +71,38 @@ open class BaseKotlinGradleTest(private val projectName: String) {
rootProjectDir.resolve("build/classes/atomicfu/js/main/$projectName.js").let {
it.checkExists()
- check(it in testCompileClasspathFiles) { "Original '$it' is missing from test compile classpath" }
+ check(it in testCompileClasspathFiles) { "Transformed '$it' is missing from test compile classpath" }
}
}
-} \ No newline at end of file
+
+ fun checkBytecode(classFilePath: String) {
+ rootProjectDir.resolve(classFilePath).let {
+ it.checkExists()
+ assertFalse(it.readBytes().findAtomicfuRef(), "Found 'Lkotlinx/atomicfu/' reference in $it" )
+ }
+ }
+
+ private fun ByteArray.findAtomicfuRef(): Boolean {
+ val bytes = this.eraseMetadata()
+ loop@for (i in 0 until bytes.size - ATOMIC_FU_REF.size) {
+ for (j in 0 until ATOMIC_FU_REF.size) {
+ if (bytes[i + j] != ATOMIC_FU_REF[j]) continue@loop
+ }
+ return true
+ }
+ return false
+ }
+
+ // The atomicfu compiler plugin does not remove atomic properties from metadata,
+ // so for now we check that there are no ATOMIC_FU_REF left in the class bytecode excluding metadata.
+ // This may be reverted after the fix in the compiler plugin transformer (See #254).
+ private fun ByteArray.eraseMetadata(): ByteArray {
+ val cw = ClassWriter(ClassWriter.COMPUTE_MAXS or ClassWriter.COMPUTE_FRAMES)
+ ClassReader(this).accept(object : ClassVisitor(Opcodes.ASM9, cw) {
+ override fun visitAnnotation(descriptor: String?, visible: Boolean): AnnotationVisitor? {
+ return if (descriptor == KOTLIN_METADATA_DESC) null else super.visitAnnotation(descriptor, visible)
+ }
+ }, ClassReader.SKIP_FRAMES)
+ return cw.toByteArray()
+ }
+}
diff --git a/atomicfu-gradle-plugin/src/test/kotlin/kotlinx/atomicfu/plugin/gradle/test/JsProjectTest.kt b/atomicfu-gradle-plugin/src/test/kotlin/kotlinx/atomicfu/plugin/gradle/test/JsProjectTest.kt
index 8630f70..0b34955 100644
--- a/atomicfu-gradle-plugin/src/test/kotlin/kotlinx/atomicfu/plugin/gradle/test/JsProjectTest.kt
+++ b/atomicfu-gradle-plugin/src/test/kotlin/kotlinx/atomicfu/plugin/gradle/test/JsProjectTest.kt
@@ -4,8 +4,15 @@ import kotlinx.atomicfu.plugin.gradle.internal.*
import kotlinx.atomicfu.plugin.gradle.internal.BaseKotlinScope
import org.junit.Test
-class JsProjectTest : BaseKotlinGradleTest("js-simple") {
- private fun BaseKotlinScope.createProject() {
+/**
+ * Test that ensures correctness of `atomicfu-gradle-plugin` application to the JS project:
+ * - post-compilation js transformation tasks are created
+ * (legacy transformation is tested here, compiler plugin is not applied).
+ * - original non-transformed classes are not left in compile/runtime classpath.
+ */
+class JsLegacyTransformationTest : BaseKotlinGradleTest("js-simple") {
+
+ override fun BaseKotlinScope.createProject() {
buildGradleKts {
resolve("projects/js-simple/js-simple.gradle.kts")
}
@@ -23,30 +30,20 @@ class JsProjectTest : BaseKotlinGradleTest("js-simple") {
}
@Test
- fun testPlugin() {
- val runner = test {
- createProject()
- runner {
- arguments.add(":build")
- }
- }
- val tasksToCheck = arrayOf(
- ":compileKotlinJs",
- ":transformJsMainAtomicfu",
- ":compileTestKotlinJs",
- ":transformJsTestAtomicfu"
+ fun testPluginApplication() =
+ checkTaskOutcomes(
+ executedTasks = listOf(
+ ":compileKotlinJs",
+ ":transformJsMainAtomicfu",
+ ":compileTestKotlinJs",
+ ":transformJsTestAtomicfu"
+ ),
+ excludedTasks = emptyList()
)
- runner.build().apply {
- tasksToCheck.forEach {
- assertTaskSuccess(it)
- }
- }
- // check that task outcomes are cached for the second build
- runner.build().apply {
- tasksToCheck.forEach {
- assertTaskUpToDate(it)
- }
- }
+
+ @Test
+ fun testClasspath() {
+ runner.build()
checkJsCompilationClasspath()
}
-} \ No newline at end of file
+}
diff --git a/atomicfu-gradle-plugin/src/test/kotlin/kotlinx/atomicfu/plugin/gradle/test/JvmProjectTest.kt b/atomicfu-gradle-plugin/src/test/kotlin/kotlinx/atomicfu/plugin/gradle/test/JvmProjectTest.kt
index 838d091..2545e0e 100644
--- a/atomicfu-gradle-plugin/src/test/kotlin/kotlinx/atomicfu/plugin/gradle/test/JvmProjectTest.kt
+++ b/atomicfu-gradle-plugin/src/test/kotlin/kotlinx/atomicfu/plugin/gradle/test/JvmProjectTest.kt
@@ -4,9 +4,16 @@ import kotlinx.atomicfu.plugin.gradle.internal.*
import kotlinx.atomicfu.plugin.gradle.internal.BaseKotlinScope
import org.junit.Test
-class JvmProjectTest : BaseKotlinGradleTest("jvm-simple") {
+/**
+ * Test that ensures correctness of `atomicfu-gradle-plugin` application to the JVM project:
+ * - post-compilation bytecode transformation tasks are created
+ * (legacy transformation is tested here, compiler plugin is not applied).
+ * - original non-transformed classes are not left in compile/runtime classpath.
+ * - no `kotlinx/atomicfu` references are left in the transformed bytecode.
+ */
+class JvmLegacyTransformationTest : BaseKotlinGradleTest("jvm-simple") {
- private fun BaseKotlinScope.createProject() {
+ override fun BaseKotlinScope.createProject() {
buildGradleKts {
resolve("projects/jvm-simple/jvm-simple.gradle.kts")
}
@@ -24,33 +31,78 @@ class JvmProjectTest : BaseKotlinGradleTest("jvm-simple") {
}
@Test
- fun testPlugin() {
- val runner = test {
- createProject()
- runner {
- arguments.add(":build")
- }
- }
- val tasksToCheck = arrayOf(
- ":compileKotlin",
- ":transformAtomicfuClasses",
- ":compileTestKotlin",
- ":transformTestAtomicfuClasses"
+ fun testPluginApplication() =
+ checkTaskOutcomes(
+ executedTasks = listOf(
+ ":compileKotlin",
+ ":transformAtomicfuClasses",
+ ":compileTestKotlin",
+ ":transformTestAtomicfuClasses"
+ ),
+ excludedTasks = emptyList()
)
- runner.build().apply {
- tasksToCheck.forEach {
- assertTaskSuccess(it)
- }
- }
- // check that task outcomes are cached for the second build
- runner.build().apply {
- tasksToCheck.forEach {
- assertTaskUpToDate(it)
- }
- }
+
+ @Test
+ fun testClasspath() {
+ runner.build()
checkJvmCompilationClasspath(
originalClassFile = "build/classes/kotlin/main/IntArithmetic.class",
transformedClassFile = "build/classes/atomicfu/main/IntArithmetic.class"
)
}
-} \ No newline at end of file
+
+ @Test
+ fun testAtomicfuReferences() {
+ runner.build()
+ checkBytecode("build/classes/atomicfu/main/IntArithmetic.class")
+ }
+}
+
+/**
+ * Test that ensures correctness of `atomicfu-gradle-plugin` application to the JVM project,
+ * - JVM IR compiler plugin transformation (kotlinx.atomicfu.enableJvmIrTransformation=true)
+ * - no post-compilation bytecode transforming tasks created
+ * - no `kotlinx/atomicfu` references are left in the resulting bytecode after IR transformation.
+ */
+class JvmIrTransformationTest : BaseKotlinGradleTest("jvm-simple") {
+
+ override fun BaseKotlinScope.createProject() {
+ buildGradleKts {
+ resolve("projects/jvm-simple/jvm-simple.gradle.kts")
+ }
+ settingsGradleKts {
+ resolve("projects/jvm-simple/settings.gradle.kts")
+ }
+ // set kotlinx.atomicfu.enableJvmIrTransformation=true to apply compiler plugin
+ gradleProperties {
+ resolve("projects/jvm-simple/gradle.properties")
+ }
+ dir("src/main/kotlin") {}
+ kotlin("IntArithmetic.kt", "main") {
+ resolve("projects/jvm-simple/src/main/kotlin/IntArithmetic.kt")
+ }
+ dir("src/test/kotlin") {}
+ kotlin("ArithmeticTest.kt", "test") {
+ resolve("projects/jvm-simple/src/test/kotlin/ArithmeticTest.kt")
+ }
+ }
+
+ @Test
+ fun testPluginApplication() =
+ checkTaskOutcomes(
+ executedTasks = listOf(
+ ":compileKotlin",
+ ":compileTestKotlin"
+ ),
+ excludedTasks = listOf(
+ ":transformAtomicfuClasses",
+ ":transformTestAtomicfuClasses"
+ )
+ )
+
+ @Test
+ fun testAtomicfuReferences() {
+ runner.build()
+ checkBytecode("build/classes/kotlin/main/IntArithmetic.class")
+ }
+}
diff --git a/atomicfu-gradle-plugin/src/test/kotlin/kotlinx/atomicfu/plugin/gradle/test/MppProjectTest.kt b/atomicfu-gradle-plugin/src/test/kotlin/kotlinx/atomicfu/plugin/gradle/test/MppProjectTest.kt
index cbeefa2..e95b091 100644
--- a/atomicfu-gradle-plugin/src/test/kotlin/kotlinx/atomicfu/plugin/gradle/test/MppProjectTest.kt
+++ b/atomicfu-gradle-plugin/src/test/kotlin/kotlinx/atomicfu/plugin/gradle/test/MppProjectTest.kt
@@ -3,8 +3,16 @@ package kotlinx.atomicfu.plugin.gradle.test
import kotlinx.atomicfu.plugin.gradle.internal.*
import org.junit.*
-class MppProjectTest : BaseKotlinGradleTest("mpp-simple") {
- private fun BaseKotlinScope.createProject() {
+/**
+ * Test that ensures correctness of `atomicfu-gradle-plugin` application to the MPP project:
+ * - post-compilation bytecode transformation tasks are created
+ * (legacy transformation is tested here, compiler plugin is not applied).
+ * - original non-transformed classes are not left in compile/runtime classpath.
+ * - no `kotlinx/atomicfu` references are left in the transformed bytecode.
+ */
+class MppLegacyTransformationTest : BaseKotlinGradleTest("mpp-simple") {
+
+ override fun BaseKotlinScope.createProject() {
buildGradleKts {
resolve("projects/mpp-simple/mpp-simple.gradle.kts")
}
@@ -22,37 +30,190 @@ class MppProjectTest : BaseKotlinGradleTest("mpp-simple") {
}
@Test
- fun testPlugin() {
- val runner = test {
- createProject()
- runner {
- arguments.add(":build")
- }
- }
- val tasksToCheck = arrayOf(
- ":compileKotlinJvm",
- ":compileTestKotlinJvm",
- ":transformJvmMainAtomicfu",
- ":transformJvmTestAtomicfu",
- ":compileKotlinJs",
- ":transformJsMainAtomicfu"
+ fun testPluginApplication() =
+ checkTaskOutcomes(
+ executedTasks = listOf(
+ ":compileKotlinJvm",
+ ":compileTestKotlinJvm",
+ ":transformJvmMainAtomicfu",
+ ":transformJvmTestAtomicfu",
+ ":compileKotlinJs",
+ ":transformJsMainAtomicfu"
+ ),
+ excludedTasks = emptyList()
)
- runner.build().apply {
- tasksToCheck.forEach {
- assertTaskSuccess(it)
- }
- }
- // check that task outcomes are cached for the second build
- runner.build().apply {
- tasksToCheck.forEach {
- assertTaskUpToDate(it)
- }
- }
+ @Test
+ fun testClasspath() {
+ runner.build()
checkJvmCompilationClasspath(
originalClassFile = "build/classes/kotlin/jvm/main/IntArithmetic.class",
transformedClassFile = "build/classes/atomicfu/jvm/main/IntArithmetic.class"
)
checkJsCompilationClasspath()
}
-} \ No newline at end of file
+
+ @Test
+ fun testAtomicfuReferences() {
+ runner.build()
+ checkBytecode("build/classes/atomicfu/jvm/main/IntArithmetic.class")
+ }
+}
+
+/**
+ * Test that ensures correctness of `atomicfu-gradle-plugin` application to the MPP project,
+ * - JVM IR compiler plugin transformation (kotlinx.atomicfu.enableJvmIrTransformation=true)
+ * - no post-compilation bytecode transformation tasks are created
+ * - post-compilation js file transformation task created (as only JVM IR transformation applied, js is transformed in legacy mode)
+ * - no `kotlinx/atomicfu` references are left in the transformed bytecode.
+ */
+class MppJvmIrTransformationTest : BaseKotlinGradleTest("mpp-simple") {
+
+ override fun BaseKotlinScope.createProject() {
+ buildGradleKts {
+ resolve("projects/mpp-simple/mpp-simple.gradle.kts")
+ }
+ settingsGradleKts {
+ resolve("projects/mpp-simple/settings.gradle.kts")
+ }
+ gradleProperties {
+ resolve("projects/mpp-simple/gradle.properties_jvm")
+ }
+ dir("src/commonMain/kotlin") {}
+ kotlin("IntArithmetic.kt", "commonMain") {
+ resolve("projects/mpp-simple/src/commonMain/kotlin/IntArithmetic.kt")
+ }
+ dir("src/commonTest/kotlin") {}
+ kotlin("ArithmeticTest.kt", "commonTest") {
+ resolve("projects/mpp-simple/src/commonTest/kotlin/ArithmeticTest.kt")
+ }
+ }
+
+ @Test
+ fun testPluginApplication() =
+ checkTaskOutcomes(
+ executedTasks = listOf(
+ ":compileKotlinJvm",
+ ":compileTestKotlinJvm",
+ ":compileKotlinJs",
+ // legacy JS transformation
+ ":transformJsMainAtomicfu",
+ ":transformJsTestAtomicfu"
+ ),
+ excludedTasks = listOf(
+ ":transformJvmMainAtomicfu",
+ ":transformJvmTestAtomicfu"
+ )
+ )
+
+ @Test
+ fun testAtomicfuReferences() {
+ runner.build()
+ checkBytecode("build/classes/kotlin/jvm/main/IntArithmetic.class")
+ }
+}
+
+/**
+ * Test that ensures correctness of `atomicfu-gradle-plugin` application to the MPP project,
+ * - JS IR compiler plugin transformation (kotlinx.atomicfu.enableJsIrTransformation=true)
+ * - post-compilation bytecode transformation tasks are created (only JS IR transformation is applied, jvm is transformed in legacy mode)
+ * - no post-compilation js file transformation tasks are created
+ * - no `kotlinx/atomicfu` references are left in the transformed bytecode.
+ */
+class MppJsIrTransformationTest : BaseKotlinGradleTest("mpp-simple") {
+
+ override fun BaseKotlinScope.createProject() {
+ buildGradleKts {
+ resolve("projects/mpp-simple/mpp-simple.gradle.kts")
+ }
+ settingsGradleKts {
+ resolve("projects/mpp-simple/settings.gradle.kts")
+ }
+ gradleProperties {
+ resolve("projects/mpp-simple/gradle.properties_js")
+ }
+ dir("src/commonMain/kotlin") {}
+ kotlin("IntArithmetic.kt", "commonMain") {
+ resolve("projects/mpp-simple/src/commonMain/kotlin/IntArithmetic.kt")
+ }
+ dir("src/commonTest/kotlin") {}
+ kotlin("ArithmeticTest.kt", "commonTest") {
+ resolve("projects/mpp-simple/src/commonTest/kotlin/ArithmeticTest.kt")
+ }
+ }
+
+ @Test
+ fun testPluginApplication() =
+ checkTaskOutcomes(
+ executedTasks = listOf(
+ ":compileKotlinJvm",
+ ":compileTestKotlinJvm",
+ ":compileKotlinJs",
+ // legacy JVM transformation
+ ":transformJvmMainAtomicfu",
+ ":transformJvmTestAtomicfu"
+ ),
+ excludedTasks = listOf(
+ ":transformJsMainAtomicfu",
+ ":transformJsTestAtomicfu"
+ )
+ )
+
+ @Test
+ fun testAtomicfuReferences() {
+ runner.build()
+ checkBytecode("build/classes/atomicfu/jvm/main/IntArithmetic.class")
+ }
+}
+
+/**
+ * Test that ensures correctness of `atomicfu-gradle-plugin` application to the MPP project,
+ * - JS IR and JVM IR compiler plugin transformation
+ * - no post-compilation bytecode transformation tasks are created (only JS IR transformation is applied, jvm is transformed in legacy mode)
+ * - no post-compilation js file transformation tasks are created
+ * - no `kotlinx/atomicfu` references are left in the transformed bytecode.
+ */
+class MppBothIrTransformationTest : BaseKotlinGradleTest("mpp-simple") {
+
+ override fun BaseKotlinScope.createProject() {
+ buildGradleKts {
+ resolve("projects/mpp-simple/mpp-simple.gradle.kts")
+ }
+ settingsGradleKts {
+ resolve("projects/mpp-simple/settings.gradle.kts")
+ }
+ gradleProperties {
+ resolve("projects/mpp-simple/gradle.properties_both")
+ }
+ dir("src/commonMain/kotlin") {}
+ kotlin("IntArithmetic.kt", "commonMain") {
+ resolve("projects/mpp-simple/src/commonMain/kotlin/IntArithmetic.kt")
+ }
+ dir("src/commonTest/kotlin") {}
+ kotlin("ArithmeticTest.kt", "commonTest") {
+ resolve("projects/mpp-simple/src/commonTest/kotlin/ArithmeticTest.kt")
+ }
+ }
+
+ @Test
+ fun testPluginApplication() =
+ checkTaskOutcomes(
+ executedTasks = listOf(
+ ":compileKotlinJvm",
+ ":compileTestKotlinJvm",
+ ":compileKotlinJs"
+ ),
+ excludedTasks = listOf(
+ ":transformJvmMainAtomicfu",
+ ":transformJvmTestAtomicfu",
+ ":transformJsMainAtomicfu",
+ ":transformJsTestAtomicfu"
+ )
+ )
+
+ @Test
+ fun testAtomicfuReferences() {
+ runner.build()
+ checkBytecode("build/classes/kotlin/jvm/main/IntArithmetic.class")
+ }
+}
diff --git a/atomicfu-gradle-plugin/src/test/resources/projects/jvm-simple/gradle.properties b/atomicfu-gradle-plugin/src/test/resources/projects/jvm-simple/gradle.properties
new file mode 100644
index 0000000..fa37a2c
--- /dev/null
+++ b/atomicfu-gradle-plugin/src/test/resources/projects/jvm-simple/gradle.properties
@@ -0,0 +1 @@
+kotlinx.atomicfu.enableJvmIrTransformation=true
diff --git a/atomicfu-gradle-plugin/src/test/resources/projects/mpp-simple/gradle.properties_both b/atomicfu-gradle-plugin/src/test/resources/projects/mpp-simple/gradle.properties_both
new file mode 100644
index 0000000..5d28ccd
--- /dev/null
+++ b/atomicfu-gradle-plugin/src/test/resources/projects/mpp-simple/gradle.properties_both
@@ -0,0 +1,3 @@
+kotlin.js.compiler=ir
+kotlinx.atomicfu.enableJvmIrTransformation=true
+kotlinx.atomicfu.enableJsIrTransformation=true
diff --git a/atomicfu-gradle-plugin/src/test/resources/projects/mpp-simple/gradle.properties_js b/atomicfu-gradle-plugin/src/test/resources/projects/mpp-simple/gradle.properties_js
new file mode 100644
index 0000000..b57875b
--- /dev/null
+++ b/atomicfu-gradle-plugin/src/test/resources/projects/mpp-simple/gradle.properties_js
@@ -0,0 +1,2 @@
+kotlin.js.compiler=ir
+kotlinx.atomicfu.enableJsIrTransformation=true
diff --git a/atomicfu-gradle-plugin/src/test/resources/projects/mpp-simple/gradle.properties_jvm b/atomicfu-gradle-plugin/src/test/resources/projects/mpp-simple/gradle.properties_jvm
new file mode 100644
index 0000000..fa37a2c
--- /dev/null
+++ b/atomicfu-gradle-plugin/src/test/resources/projects/mpp-simple/gradle.properties_jvm
@@ -0,0 +1 @@
+kotlinx.atomicfu.enableJvmIrTransformation=true