Modern Apps git

← Modern-Apps.git

tests: batch pure classes in measure, translate, youpipe

Commit
46858d7faae6f45179e3321f5b182aa9b7908834
Author
Vayun Mathur <[email protected]>
When
2026-11-22 00:28 UTC (14 days ago)
Parents
7d78848
Split audits: measure 146 green (105s -> 74s), translate
121 green (49s -> 44s), youpipe 505 green (265s -> 164s;
its quarantine grew by two SharedWebViewRuntime-singleton
classes after the first batched run proved the shared latch,
then fully green). uniflix was audited and deliberately left
unwired: its graph has no rustNativeLib, it already batches
via the non-Rust branch, and the DSL would be dead config.
New native/ViewModel classes must join the lists (documented
per file).

Diff

measure/build.gradle.kts
diff --git a/measure/build.gradle.kts b/measure/build.gradle.ktsindex 571b1da615..10ae953eac 100644--- a/measure/build.gradle.kts+++ b/measure/build.gradle.kts@@ -30,6 +30,47 @@ androidComponents { // measure/src/main/rust/. rustNativeLib("measure_cv", "measure") +// Only the classes below actually load libmeasure_cv: they call+// MeasureCvNative directly, construct a VioEngine (whose init reads+// VioEngine.available -> MeasureCvNative.available and creates a native+// session when present), or launch MainActivity (which builds the+// ViewModel over the same engine seam). Tests that merely call the pure+// domain math, or compose contents from fake action objects without an+// engine/ViewModel, never load the 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.measure.MainActivityAndAnalyzerTest",+            "com.vayunmathur.measure.platform.DirectByteBufferVioTest",+            "com.vayunmathur.measure.platform.SyntheticVioHarnessTest",+            "com.vayunmathur.measure.ui.MeasureContentsCoverageTest",+        )+    )+    // Shared-JVM polluters keep forkEvery = 1 in the same companion task:+    // MeasureViewModel reads the process-wide DataStoreUtils singleton+    // synchronously at init and starts viewModelScope collectors on the+    // orientation/tilt sensor flows that are never cleared when the test+    // never clears the ViewModel; persisted DataStore state also leaks+    // into classes expecting defaults. (Its init also touches+    // VioEngine.available, so these classes would load the native+    // library too โ€” another reason they cannot batch.) Audit rule: any+    // test instantiating MeasureViewModel belongs here.+    // MainActivityAndAnalyzerTest also builds one but is already+    // quarantined as a native loader above. All other classes batch.+    isolatedClasses.addAll(+        listOf(+            "com.vayunmathur.measure.platform.ArFlowViewModelTest",+            "com.vayunmathur.measure.platform.MeasureViewModelTest",+            "com.vayunmathur.measure.ui.ArMeasurePageTest",+            "com.vayunmathur.measure.ui.MeasurePagesTest",+        )+    )+}+ dependencies {     implementation(libs.androidx.camera.core)     implementation(libs.androidx.camera.camera2)
translate/build.gradle.kts
diff --git a/translate/build.gradle.kts b/translate/build.gradle.ktsindex 1f1d46064b..832f0a2c68 100644--- a/translate/build.gradle.kts+++ b/translate/build.gradle.kts@@ -10,6 +10,55 @@ launcherIcon {     symbol = "translate" } +// This module has no rustNativeLib of its own: the native load arrives+// transitively from :library:ml (libmodelrunner, via :library:ocr too),+// which is what puts this module's tests on the forkEvery = 1 path at+// all. Only the classes below actually load it: PlatformEnginesTest+// drives NllbTranslator/MadladTranslator availability (and fabricates+// model files in-class, so a handle construction โ€” which reads+// MlNative.isAvailable โ€” is reachable), and ImageTranslateScreenTest+// reaches TextRecognizer through the OCR seam (its init reads+// MlNative.isAvailable). Tests that merely reference a handle's pure+// constants, stub the engines, or compose screens from fake actions+// never load the 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.translate.platform.PlatformEnginesTest",+            "com.vayunmathur.translate.ui.ImageTranslateScreenTest",+        )+    )+    // Shared-JVM polluters keep forkEvery = 1 in the same companion task:+    // TranslateViewModel launches a viewModelScope init read over+    // TranslateSettings (the module's preferences DataStore) and calls+    // translator.isAvailable() from it, stateIns the process-wide+    // TranslateRepository.get singleton's Room flows in viewModelScope,+    // and is never cleared when the test never calls onCleared; the+    // repository singleton and persisted DataStore/Room state also leak+    // into classes expecting defaults. Audit rule: any test+    // instantiating TranslateViewModel (or launching MainActivity, which+    // builds one), using TranslateSettings directly, or using the+    // TranslateRepository singleton belongs here. ImageTranslateScreenTest+    // also instantiates the ViewModel but is already quarantined as a+    // native loader above. All other classes batch.+    isolatedClasses.addAll(+        listOf(+            "com.vayunmathur.translate.data.DataLayerTest",+            "com.vayunmathur.translate.data.DbBackedRepositoryTest",+            "com.vayunmathur.translate.platform.SharedImageIntentTest",+            "com.vayunmathur.translate.platform.ViewModelAndPagesTest",+            "com.vayunmathur.translate.ui.CameraScreenProbeTest",+            "com.vayunmathur.translate.ui.DbBackedPagesTest",+            "com.vayunmathur.translate.ui.ExpandedAndLoopTest",+            "com.vayunmathur.translate.ui.ImageAndActivityTest",+        )+    )+}+ android {     defaultConfig {         applicationId = "com.vayunmathur.translate"
youpipe/build.gradle.kts
diff --git a/youpipe/build.gradle.kts b/youpipe/build.gradle.ktsindex 51767eca4c..439d3e1cbb 100644--- a/youpipe/build.gradle.kts+++ b/youpipe/build.gradle.kts@@ -30,6 +30,73 @@ androidComponents { // extraAbis: the .so must also load on 32-bit Google TV. rustNativeLib("youpipe_extractor", "youpipe", extraAbis = listOf("armeabi-v7a")) +// Only the class below actually loads libyoupipe_extractor: it calls+// NativeExtractor.*, which initialises YouPipeNative (the one+// NativeLoader.load("youpipe_extractor") attempt) and then invokes the+// external functions. Tests that only exercise NativeExtractor.unwrap,+// the NewPipe-extractor helpers in network/Extractor.kt, or DTO/JSON+// contracts never initialise YouPipeNative and stay in the main task.+// Quarantine the loader 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.add("com.vayunmathur.youpipe.nativeext.NativeExtractorDispatchDeepTest")+    // Shared-JVM polluters keep forkEvery = 1 in the same companion task:+    // YouPipeViewModel stateIns (SharingStarted.WhileSubscribed) more+    // than a dozen repository flows plus the process-wide DataStoreUtils+    // singleton's flows (sponsor-block, language, default page, playback+    // speed, ...) in viewModelScope, and is never cleared when the test+    // never calls onCleared; persisted DataStoreUtils state also leaks+    // into classes expecting defaults. Audit rule: any test+    // instantiating YouPipeViewModel (or launching MainActivity, which+    // builds one via its factory) belongs here. Tests that build only an+    // in-memory SubscriptionDatabase/repository seam without the+    // ViewModel batch. The two Sabr WebView classes below share the+    // process-wide SharedWebViewRuntime singleton (same Robolectric+    // @Config, hence the same sandbox classloader in a shared JVM):+    // each calls SharedWebViewRuntime.get(ctx).warmUp() and depends on+    // its stored init-failure latch, so they must not share a JVM with+    // each other either. All other classes batch.+    isolatedClasses.addAll(+        listOf(+            "com.vayunmathur.youpipe.RootSlice3Pass2Test",+            "com.vayunmathur.youpipe.RootSlice3RouteTest",+            "com.vayunmathur.youpipe.network.sabr.SabrSlice1StoreDownloadTest",+            "com.vayunmathur.youpipe.network.sabr.SabrSlice1WebViewTest",+            "com.vayunmathur.youpipe.platform.ImportExportDeepTest",+            "com.vayunmathur.youpipe.platform.SharedLinkDeepTest",+            "com.vayunmathur.youpipe.platform.VideoLoadingDeepTest",+            "com.vayunmathur.youpipe.ui.C9Slice2PagesTest",+            "com.vayunmathur.youpipe.ui.ChannelPageDeepTest",+            "com.vayunmathur.youpipe.ui.DataSettingsRowsPass3Test",+            "com.vayunmathur.youpipe.ui.ExpandedWidthPass3Test",+            "com.vayunmathur.youpipe.ui.HistoryInteractionsPass3Test",+            "com.vayunmathur.youpipe.ui.ManageInterestsActionsPass3Test",+            "com.vayunmathur.youpipe.ui.OrientationHistoryPass3Test",+            "com.vayunmathur.youpipe.ui.PagesPass3Test",+            "com.vayunmathur.youpipe.ui.PhonePlayerSearchDeepTest",+            "com.vayunmathur.youpipe.ui.PhoneVideoDeepTest",+            "com.vayunmathur.youpipe.ui.PlayerMenusPass3Test",+            "com.vayunmathur.youpipe.ui.PlaylistInteractionsPass3Test",+            "com.vayunmathur.youpipe.ui.SavedPlaylistMorePass3Test",+            "com.vayunmathur.youpipe.ui.SettingsDialogsMorePass3Test",+            "com.vayunmathur.youpipe.ui.SettingsDownloadsPass3Test",+            "com.vayunmathur.youpipe.ui.SubscriptionsSettingsNavPass3Test",+            "com.vayunmathur.youpipe.ui.VideoPlayerPass3Test",+            "com.vayunmathur.youpipe.ui.ViewModelHarnessPass3Test",+            "com.vayunmathur.youpipe.ui.dialogs.RootSlice3PlaylistDialogsTest",+            "com.vayunmathur.youpipe.ui.tv.TvBrowseDeepTest",+            "com.vayunmathur.youpipe.ui.tv.TvFeedDeepTest",+            "com.vayunmathur.youpipe.ui.tv.TvPagesDeep2Test",+            "com.vayunmathur.youpipe.ui.tv.TvPagesTest",+            "com.vayunmathur.youpipe.ui.tv.TvPlayerDeepTest",+            "com.vayunmathur.youpipe.ui.tv.TvSearchChannelDeepTest",+            "com.vayunmathur.youpipe.ui.tv.TvSearchDownloadsDeepTest",+        )+    )+}+ android {     defaultConfig {         applicationId = "com.vayunmathur.youpipe"