Modern Apps git

← Modern-Apps.git

weather: batch unit tests - quarantine map/native and ViewModel classes

Commit
195a680d68695e30cf15456dcfe76c32ea27e4c8
Author
Vayun Mathur <[email protected]>
When
2026-11-21 22:19 UTC (14 days ago)
Parents
2c2a378
Split audit: 4 classes load the weather/map Rust and 9
instantiate WeatherViewModel (never-cleared collectors +
WorkManager enqueue in init); 36 batch at 20. 291/291 green
both ways, 75s -> 23-37s. New native/ViewModel weather
classes must join the lists (documented).

Diff

weather/build.gradle.kts
diff --git a/weather/build.gradle.kts b/weather/build.gradle.ktsindex 82b8cec365..31163ed891 100644--- a/weather/build.gradle.kts+++ b/weather/build.gradle.kts@@ -35,6 +35,58 @@ androidComponents { // Native `.om` weather-file decoder (Rust). See weather/src/main/rust/. rustNativeLib("weather_om", "weather") +// This module loads two Rust libraries in tests: its own libweather_om+// (above) and libmap_renderer from :library:map (implementation dep+// below), so every unit test here has kept forkEvery = 1. Only the+// classes below actually load one: they render WeatherMapPage (whose+// VectorMap surface touches MapNative.isAvailable and whose metadata /+// decode effects touch OmTilesNative.isAvailable) or compose the map+// metadata/decode effects directly. Tests that merely construct+// WeatherMapState, use the pure-Kotlin WxTiles/WxGrid decoders, or stub+// the native path before isAvailable is evaluated never load a library+// and stay in the main task. Quarantine the loaders and the shared-JVM+// polluters below into testDevUnitTestNative (forkEvery = 1); the+// remaining classes batch 20-per-JVM in testDevUnitTest, which depends+// on the quarantine task so the usual invocation still runs everything.+rustNativeTests {+    nativeClasses.addAll(+        listOf(+            "com.vayunmathur.weather.ui.MapDecodeCacheTest",+            "com.vayunmathur.weather.ui.MapPageTest",+            "com.vayunmathur.weather.ui.PagesTest",+            "com.vayunmathur.weather.ui.Wave3bWeatherCoverageTest",+        )+    )+    // Shared-JVM polluters keep forkEvery = 1 in the same companion task:+    // WeatherViewModel turns the repository's locations flow into a+    // viewModelScope stateIn collector (SharingStarted.WhileSubscribed)+    // that is never cleared when the test never calls onCleared, and its+    // init enqueues WeatherRefreshWorker's hourly WorkManager work;+    // its fetch paths also launch viewModelScope coroutines the test+    // drains by polling. Same hazard for tests that launch MainActivity+    // (which builds the ViewModel over WeatherRepository.get's+    // process-wide singleton). This module has no DataStore owner (its+    // datastore dependency is unused by main/test sources), so no+    // DataStore polluters exist here. Audit rule: any test instantiating+    // WeatherViewModel (or launching MainActivity, which builds one)+    // belongs here; Wave3bWeatherCoverageTest and PagesTest also+    // instantiate one but are already quarantined as native loaders+    // above. All other classes batch.+    isolatedClasses.addAll(+        listOf(+            "com.vayunmathur.weather.platform.ViewModelAddLocationTest",+            "com.vayunmathur.weather.platform.ViewModelDeviceFixTest",+            "com.vayunmathur.weather.platform.ViewModelFetchTest",+            "com.vayunmathur.weather.platform.ViewModelSuccessTest",+            "com.vayunmathur.weather.platform.WeatherViewModelTest",+            "com.vayunmathur.weather.ui.DeviceLocationGrantedTest",+            "com.vayunmathur.weather.ui.HomeAndLocationsExtraTest",+            "com.vayunmathur.weather.ui.MoreEdgesTest",+            "com.vayunmathur.weather.ui.Wave3WeatherCoverageTest",+        )+    )+}+ dependencies {     implementation(project(":library:network"))     implementation(project(":library:widgets"))