Modern Apps git

← Modern-Apps.git

build: let compile-only stub modules have no tests

Commit
2abaa68ef358192043b208795decc0ee97547d5c
Author
Vayun Mathur <[email protected]>
When
2026-11-21 07:24 UTC (15 days ago)
Parents
6cd44f1
library:aosp-stubs has 37 stub classes and zero tests, but the shared-test helper injected into every library source set made Gradle 9 see sources and discover none - a deterministic failure in every CI run. Compile-only stub modules now set failOnNoDiscoveredTests=false on their unit test task.

Verified: :library:aosp-stubs:testDebugUnitTest passes.

Diff

build-logic/src/main/kotlin/common-conventions-library.gradle.kts
diff --git a/build-logic/src/main/kotlin/common-conventions-library.gradle.kts b/build-logic/src/main/kotlin/common-conventions-library.gradle.ktsindex 05befb2538..4ab0c5c058 100644--- a/build-logic/src/main/kotlin/common-conventions-library.gradle.kts+++ b/build-logic/src/main/kotlin/common-conventions-library.gradle.kts@@ -1,4 +1,5 @@ import org.gradle.api.tasks.bundling.AbstractArchiveTask+import org.gradle.api.tasks.testing.Test import org.gradle.testing.jacoco.tasks.JacocoReport  plugins {@@ -197,6 +198,15 @@ if (project.path in COMPILE_ONLY_STUB_MODULES) {     tasks.named(MERGED_COVERAGE_TASK) {         onlyIf("compile-only stub module (see TestCoverage.kt)") { false }     }+    // No real tests: the shared-test helper is injected into every library's+    // test source set, so Gradle 9 sees sources but discovers zero tests and+    // would fail the task. Allow empty discovery for stub modules only.+    // Lazy: AGP creates testDebugUnitTest after this convention applies.+    tasks.withType<Test>().configureEach {+        if (name == "testDebugUnitTest") {+            failOnNoDiscoveredTests.set(false)+        }+    } }  tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {