-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integration tests #345
Integration tests #345
Conversation
8c218bd
to
1b1ccda
Compare
1b1ccda
to
2e8a11f
Compare
cd6564d
to
ae77f31
Compare
6f9fdf0
to
ca40dbb
Compare
@@ -0,0 +1,28 @@ | |||
buildscript { | |||
val atomicfu_version = rootProject.properties["atomicfu_version"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And what is the proper way to get atomicfu_version here?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can override the plugin version in settings.gradle.kts
file. In this case, it will be possible to apply the plugin in the plugins { }
block
pluginManagement {
resolutionStrategy {
eachPlugin {
val fuVersion = gradle.rootProject.properties["atomicfu_version"]?.toString()
if (fuVersion != null && requested.id.id != "kotlinx-atomicfu") {
useVersion(fuVersion)
}
}
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error is: The root project is not yet available for build.
And I get the same error for version catalogs, so, I only managed to do it like this:
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
version("atomicfu", "0.22.0-SNAPSHOT")
version("kotlin", "1.9.20")
}
}
}
But it's still versions hardcoding 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's fine to leave like it is for now then
...-testing/src/test/kotlin/kotlinx.atomicfu.gradle.plugin.test/framework/runner/Environment.kt
Outdated
Show resolved
Hide resolved
e395a11
to
9a2703e
Compare
val config = config | ||
withPluginWhenEvaluated("kotlin") { | ||
if (config.transformJvm) configureJvmTransformation() | ||
private fun Project.configureMultiplatformPluginDependencies(version: String) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only conceptual change in the AtomicfuGradlePlugin
is in configureMultiplatformPluginDependencies
, all other changes are just refactoring: changing the order of declarations.
val config = config | ||
withPluginWhenEvaluated("kotlin") { | ||
if (config.transformJvm) configureJvmTransformation() | ||
private fun Project.configureMultiplatformPluginDependencies(version: String) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only conceptual change in the AtomicfuGradlePlugin
is in configureMultiplatformPluginDependencies
, all other changes are just refactoring: changing the order of declarations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job! Overall looks good, there's only a few minor issues to address.
integration-testing/examples/jvm-sample/src/main/kotlin/Sample.kt
Outdated
Show resolved
Hide resolved
...nctionalTest/kotlin/kotlinx.atomicfu.gradle.plugin.test/framework/checker/ArtifactChecker.kt
Outdated
Show resolved
Hide resolved
...nctionalTest/kotlin/kotlinx.atomicfu.gradle.plugin.test/framework/checker/ArtifactChecker.kt
Outdated
Show resolved
Hide resolved
...rc/functionalTest/kotlin/kotlinx.atomicfu.gradle.plugin.test/framework/runner/BuildRunner.kt
Outdated
Show resolved
Hide resolved
...rc/functionalTest/kotlin/kotlinx.atomicfu.gradle.plugin.test/framework/runner/BuildRunner.kt
Outdated
Show resolved
Hide resolved
...rc/functionalTest/kotlin/kotlinx.atomicfu.gradle.plugin.test/framework/runner/BuildRunner.kt
Show resolved
Hide resolved
integration-testing/build.gradle.kts
Outdated
} | ||
|
||
plugins { | ||
kotlin("jvm") version "${project.properties["kotlin_version"]}" // todo: is there a more consise way to get kotlin_version from gradle.properties? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe versions catalog?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I configure version catalog like this, I get "The root project is not yet available for build." 👀
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
version("atomicfu", gradle.rootProject.properties["atomicfu_version"])
}
}
}
...esting/src/functionalTest/kotlin/kotlinx.atomicfu.gradle.plugin.test/cases/MppProjectTest.kt
Outdated
Show resolved
Hide resolved
return BuildResult(exitCode, logFile) | ||
} | ||
|
||
private fun buildSystemCommand(projectDir: File, commands: List<String>, properties: List<String>): List<String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to use TestKit instead of a custom GradleRunner - because supporting it in the future requires additional labor.
TextKit has some problems with the plugin's classpath, however, if configured correctly, they should not appear.
|
||
internal fun GradleBuild.clean(): BuildResult = runGradle(listOf("clean")) | ||
|
||
internal fun GradleBuild.build(): BuildResult = runGradle(listOf("clean", "build")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cleanAndBuild
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
val output: String by lazy { logFile.readText() } | ||
|
||
// Gets the list of dependencies for the given configuration | ||
fun getDependenciesForConfig(configuration: String): List<String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to use regular expressions
@@ -0,0 +1,28 @@ | |||
buildscript { | |||
val atomicfu_version = rootProject.properties["atomicfu_version"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can override the plugin version in settings.gradle.kts
file. In this case, it will be possible to apply the plugin in the plugins { }
block
pluginManagement {
resolutionStrategy {
eachPlugin {
val fuVersion = gradle.rootProject.properties["atomicfu_version"]?.toString()
if (fuVersion != null && requested.id.id != "kotlinx-atomicfu") {
useVersion(fuVersion)
}
}
}
}
private fun Project.configureMultiplatformPluginDependencies(version: String) { | ||
val multiplatformExtension = kotlinExtension as? KotlinMultiplatformExtension ?: error("Expected kotlin multiplatform extension") | ||
val atomicfuDependency = "org.jetbrains.kotlinx:atomicfu:$version" | ||
multiplatformExtension.sourceSets.getByName("commonMain").dependencies { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can there be a situation when there are no commonMain
or commonTest
source sets in the project?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess, commonMain и commonTest always exist in the mpp project acording to the kotlin-gradle-plugin structure
The reason of the current build failure: mavenTest depends on |
This comment was marked as resolved.
This comment was marked as resolved.
As an extra effort to keep things nice and clean, it might be worth adding a separate set of publishToLocal tasks that will write artifacts to a temporary repo in the build directory (like int tests do). |
I fixed |
...onalTest/kotlin/kotlinx.atomicfu.gradle.plugin.test/framework/checker/DependenciesChecker.kt
Outdated
Show resolved
Hide resolved
...rc/functionalTest/kotlin/kotlinx.atomicfu.gradle.plugin.test/framework/runner/BuildRunner.kt
Outdated
Show resolved
Hide resolved
...rc/functionalTest/kotlin/kotlinx.atomicfu.gradle.plugin.test/framework/runner/BuildRunner.kt
Outdated
Show resolved
Hide resolved
integration-testing/examples/mpp-sample/src/commonTest/kotlin/IntArithmeticTest.kt
Outdated
Show resolved
Hide resolved
- made integration-testing part of the rootProject - removed duplicated gradle.properties - integration-testing depends on atomicfu-gradle-plugin publication
Pass atomicfu and kotlin versions to sample projects as parameters
…blication of the atomicfu-gradle-plugin
…ck atomicfu jar file
This reverts commit 7b10481.
…by the time of atomicfu-gradle-plugin application
…IntArithmeticTest.kt Co-authored-by: Filipp Zhinkin <filipp.zhinkin@gmail.com>
fd3ad7a
to
ea02a32
Compare
Rebased on the latest develop with Kotlin updated to 1.9.20 |
Well, something happened (after rebase to develop with updated Kotlin 1.9.20) and mpp-sample build is failing with this error again 🪦
|
@@ -25,6 +25,7 @@ apply(plugin = "kotlinx-atomicfu") | |||
|
|||
repositories { | |||
mavenCentral() | |||
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to have these repos ordered differently in jvm- and mpp-sample projects?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with unresolved classes from kotlin-stdlib
may've been caused by the maven local repository being corrupted by some other process, and it's priority caused gradle to search for stdlib classes there first. As gradle can not work properly with mavenLocal
, it's better not to set it first in the repo list .
This PR introduces the framework for atomicfu-gradle-plugin integration tests.
To run functional tests:
Current problems:
Do not copy versions in build scripts of sample projects #gradle
Add tests for the JS IR backend
DependenciesChecker
: should also check apiElements and runtimeElements configurationsDependenciesChecker
: it'd be nice to check .module or .pom files after publication of the project for "consumable" dependencies that will not be present in thedependencies
outputAtomicfuGradlePlugin
: configuration of dependencies for MPP project should be reviewed, currently it causes Mpp dependency test to failklib dump-ir checks are not enabled for now because of this known problem KT-61143, looking for WA