Added test case for #488

This commit is contained in:
Akash Yadav
2022-10-17 17:16:54 +05:30
parent 1e6cc9a962
commit af89571e80
4 changed files with 61 additions and 22 deletions
@@ -34,6 +34,7 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
import java.io.File
import kotlin.jvm.Throws
/** @author Akash Yadav */
@RunWith(JUnit4::class)
@@ -141,24 +142,43 @@ class MultiModuleAndroidProjectTest {
* Android Gradle Plugin. This test runs only in the CI environment.
*/
@Test
@Throws(CIOnlyException::class)
fun `test CI-only simple multi module project initialization with multiple AGP versions`() {
val isCi = System.getenv("TEST_TOOLING_API_IMPL").let { it == "true" }
if (!isCi) {
println("Skipping project initialization test with multiple AGP versions")
println("This test is supposed to run only in CI environment")
return
}
val versions = listOf("7.2.0", "7.2.1", "7.2.2", "7.3.0")
val client = MultiVersionTestClient()
for (version in versions) {
client.version = version
val (server, project) = ToolingApiTestLauncher().launchServer(client = client)
server
.initialize(InitializeProjectMessage(File("../../tests/test-project").absolutePath))
.get()
doAssertions(project = project, server = server)
MultiVersionTestClient.buildFile.delete()
ciOnlyTest {
val versions = listOf("7.2.0", "7.2.1", "7.2.2", "7.3.0")
val client = MultiVersionTestClient()
for (version in versions) {
client.version = version
val (server, project) = ToolingApiTestLauncher().launchServer(client = client)
server
.initialize(InitializeProjectMessage(File("../../tests/test-project").absolutePath))
.get()
doAssertions(project = project, server = server)
MultiVersionTestClient.buildFile.delete()
}
}
}
private fun ciOnlyTest(test: () -> Unit) {
try {
assertIsCI()
test()
} catch (err: CIOnlyException) {
if(shouldTestMultipleVersions()) {
throw err
}
}
}
private fun assertIsCI() {
if (!shouldTestMultipleVersions()) {
throw CIOnlyException()
}
}
private fun shouldTestMultipleVersions() : Boolean {
return System.getenv("TEST_TOOLING_API_IMPL").let { it == "true" }
}
private class CIOnlyException : IllegalStateException()
}
Binary file not shown.
+23 -4
View File
@@ -39,12 +39,31 @@ task thisIsATestTask () {
dependencies {
implementation fileTree (dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
// Issue #488
implementation 'com.unity3d.ads:unity-ads:4.4.0'
implementation 'com.google.android.gms:play-services-ads:21.2.0'
implementation platform('com.google.firebase:firebase-bom:30.5.0')
implementation 'com.google.firebase:firebase-perf'
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-firestore'
implementation 'com.google.android.gms:play-services-auth:20.3.0'
implementation 'com.google.firebase:firebase-messaging'
implementation 'com.google.firebase:firebase-database'
implementation fileTree(dir: 'libs', include: ['*.aar'])
implementation 'com.google.android.gms:play-services-appset:16.0.2'
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
implementation 'com.google.android.gms:play-services-basement:18.1.0'
implementation 'com.google.firebase:firebase-inappmessaging-display'
implementation 'com.google.android.material:material:1.8.0-alpha01'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'unresolved:unresolved:unresolved'
implementation project (path: ':another-android-library')
// implementation project (path: ':android-library')
implementation platform('com.google.firebase:firebase-bom:30.5.0')
}
+1 -1
View File
@@ -1,7 +1,7 @@
/* DO NOT EDIT - Automatically generated file */
buildscript {
ext {
build_gradle_version = "7.2.0"
build_gradle_version = "7.3.0"
}
project.ext {