Skip to content

Commit

Permalink
Fix integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsonlee committed Dec 1, 2022
1 parent 41d7282 commit a62c739
Show file tree
Hide file tree
Showing 61 changed files with 130 additions and 332 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,27 @@ jobs:
with:
name: booster-android-gradle-v7_2
path: booster-android-gradle-v7_2/build/reports/tests/integrationTest

integration-test-agp-v7_3:
name: AGP 7.3 Integration Test
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '11'
cache: 'gradle'
- uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ github.run_number }}
- shell: bash
run: ./gradlew booster-android-gradle-v7_3:integrationTest -S --no-daemon -Pversion=${{ github.run_number }}
- uses: actions/upload-artifact@v3
if: failure()
with:
name: booster-android-gradle-v7_3
path: booster-android-gradle-v7_3/build/reports/tests/integrationTest

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import java.io.File
/**
* The project which this variant belongs
*/
@Suppress("DEPRECATION")
val BaseVariant.project: Project
get() = AGP.run { project }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ class ResolvedArtifactResults(private val variant: BaseVariant) : Collection<Res
.sortedBy { it.id.componentIdentifier.displayName }
.toList()

private val maxNameWidth = map { it.id.componentIdentifier.displayName.length }.maxOrNull() ?: 0
private val maxNameWidth = map { it.id.componentIdentifier.displayName.length }.max() ?: 0

private val maxFileWidth = map { it.file.path.length }.maxOrNull() ?: 0
private val maxFileWidth = map { it.file.path.length }.max() ?: 0

override val size: Int
get() = results.count()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
@file:Suppress("DEPRECATION")

package com.didiglobal.booster.android.gradle.v3_3

import com.android.build.gradle.AppExtension
import com.android.build.gradle.BaseExtension
import com.android.build.gradle.LibraryExtension
import com.android.build.gradle.api.BaseVariant
import com.android.builder.core.VariantTypeImpl
import com.android.sdklib.BuildToolInfo
import com.didiglobal.booster.gradle.AGP
import com.didiglobal.booster.gradle.getAndroid
Expand All @@ -31,12 +28,11 @@ import kotlin.test.assertNotNull
import kotlin.test.assertTrue
import kotlin.test.fail

private const val MIN_SDK_VERSION = 18
private val MIN_SDK_VERSION = System.getProperty("android.minsdk.version").toInt()

private const val TARGET_SDK_VERSION = 26

