From b490e8971e43a9ee20d69b240edf63b49d1433c3 Mon Sep 17 00:00:00 2001 From: Marcello Albano Date: Fri, 10 Nov 2023 00:16:25 +0000 Subject: Fixed branch for cherrypick aosp/2823110 Test: existing Bug: n/a (cherry picked from https://android-review.googlesource.com/q/commit:a411af27953557a1d62b6a854ee9f557811a0345) Merged-In: I741fdb3e8a6017b37eb27ad0f2778f8523e99f33 Change-Id: I741fdb3e8a6017b37eb27ad0f2778f8523e99f33 --- .../BaselineProfileAppTargetPluginTest.kt | 16 ++++---- .../consumer/BaselineProfileConsumerPluginTest.kt | 44 ++++++++++++---------- .../producer/BaselineProfileProducerPluginTest.kt | 20 +++++----- .../baselineprofile/gradle/utils/Constants.kt | 17 +++------ 4 files changed, 49 insertions(+), 48 deletions(-) diff --git a/benchmark/baseline-profile-gradle-plugin/src/test/kotlin/androidx/baselineprofile/gradle/apptarget/BaselineProfileAppTargetPluginTest.kt b/benchmark/baseline-profile-gradle-plugin/src/test/kotlin/androidx/baselineprofile/gradle/apptarget/BaselineProfileAppTargetPluginTest.kt index 92660a31816..4babdfbf53c 100644 --- a/benchmark/baseline-profile-gradle-plugin/src/test/kotlin/androidx/baselineprofile/gradle/apptarget/BaselineProfileAppTargetPluginTest.kt +++ b/benchmark/baseline-profile-gradle-plugin/src/test/kotlin/androidx/baselineprofile/gradle/apptarget/BaselineProfileAppTargetPluginTest.kt @@ -17,9 +17,9 @@ package androidx.baselineprofile.gradle.apptarget import androidx.baselineprofile.gradle.utils.BaselineProfileProjectSetupRule -import androidx.baselineprofile.gradle.utils.TEST_AGP_VERSION_8_0_0 -import androidx.baselineprofile.gradle.utils.TEST_AGP_VERSION_8_1_0 -import androidx.baselineprofile.gradle.utils.TEST_AGP_VERSION_ALL +import androidx.baselineprofile.gradle.utils.TestAgpVersion +import androidx.baselineprofile.gradle.utils.TestAgpVersion.TEST_AGP_VERSION_8_0_0 +import androidx.baselineprofile.gradle.utils.TestAgpVersion.TEST_AGP_VERSION_8_1_0 import androidx.baselineprofile.gradle.utils.build import androidx.baselineprofile.gradle.utils.buildAndAssertThatOutput import com.google.common.truth.Truth.assertThat @@ -66,15 +66,15 @@ private val buildGradle = """ """.trimIndent() @RunWith(Parameterized::class) -class BaselineProfileAppTargetPluginTest(agpVersion: String?) { +class BaselineProfileAppTargetPluginTest(agpVersion: TestAgpVersion) { @get:Rule - val projectSetup = BaselineProfileProjectSetupRule(forceAgpVersion = agpVersion) + val projectSetup = BaselineProfileProjectSetupRule(forceAgpVersion = agpVersion.versionString) companion object { @Parameterized.Parameters(name = "agpVersion={0}") @JvmStatic - fun parameters() = TEST_AGP_VERSION_ALL + fun parameters() = TestAgpVersion.values() } @Test @@ -134,7 +134,7 @@ class BaselineProfileAppTargetPluginTestWithAgp80 { @get:Rule val projectSetup = BaselineProfileProjectSetupRule( - forceAgpVersion = TEST_AGP_VERSION_8_0_0 + forceAgpVersion = TEST_AGP_VERSION_8_0_0.versionString ) @Test @@ -172,7 +172,7 @@ class BaselineProfileAppTargetPluginTestWithAgp81 { @get:Rule val projectSetup = BaselineProfileProjectSetupRule( - forceAgpVersion = TEST_AGP_VERSION_8_1_0 + forceAgpVersion = TEST_AGP_VERSION_8_1_0.versionString ) @Test diff --git a/benchmark/baseline-profile-gradle-plugin/src/test/kotlin/androidx/baselineprofile/gradle/consumer/BaselineProfileConsumerPluginTest.kt b/benchmark/baseline-profile-gradle-plugin/src/test/kotlin/androidx/baselineprofile/gradle/consumer/BaselineProfileConsumerPluginTest.kt index 5c47623a83f..38b3357e2d5 100644 --- a/benchmark/baseline-profile-gradle-plugin/src/test/kotlin/androidx/baselineprofile/gradle/consumer/BaselineProfileConsumerPluginTest.kt +++ b/benchmark/baseline-profile-gradle-plugin/src/test/kotlin/androidx/baselineprofile/gradle/consumer/BaselineProfileConsumerPluginTest.kt @@ -21,9 +21,9 @@ import androidx.baselineprofile.gradle.utils.ANDROID_LIBRARY_PLUGIN import androidx.baselineprofile.gradle.utils.ANDROID_TEST_PLUGIN import androidx.baselineprofile.gradle.utils.BaselineProfileProjectSetupRule import androidx.baselineprofile.gradle.utils.Fixtures -import androidx.baselineprofile.gradle.utils.TEST_AGP_VERSION_8_0_0 -import androidx.baselineprofile.gradle.utils.TEST_AGP_VERSION_8_1_0 -import androidx.baselineprofile.gradle.utils.TEST_AGP_VERSION_ALL +import androidx.baselineprofile.gradle.utils.TestAgpVersion +import androidx.baselineprofile.gradle.utils.TestAgpVersion.TEST_AGP_VERSION_8_0_0 +import androidx.baselineprofile.gradle.utils.TestAgpVersion.TEST_AGP_VERSION_8_1_0 import androidx.baselineprofile.gradle.utils.VariantProfile import androidx.baselineprofile.gradle.utils.build import androidx.baselineprofile.gradle.utils.buildAndAssertThatOutput @@ -44,16 +44,16 @@ import org.junit.runners.Parameterized private const val EXPECTED_PROFILE_FOLDER = "generated/baselineProfiles" @RunWith(Parameterized::class) -class BaselineProfileConsumerPluginTest(private val agpVersion: String?) { +class BaselineProfileConsumerPluginTest(private val agpVersion: TestAgpVersion) { companion object { @Parameterized.Parameters(name = "agpVersion={0}") @JvmStatic - fun parameters() = TEST_AGP_VERSION_ALL + fun parameters() = TestAgpVersion.values() } @get:Rule - val projectSetup = BaselineProfileProjectSetupRule(forceAgpVersion = agpVersion) + val projectSetup = BaselineProfileProjectSetupRule(forceAgpVersion = agpVersion.versionString) private val gradleRunner by lazy { projectSetup.consumer.gradleRunner } @@ -67,10 +67,12 @@ class BaselineProfileConsumerPluginTest(private val agpVersion: String?) { "src/$variantName/$EXPECTED_PROFILE_FOLDER/startup-prof.txt" ) - private fun mergedArtProfile(variantName: String) = File( - projectSetup.consumer.rootDir, - "build/intermediates/merged_art_profile/$variantName/baseline-prof.txt" - ) + private fun mergedArtProfile(variantName: String): File { + return File( + projectSetup.consumer.rootDir, + "build/intermediates/merged_art_profile/$variantName/baseline-prof.txt" + ) + } private fun readBaselineProfileFileContent(variantName: String): List = baselineProfileFile(variantName).readLines() @@ -1022,7 +1024,10 @@ class BaselineProfileConsumerPluginTest(private val agpVersion: String?) { """.trimIndent() ) - data class VariantAndProfile(val variantName: String, val profile: List) + data class VariantAndProfile( + val variantName: String, + val profile: List + ) val freeRelease = VariantAndProfile( variantName = "freeRelease", @@ -1051,10 +1056,11 @@ class BaselineProfileConsumerPluginTest(private val agpVersion: String?) { paidReleaseProfileLines = paidRelease.profile, ) - gradleRunner - .build("mergeFreeReleaseArtProfile", "mergePaidReleaseArtProfile") {} + val variants = arrayOf(freeRelease, paidRelease) + val tasks = variants.map { camelCase("merge", it.variantName, "ArtProfile") } + gradleRunner.build(*(tasks.toTypedArray())) {} - arrayOf(freeRelease, paidRelease).forEach { + variants.forEach { val notFound = mergedArtProfile(it.variantName) .readLines() .require(*(it.profile).toTypedArray()) @@ -1371,7 +1377,7 @@ class BaselineProfileConsumerPluginTestWithAgp80 { @get:Rule val projectSetup = BaselineProfileProjectSetupRule( - forceAgpVersion = TEST_AGP_VERSION_8_0_0 + forceAgpVersion = TEST_AGP_VERSION_8_0_0.versionString ) @Test @@ -1535,7 +1541,7 @@ class BaselineProfileConsumerPluginTestWithAgp81 { @get:Rule val projectSetup = BaselineProfileProjectSetupRule( - forceAgpVersion = TEST_AGP_VERSION_8_1_0 + forceAgpVersion = TEST_AGP_VERSION_8_1_0.versionString ) @Test @@ -1746,17 +1752,17 @@ class BaselineProfileConsumerPluginTestWithAgp81 { } @RunWith(Parameterized::class) -class BaselineProfileConsumerPluginTestWithKmp(agpVersion: String?) { +class BaselineProfileConsumerPluginTestWithKmp(agpVersion: TestAgpVersion) { companion object { @Parameterized.Parameters(name = "agpVersion={0}") @JvmStatic - fun parameters() = TEST_AGP_VERSION_ALL + fun parameters() = TestAgpVersion.values() } @get:Rule val projectSetup = BaselineProfileProjectSetupRule( - forceAgpVersion = agpVersion, + forceAgpVersion = agpVersion.versionString, addKotlinGradlePluginToClasspath = true ) diff --git a/benchmark/baseline-profile-gradle-plugin/src/test/kotlin/androidx/baselineprofile/gradle/producer/BaselineProfileProducerPluginTest.kt b/benchmark/baseline-profile-gradle-plugin/src/test/kotlin/androidx/baselineprofile/gradle/producer/BaselineProfileProducerPluginTest.kt index af8be8ea120..eeb142e0fc9 100644 --- a/benchmark/baseline-profile-gradle-plugin/src/test/kotlin/androidx/baselineprofile/gradle/producer/BaselineProfileProducerPluginTest.kt +++ b/benchmark/baseline-profile-gradle-plugin/src/test/kotlin/androidx/baselineprofile/gradle/producer/BaselineProfileProducerPluginTest.kt @@ -17,10 +17,10 @@ package androidx.baselineprofile.gradle.producer import androidx.baselineprofile.gradle.utils.BaselineProfileProjectSetupRule -import androidx.baselineprofile.gradle.utils.TEST_AGP_VERSION_8_0_0 -import androidx.baselineprofile.gradle.utils.TEST_AGP_VERSION_8_1_0 -import androidx.baselineprofile.gradle.utils.TEST_AGP_VERSION_8_2_0 -import androidx.baselineprofile.gradle.utils.TEST_AGP_VERSION_ALL +import androidx.baselineprofile.gradle.utils.TestAgpVersion +import androidx.baselineprofile.gradle.utils.TestAgpVersion.TEST_AGP_VERSION_8_0_0 +import androidx.baselineprofile.gradle.utils.TestAgpVersion.TEST_AGP_VERSION_8_1_0 +import androidx.baselineprofile.gradle.utils.TestAgpVersion.TEST_AGP_VERSION_8_2_0 import androidx.baselineprofile.gradle.utils.VariantProfile import androidx.baselineprofile.gradle.utils.build import androidx.baselineprofile.gradle.utils.buildAndAssertThatOutput @@ -38,7 +38,7 @@ class BaselineProfileProducerPluginTestWithAgp80 { @get:Rule val projectSetup = BaselineProfileProjectSetupRule( - forceAgpVersion = TEST_AGP_VERSION_8_0_0 + forceAgpVersion = TEST_AGP_VERSION_8_0_0.versionString ) private val emptyReleaseVariantProfile = VariantProfile( @@ -70,7 +70,7 @@ class BaselineProfileProducerPluginTestWithAgp81 { @get:Rule val projectSetup = BaselineProfileProjectSetupRule( - forceAgpVersion = TEST_AGP_VERSION_8_1_0 + forceAgpVersion = TEST_AGP_VERSION_8_1_0.versionString ) private val emptyReleaseVariantProfile = VariantProfile( @@ -103,7 +103,7 @@ class BaselineProfileProducerPluginTestWithAgp82 { @get:Rule val projectSetup = BaselineProfileProjectSetupRule( - forceAgpVersion = TEST_AGP_VERSION_8_2_0 + forceAgpVersion = TEST_AGP_VERSION_8_2_0.versionString ) private val emptyReleaseVariantProfile = VariantProfile( @@ -184,16 +184,16 @@ class BaselineProfileProducerPluginTestWithAgp82 { } @RunWith(Parameterized::class) -class BaselineProfileProducerPluginTest(agpVersion: String?) { +class BaselineProfileProducerPluginTest(agpVersion: TestAgpVersion) { companion object { @Parameterized.Parameters(name = "agpVersion={0}") @JvmStatic - fun parameters() = TEST_AGP_VERSION_ALL + fun parameters() = TestAgpVersion.values() } @get:Rule - val projectSetup = BaselineProfileProjectSetupRule(forceAgpVersion = agpVersion) + val projectSetup = BaselineProfileProjectSetupRule(forceAgpVersion = agpVersion.versionString) private val emptyReleaseVariantProfile = VariantProfile( flavor = null, diff --git a/benchmark/baseline-profile-gradle-plugin/src/test/kotlin/androidx/baselineprofile/gradle/utils/Constants.kt b/benchmark/baseline-profile-gradle-plugin/src/test/kotlin/androidx/baselineprofile/gradle/utils/Constants.kt index 220b1d2bc51..ea5d250f127 100644 --- a/benchmark/baseline-profile-gradle-plugin/src/test/kotlin/androidx/baselineprofile/gradle/utils/Constants.kt +++ b/benchmark/baseline-profile-gradle-plugin/src/test/kotlin/androidx/baselineprofile/gradle/utils/Constants.kt @@ -16,14 +16,9 @@ package androidx.baselineprofile.gradle.utils -internal const val TEST_AGP_VERSION_8_0_0 = "8.0.0-beta03" -internal const val TEST_AGP_VERSION_8_1_0 = "8.1.0-beta05" -internal const val TEST_AGP_VERSION_8_2_0 = "8.2.0-alpha04" -internal val TEST_AGP_VERSION_CURRENT = null - -internal val TEST_AGP_VERSION_ALL = arrayOf( - TEST_AGP_VERSION_8_0_0, - TEST_AGP_VERSION_8_1_0, - TEST_AGP_VERSION_8_2_0, - TEST_AGP_VERSION_CURRENT, -) +enum class TestAgpVersion(val versionString: String?) { + TEST_AGP_VERSION_8_0_0("8.0.0-beta03"), + TEST_AGP_VERSION_8_1_0("8.1.0-beta05"), + TEST_AGP_VERSION_8_2_0("8.2.0-alpha04"), + TEST_AGP_VERSION_CURRENT(null) +} -- cgit v1.2.3