photos: batch unit tests - quarantine native loaders and scope polluters
- Commit
feda441eed012a690913352d752c3db2331ae244- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-21 21:20 UTC (14 days ago)
- Parents
54a1822
112 classes forked per-class for Rust in the graph. Audit: 6 classes actually load native (PhotosNative adjustments, library:ml handle probers) and 57 pollute shared JVMs - 32 via the eagerly-collecting DataStoreUtils singleton drivers, 25 PhotoEdit/VideoEdit ViewModel instantiators (proven by a leaked render job surfacing in a sibling test's sandbox) - run quarantined; 51 classes batch at 20. Before 3m28s (with one pre-existing flow-timing failure), after 1m58s, 806/806 green - the flake passes quarantined. New photos classes loading natives or instantiating these ViewModels/stores must join the lists (documented in file).
Diff
photos/build.gradle.kts
diff --git a/photos/build.gradle.kts b/photos/build.gradle.ktsindex cb7566f1eb..961aeca252 100644--- a/photos/build.gradle.kts+++ b/photos/build.gradle.kts@@ -34,6 +34,111 @@ androidComponents { // Native pixel filters (Rust). See photos/src/main/rust/. rustNativeLib("photos_fx", "photos") +// Only the classes below actually load a native library: they execute a+// PhotosNative-backed adjustment (Blur/Stylize/Liquify via the *Data+// applyToBitmap extensions, reached directly or through LayerCompositor)+// or probe the :library:ml bridges (FaceRecognizer.modelsAvailable /+// detectAndEmbed, ClipEmbedder.embeddingSupport — both construct+// FaceDetector/FaceEmbedder/ClipHandle, whose initialisers touch+// MlNative and load libmodelrunner). Classes that merely use the pure+// FaceRecognizer/ClipEmbedder helpers (similarity, l2Normalize,+// floatsToBytes), construct identity adjustments, or stub the ML paths+// never load either 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.photos.data.AdjustmentBitmapsRealTest",+ "com.vayunmathur.photos.data.PhotosSlice1DataPass3Test",+ "com.vayunmathur.photos.util.PhotosCovC2CompositorTest",+ "com.vayunmathur.photos.util.PhotosCovC2IndexingTest",+ "com.vayunmathur.photos.util.PhotosCovC2LogicTest",+ "com.vayunmathur.photos.util.PhotosSlice1MlInertTest",+ )+ )+ // Shared-JVM polluters keep forkEvery = 1 in the same companion task:+ // GalleryViewModel and SecureFolderViewModel eagerly collect the+ // process-wide DataStoreUtils singleton (its init launches a+ // DataStore collector) from viewModelScope on the Robolectric main+ // looper, and the Sync/Face workers and LiveWallpaper paths drive+ // the same singleton; leaked collectors and persisted DataStore+ // state leak into classes expecting defaults. The editor ViewModels+ // pollute the same way: PhotoEditViewModel/VideoEditViewModel launch+ // preview/composite jobs in viewModelScope that outlive the test and+ // render through LayerCompositor on a torn-down Robolectric sandbox+ // (observed: a leaked renderTextPixels NPE surfacing as+ // UncaughtExceptionsBeforeTest in the next batched class). Audit+ // rule: any test instantiating GalleryViewModel/+ // SecureFolderViewModel/PhotoEditViewModel/VideoEditViewModel,+ // launching MainActivity (which builds them), or driving+ // SyncWorker/FaceWorker/LiveWallpaper/DataStoreUtils directly+ // belongs here. All other classes batch.+ isolatedClasses.addAll(+ listOf(+ "com.vayunmathur.photos.MainActivityRealLaunchTest",+ "com.vayunmathur.photos.service.LiveWallpaperServiceRealTest",+ "com.vayunmathur.photos.ui.AlbumDetailAndPickerTest",+ "com.vayunmathur.photos.ui.FavoriteToggleComposeTest",+ "com.vayunmathur.photos.ui.FavoritesWallpaperMotionTest",+ "com.vayunmathur.photos.ui.GalleryActionsRealRepoTest",+ "com.vayunmathur.photos.ui.GalleryPageDeepDriveTest",+ "com.vayunmathur.photos.ui.PhotoDetailAndFilmstripTest",+ "com.vayunmathur.photos.ui.PhotosPagesDeepDriveTest",+ "com.vayunmathur.photos.ui.VaultViewerPageRealTest",+ "com.vayunmathur.photos.ui.WallpaperSetFlowTest",+ "com.vayunmathur.photos.util.GalleryViewModelRealRepoTest",+ "com.vayunmathur.photos.util.PhotosCovC2NavigationTest",+ "com.vayunmathur.photos.util.PhotosCovC2PagesTest",+ "com.vayunmathur.photos.util.PhotosCovC2VmTest",+ "com.vayunmathur.photos.util.PhotosFavoritesAlbumTest",+ "com.vayunmathur.photos.util.PhotosNavEntriesDeepTest",+ "com.vayunmathur.photos.util.PhotosNavigationDeepTest",+ "com.vayunmathur.photos.util.PhotosPagesRealRepoTest",+ "com.vayunmathur.photos.util.PhotosPrivacyFixesTest",+ "com.vayunmathur.photos.util.PhotosSlice1VaultPage2Test",+ "com.vayunmathur.photos.util.PhotosSlice1VaultUiTest",+ "com.vayunmathur.photos.util.PhotosSlice1VaultVm2Test",+ "com.vayunmathur.photos.util.PhotosSlice1VaultVm3Test",+ "com.vayunmathur.photos.util.PhotosSlice1WorkersTest",+ "com.vayunmathur.photos.util.PhotosSlice3EditPanelsTest",+ "com.vayunmathur.photos.util.PhotosSlice3ExtrasTest",+ "com.vayunmathur.photos.util.PhotosSlice3GalleryTest",+ "com.vayunmathur.photos.util.PhotosSlice3PagesTest",+ "com.vayunmathur.photos.util.PhotosSlice3VaultTest",+ "com.vayunmathur.photos.util.SecureFolderRestoreRealTest",+ "com.vayunmathur.photos.util.SyncWorkersRealRepoTest",+ "com.vayunmathur.photos.photoslice2.BottomControlsEditingPass3Test",+ "com.vayunmathur.photos.photoslice2.CurvesAndPanelsEditingPass3Test",+ "com.vayunmathur.photos.photoslice2.EditPageEditingPass3Test",+ "com.vayunmathur.photos.photoslice2.EditorStateEditingPass3Test",+ "com.vayunmathur.photos.photoslice2.LayerControllerEditingPass3Test",+ "com.vayunmathur.photos.photoslice2.LoadedPagesEditingPass3Test",+ "com.vayunmathur.photos.photoslice2.OverlaysEditingPass3Test",+ "com.vayunmathur.photos.photoslice2.PhotosCovC2EditorClickTest",+ "com.vayunmathur.photos.photoslice2.PhotosCovC2EditorTest",+ "com.vayunmathur.photos.photoslice2.RoutePreviewEditingPass3Test",+ "com.vayunmathur.photos.photoslice2.Slice2Pass2LogicTest",+ "com.vayunmathur.photos.photoslice2.Slice2Pass2PanelsTest",+ "com.vayunmathur.photos.photoslice2.SliderGestureEditingPass3Test",+ "com.vayunmathur.photos.photoslice2.StateLayerEditingPass3Test",+ "com.vayunmathur.photos.photoslice2.VideoEditingPass3Test",+ "com.vayunmathur.photos.photoslice2.VideoVmEditingPass3Test",+ "com.vayunmathur.photos.ui.EditorDriveAllModesTest",+ "com.vayunmathur.photos.ui.EditorStateFunctionsTest",+ "com.vayunmathur.photos.ui.MaskAndVideoEditPageTest",+ "com.vayunmathur.photos.ui.VideoPreviewAndCropTest",+ "com.vayunmathur.photos.util.EditControllersDeepTest",+ "com.vayunmathur.photos.util.EditSaverAndVideoWriteTest",+ "com.vayunmathur.photos.util.PhotoEditDecodeAndExportTest",+ "com.vayunmathur.photos.util.PhotosCovC2PixelTest",+ "com.vayunmathur.photos.util.VideoEditAndWallpaperRealTest",+ )+ )+}+ dependencies { implementation(libs.androidx.compose.foundation) // collectAsStateWithLifecycle in Navigation (as in :auto).