Fix non-instrumentation variants not being able to run unit tests.

This commit is contained in:
Cody Henthorne
2026-05-20 12:23:55 -04:00
committed by jeffrey-signal
parent 4d0919c9a8
commit 16de2efa9e
2 changed files with 9 additions and 6 deletions
+3
View File
@@ -524,6 +524,9 @@ android {
androidComponents {
beforeVariants { variant ->
variant.enable = variant.name in selectableVariants
if (variant.enable) {
(variant as? com.android.build.api.variant.HasUnitTestBuilder)?.enableUnitTest = true
}
}
onVariants(selector().all()) { variant: com.android.build.api.variant.ApplicationVariant ->
// Rename APK to include version name
+6 -6
View File
@@ -79,8 +79,8 @@ tasks.register("qa") {
// Wire up QA dependencies after all projects are evaluated
gradle.projectsEvaluated {
val appTestTask = tasks.findByPath(":Signal-Android:testPlayProdReleaseUnitTest")
val appLintTask = tasks.findByPath(":Signal-Android:lintPlayProdRelease")
val appTestTask = tasks.findByPath(":Signal-Android:testPlayProdReleaseUnitTest")!!
val appLintTask = tasks.findByPath(":Signal-Android:lintPlayProdRelease")!!
val appCompileInstrumentationTask = tasks.findByPath(":Signal-Android:compilePlayProdInstrumentationAndroidTestSources")
tasks.named("qa") {
@@ -89,8 +89,8 @@ gradle.projectsEvaluated {
dependsOn("checkStopship")
// Main app tasks
appTestTask?.let { dependsOn(it) }
appLintTask?.let { dependsOn(it) }
dependsOn(appTestTask)
dependsOn(appLintTask)
// Instrumentation
appCompileInstrumentationTask?.let { dependsOn(it) }
@@ -120,11 +120,11 @@ gradle.projectsEvaluated {
// If you let all of these things run in parallel, gradle will likely OOM.
// To avoid this, we put non-app tests and lints behind the much heavier app tests and lints.
subprojects.filter { it.name != "Signal-Android" }.forEach { subproject ->
appTestTask?.let { task ->
appTestTask.let { task ->
subproject.tasks.findByName("testDebugUnitTest")?.mustRunAfter(task)
subproject.tasks.findByName("test")?.mustRunAfter(task)
}
appLintTask?.let { task ->
appLintTask.let { task ->
subproject.tasks.findByName("lintDebug")?.mustRunAfter(task)
}
}