Browse Source

Fix gradle tests (#2708)

* Add docker file for Gradle tests on TeamCity

* Remove configuring JDK for tests

* Update compose & kotlin compiler in testAndroidxCompiler
pull/2716/head
Alexey Tsvetkov 2 years ago committed by GitHub
parent
commit
8f3578bdca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      ci/docker/gradle-plugin-tests/Dockerfile
  2. 7
      gradle-plugins/buildSrc/src/main/kotlin/gradleUtils.kt
  3. 4
      gradle-plugins/compose/build.gradle.kts
  4. 4
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/DesktopApplicationTest.kt
  5. 2
      gradle-plugins/preview-rpc/build.gradle.kts

11
ci/docker/gradle-plugin-tests/Dockerfile

@ -0,0 +1,11 @@
FROM ubuntu:20.04
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update -y && \
apt-get install binutils --no-install-recommends -y && \
apt-get install fakeroot --no-install-recommends -y && \
apt-get install dpkg --no-install-recommends -y && \
apt-get install dpkg-dev --no-install-recommends -y && \
apt-get install libgl-dev --no-install-recommends -y
ENV PATH="/usr/lib/x86_64-linux-gnu/:$PATH"
RUN apt-get install openjdk-16-jdk --no-install-recommends -y

7
gradle-plugins/buildSrc/src/main/kotlin/gradleUtils.kt

@ -28,13 +28,6 @@ inline fun <reified T> Project.configureIfExists(fn: T.() -> Unit) {
val isWindows = DefaultNativePlatform.getCurrentOperatingSystem().isWindows val isWindows = DefaultNativePlatform.getCurrentOperatingSystem().isWindows
fun Test.configureJavaForComposeTest() {
val toolchains = project.extensions.getByName("javaToolchains") as JavaToolchainService
javaLauncher.set(toolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(16))
})
}
fun Project.configureAllTests(fn: Test.() -> Unit = {}) { fun Project.configureAllTests(fn: Test.() -> Unit = {}) {
fun DependencyHandler.testImplementation(notation: Any) = fun DependencyHandler.testImplementation(notation: Any) =
add(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME, notation) add(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME, notation)

4
gradle-plugins/compose/build.gradle.kts

@ -118,8 +118,9 @@ tasks.test {
* Thus, the only option is to download the necessary JDK distributions ourselves. * Thus, the only option is to download the necessary JDK distributions ourselves.
*/ */
val jdkVersionsForTests = listOf(11, 15, 18, 19) val jdkVersionsForTests = listOf(11, 15, 18, 19)
val jdkForTestsRoot = project.rootProject.layout.buildDirectory.dir("jdks").get().asFile val jdkForTestsRoot = project.gradle.gradleUserHomeDir.resolve("compose-jb-jdks")
val downloadJdksForTests = tasks.register("downloadJdksForTests") {} val downloadJdksForTests = tasks.register("downloadJdksForTests") {}
for (jdkVersion in jdkVersionsForTests) { for (jdkVersion in jdkVersionsForTests) {
val ext = if (hostOS == OS.Windows) ".zip" else ".tar.gz" val ext = if (hostOS == OS.Windows) ".zip" else ".tar.gz"
val archive = jdkForTestsRoot.resolve("$jdkVersion$ext") val archive = jdkForTestsRoot.resolve("$jdkVersion$ext")
@ -161,7 +162,6 @@ for (gradleVersion in supportedGradleVersions) {
} }
configureAllTests { configureAllTests {
configureJavaForComposeTest()
dependsOn(":publishToMavenLocal") dependsOn(":publishToMavenLocal")
systemProperty("compose.tests.compose.gradle.plugin.version", BuildProperties.deployVersion(project)) systemProperty("compose.tests.compose.gradle.plugin.version", BuildProperties.deployVersion(project))
val summaryDir = project.buildDir.resolve("test-summary") val summaryDir = project.buildDir.resolve("test-summary")

4
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/DesktopApplicationTest.kt

@ -69,8 +69,8 @@ class DesktopApplicationTest : GradlePluginTestBase() {
@Test @Test
fun testAndroidxCompiler() = testProject( fun testAndroidxCompiler() = testProject(
TestProjects.customCompiler, defaultTestEnvironment.copy( TestProjects.customCompiler, defaultTestEnvironment.copy(
kotlinVersion = "1.6.10", kotlinVersion = "1.8.0",
composeCompilerPlugin = "\"androidx.compose.compiler:compiler:1.1.1\"" composeCompilerPlugin = "\"androidx.compose.compiler:compiler:1.4.0\""
) )
).checkCustomComposeCompiler() ).checkCustomComposeCompiler()

2
gradle-plugins/preview-rpc/build.gradle.kts

@ -26,8 +26,6 @@ val serializeClasspath by tasks.registering(SerializeClasspathTask::class) {
} }
tasks.test.configure { tasks.test.configure {
configureJavaForComposeTest()
dependsOn(serializeClasspath) dependsOn(serializeClasspath)
systemProperty( systemProperty(
"org.jetbrains.compose.tests.rpc.classpath.file", "org.jetbrains.compose.tests.rpc.classpath.file",

Loading…
Cancel
Save