private val ARGS = arrayOf(
"assemble", "-S",
private val ARGS = System.getProperty("gradle.args").split("\\s+".toRegex()) + listOf(
"-Pbooster_version=${Build.VERSION}",
"-Pandroid_gradle_version=3.3.0",
"-Pcompile_sdk_version=28",
Expand All @@ -53,7 +49,7 @@ abstract class V33IntegrationTest(private val isLib: Boolean) {
@get:Rule
val ruleChain: TestRule = rule(projectDir) {
rule(LocalProperties(projectDir::getRoot)) {
GradleExecutor(projectDir::getRoot, "4.10.1", *ARGS)
GradleExecutor(projectDir::getRoot, "4.10.1", *ARGS.toTypedArray())
}
}

Expand Down Expand Up @@ -139,10 +135,6 @@ abstract class V33IntegrationTest(private val isLib: Boolean) {
@Case(TargetSdkVersionTestUnit::class)
fun `test AGPInterface#targetSdkVersion`() = Unit

@Test
@Case(VariantTypeTestUnit::class)
fun `test AGPInterface#variantType`() = Unit

@Test
@Case(AarTestUnit::class)
fun `test AGPInterface#aar`() = Unit
Expand Down Expand Up @@ -328,18 +320,6 @@ class TargetSdkVersionTestUnit : VariantTestCase() {
}
}

class VariantTypeTestUnit : VariantTestCase() {
override fun apply(variant: BaseVariant) {
val project = AGP.run { variant.project }
val variantType = AGP.run { variant.variantType }
if (project.plugins.hasPlugin("com.android.application")) {
assertEquals(VariantTypeImpl.BASE_APK, variantType)
} else if (project.plugins.hasPlugin("com.android.library")) {
assertEquals(VariantTypeImpl.LIBRARY, variantType)
}
}
}

class AarTestUnit : VariantTestCase() {
override fun apply(project: Project) {
if (project.plugins.hasPlugin("com.android.library")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ internal object V33 : AGPInterface {
get() = mergeResourcesProvider

override val BaseVariant.mergeNativeLibsTaskProvider: TaskProvider<out Task>
get() = @Suppress("DEPRECATION") project.tasks.named("transformNativeLibsWithMergeJniLibsFor${name.capitalize()}")
get() = project.tasks.named("transformNativeLibsWithMergeJniLibsFor${name.capitalize()}")

override val BaseVariant.processJavaResourcesTaskProvider: TaskProvider<out Task>
get() = processJavaResourcesProvider
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
@file:Suppress("DEPRECATION")

package com.didiglobal.booster.android.gradle.v3_4

import com.android.build.gradle.AppExtension
import com.android.build.gradle.BaseExtension
import com.android.build.gradle.LibraryExtension
import com.android.build.gradle.api.BaseVariant
import com.android.builder.core.VariantTypeImpl
import com.android.sdklib.BuildToolInfo
import com.didiglobal.booster.gradle.AGP
import com.didiglobal.booster.gradle.getAndroid
Expand All @@ -31,12 +28,11 @@ import kotlin.test.assertNotNull
import kotlin.test.assertTrue
import kotlin.test.fail

private const val MIN_SDK_VERSION = 18
private val MIN_SDK_VERSION = System.getProperty("android.minsdk.version").toInt()

private const val TARGET_SDK_VERSION = 26

private val ARGS = arrayOf(
"assemble", "-S",
private val ARGS = System.getProperty("gradle.args").split("\\s+".toRegex()) + listOf(
"-Pbooster_version=${Build.VERSION}",
"-Pandroid_gradle_version=3.4.0",
"-Pcompile_sdk_version=28",
Expand All @@ -53,7 +49,7 @@ abstract class V34IntegrationTest(private val isLib: Boolean) {
@get:Rule
val ruleChain: TestRule = rule(projectDir) {
rule(LocalProperties(projectDir::getRoot)) {
GradleExecutor(projectDir::getRoot, "5.1.1", *ARGS)
GradleExecutor(projectDir::getRoot, "5.1.1", *ARGS.toTypedArray())
}
}

Expand Down Expand Up @@ -139,10 +135,6 @@ abstract class V34IntegrationTest(private val isLib: Boolean) {
@Case(TargetSdkVersionTestUnit::class)
fun `test AGPInterface#targetSdkVersion`() = Unit

@Test
@Case(VariantTypeTestUnit::class)
fun `test AGPInterface#variantType`() = Unit

@Test
@Case(AarTestUnit::class)
fun `test AGPInterface#aar`() = Unit
Expand Down Expand Up @@ -328,18 +320,6 @@ class TargetSdkVersionTestUnit : VariantTestCase() {
}
}

class VariantTypeTestUnit : VariantTestCase() {
override fun apply(variant: BaseVariant) {
val project = AGP.run { variant.project }
val variantType = AGP.run { variant.variantType }
if (project.plugins.hasPlugin("com.android.application")) {
assertEquals(VariantTypeImpl.BASE_APK, variantType)
} else if (project.plugins.hasPlugin("com.android.library")) {
assertEquals(VariantTypeImpl.LIBRARY, variantType)
}
}
}

class AarTestUnit : VariantTestCase() {
override fun apply(project: Project) {
if (project.plugins.hasPlugin("com.android.library")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ internal object V34 : AGPInterface {
get() = mergeResourcesProvider

override val BaseVariant.mergeNativeLibsTaskProvider: TaskProvider<out Task>
get() = @Suppress("DEPRECATION") project.tasks.named("transformNativeLibsWithMergeJniLibsFor${name.capitalize()}")
get() = project.tasks.named("transformNativeLibsWithMergeJniLibsFor${name.capitalize()}")

override val BaseVariant.processJavaResourcesTaskProvider: TaskProvider<out Task>
get() = processJavaResourcesProvider
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
@file:Suppress("DEPRECATION")

package com.didiglobal.booster.android.gradle.v3_5

import com.android.build.gradle.AppExtension
import com.android.build.gradle.BaseExtension
import com.android.build.gradle.LibraryExtension
import com.android.build.gradle.api.BaseVariant
import com.android.builder.core.VariantTypeImpl
import com.android.sdklib.BuildToolInfo
import com.didiglobal.booster.gradle.AGP
import com.didiglobal.booster.gradle.getAndroid
Expand All @@ -31,18 +28,17 @@ import kotlin.test.assertNotNull
import kotlin.test.assertTrue
import kotlin.test.fail

private const val MIN_SDK_VERSION = 18
private val MIN_SDK_VERSION = System.getProperty("android.minsdk.version").toInt()

private const val TARGET_SDK_VERSION = 26

private val ARGS = arrayOf(
"assemble", "-S",
private val ARGS = System.getProperty("gradle.args").split("\\s+".toRegex()) + listOf(
"-Pbooster_version=${Build.VERSION}",
"-Pandroid_gradle_version=3.5.0",
"-Pcompile_sdk_version=28",
"-Pbuild_tools_version=26.0.3",
"-Pmin_sdk_version=${MIN_SDK_VERSION}",
"-Ptarget_sdk_version=${TARGET_SDK_VERSION}"
"-Ptarget_sdk_version=${TARGET_SDK_VERSION}",
)

@Suppress("RemoveCurlyBracesFromTemplate", "FunctionName")
Expand All @@ -53,7 +49,7 @@ abstract class V35IntegrationTest(private val isLib: Boolean) {
@get:Rule
val ruleChain: TestRule = rule(projectDir) {
rule(LocalProperties(projectDir::getRoot)) {
GradleExecutor(projectDir::getRoot, "5.4.1", *ARGS)
GradleExecutor(projectDir::getRoot, "5.4.1", *ARGS.toTypedArray())
}
}

Expand Down Expand Up @@ -139,10 +135,6 @@ abstract class V35IntegrationTest(private val isLib: Boolean) {
@Case(TargetSdkVersionTestUnit::class)
fun `test AGPInterface#targetSdkVersion`() = Unit

@Test
@Case(VariantTypeTestUnit::class)
fun `test AGPInterface#variantType`() = Unit

@Test
@Case(AarTestUnit::class)
fun `test AGPInterface#aar`() = Unit
Expand Down Expand Up @@ -328,18 +320,6 @@ class TargetSdkVersionTestUnit : VariantTestCase() {
}
}

class VariantTypeTestUnit : VariantTestCase() {
override fun apply(variant: BaseVariant) {
val project = AGP.run { variant.project }
val variantType = AGP.run { variant.variantType }
if (project.plugins.hasPlugin("com.android.application")) {
assertEquals(VariantTypeImpl.BASE_APK, variantType)
} else if (project.plugins.hasPlugin("com.android.library")) {
assertEquals(VariantTypeImpl.LIBRARY, variantType)
}
}
}

class AarTestUnit : VariantTestCase() {
override fun apply(project: Project) {
if (project.plugins.hasPlugin("com.android.library")) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
@file:Suppress("DEPRECATION")

package com.didiglobal.booster.android.gradle.v3_6

import com.android.build.gradle.AppExtension
import com.android.build.gradle.BaseExtension
import com.android.build.gradle.LibraryExtension
import com.android.build.gradle.api.BaseVariant
import com.android.builder.core.VariantTypeImpl
import com.android.sdklib.BuildToolInfo
import com.didiglobal.booster.gradle.AGP
import com.didiglobal.booster.gradle.getAndroid
Expand All @@ -31,12 +28,11 @@ import kotlin.test.assertNotNull
import kotlin.test.assertTrue
import kotlin.test.fail

private const val MIN_SDK_VERSION = 18
private val MIN_SDK_VERSION = System.getProperty("android.minsdk.version").toInt()

private const val TARGET_SDK_VERSION = 26

private val ARGS = arrayOf(
"assemble", "-S",
private val ARGS = System.getProperty("gradle.args").split("\\s+".toRegex()) + listOf(
"-Pbooster_version=${Build.VERSION}",
"-Pandroid_gradle_version=3.6.0",
"-Pcompile_sdk_version=28",
Expand All @@ -53,7 +49,7 @@ abstract class V36IntegrationTest(private val isLib: Boolean) {
@get:Rule
val ruleChain: TestRule = rule(projectDir) {
rule(LocalProperties(projectDir::getRoot)) {
GradleExecutor(projectDir::getRoot, "5.6.4", *ARGS)
GradleExecutor(projectDir::getRoot, "5.6.4", *ARGS.toTypedArray())
}
}

Expand Down Expand Up @@ -139,10 +135,6 @@ abstract class V36IntegrationTest(private val isLib: Boolean) {
@Case(TargetSdkVersionTestUnit::class)
fun `test AGPInterface#targetSdkVersion`() = Unit

@Test
@Case(VariantTypeTestUnit::class)
fun `test AGPInterface#variantType`() = Unit

@Test
@Case(AarTestUnit::class)
fun `test AGPInterface#aar`() = Unit
Expand Down Expand Up @@ -328,18 +320,6 @@ class TargetSdkVersionTestUnit : VariantTestCase() {
}
}

class VariantTypeTestUnit : VariantTestCase() {
override fun apply(variant: BaseVariant) {
val project = AGP.run { variant.project }
val variantType = AGP.run { variant.variantType }
if (project.plugins.hasPlugin("com.android.application")) {
assertEquals(VariantTypeImpl.BASE_APK, variantType)
} else if (project.plugins.hasPlugin("com.android.library")) {
assertEquals(VariantTypeImpl.LIBRARY, variantType)
}
}
}

class AarTestUnit : VariantTestCase() {
override fun apply(project: Project) {
if (project.plugins.hasPlugin("com.android.library")) {
Expand Down
Loading

0 comments on commit a62c739

Please sign in to comment.