Modern Apps git

← Modern-Apps.git

camera: batch unit tests - pure Camera2 tests never needed their own JVM

Commit
42e8d3a95657b27a3073532ed1af0d9e1a3ebfa6
Author
Vayun Mathur <[email protected]>
When
2026-11-21 21:23 UTC (14 days ago)
Parents
5eb57ab
123 classes forked per-class. Audit quarantines 64 (native
loaders - StitchNative/night/pano/RAW host tests - plus
ViewModel/session polluters) and batches 59, including all
21 pure Camera2 driver-fake tests and the domain suite.
751/751 green both ways; forks drop from ~185 JVMs to 64 + 3
batched, wall 187s -> 172s on a shared box (a floor, not the
ceiling). New camera classes loading natives or driving
ViewModels/sessions must join the lists (documented).

Diff

camera/build.gradle.kts
diff --git a/camera/build.gradle.kts b/camera/build.gradle.ktsindex 323bf9a721..31efb92e41 100644--- a/camera/build.gradle.kts+++ b/camera/build.gradle.kts@@ -32,8 +32,108 @@ androidComponents { }  // Native panorama stitcher + night burst aligner (Rust). See camera/src/main/rust/.+// camera_stitch also links vision_core (library/vision), and :library:ml's+// modelrunner is in the graph too, so the host .so set is not just camera's own. rustNativeLib("camera_stitch", "camera") +// Only the classes below actually load a native library: they call+// StitchNative directly (the two host-.so tests), execute a path that+// touches StitchNative.isAvailable (PanoramaEngine.startSweep/stitch,+// NightCaptureEngine.merge), or construct a segmenter that loads+// :library:ml's modelrunner (BokehAnalyzer -> SelfieSegmenter,+// StillBokehRenderer -> ModnetSegmenter). Tests that merely call the pure+// math helpers (NightCaptureEngine.mergeScaledDimensions,+// GpuStitcher.parseEstimate, LumaPlaneMath) or the pure Camera2 driver+// fakes under platform/camera2 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.camera.platform.BokehAnalyzerMathTest",+            "com.vayunmathur.camera.platform.BurstConvertExtraTest",+            "com.vayunmathur.camera.platform.CameraControlsExtraTest",+            "com.vayunmathur.camera.platform.CameraCovC2LogicTest",+            "com.vayunmathur.camera.platform.CameraCovC2PanoramaSensorTest",+            "com.vayunmathur.camera.platform.CameraCovW3Wave4Test",+            "com.vayunmathur.camera.platform.CameraCovW3Wave8Test",+            "com.vayunmathur.camera.platform.CameraCovX4SessionsTest",+            "com.vayunmathur.camera.platform.LumaStatsNativeTest",+            "com.vayunmathur.camera.platform.NightCaptureEngineMathTest",+            "com.vayunmathur.camera.platform.PanoramaEngineExtraTest",+            "com.vayunmathur.camera.platform.PanoramaSaveExtraTest",+            "com.vayunmathur.camera.platform.PortraitBokehMathTest",+            "com.vayunmathur.camera.platform.StillEncoderNativeTest",+            "com.vayunmathur.camera.ui.CameraCovX4ComposeTest",+        )+    )+    // Shared-JVM polluters keep forkEvery = 1 in the same companion task:+    // CameraViewModel's init runs loadSettings() over the process-wide+    // DataStoreUtils singleton and starts viewModelScope collectors+    // (SharingStarted.Eagerly stateIn flows plus launch{} collectors)+    // that are never cleared when the test never calls onCleared;+    // persisted DataStore state also leaks into classes expecting+    // defaults. Audit rule: any test instantiating CameraViewModel or+    // launching MainActivity (which builds one), or using+    // DataStoreUtils / the CameraSettings extensions directly, belongs+    // here. All other classes batch.+    isolatedClasses.addAll(+        listOf(+            "com.vayunmathur.camera.MainActivityExtraTest",+            "com.vayunmathur.camera.data.SafPrepareExtraTest",+            "com.vayunmathur.camera.platform.AeConvergenceGateTest",+            "com.vayunmathur.camera.platform.CameraCovC2CapabilitiesTest",+            "com.vayunmathur.camera.platform.CameraCovC2SessionsTest",+            "com.vayunmathur.camera.platform.CameraCovW3MockSessionsTest",+            "com.vayunmathur.camera.platform.CameraCovW3SessionsTest",+            "com.vayunmathur.camera.platform.CameraCovW3Wave11Test",+            "com.vayunmathur.camera.platform.CameraCovW3Wave3Test",+            "com.vayunmathur.camera.platform.CameraCovW3Wave5Test",+            "com.vayunmathur.camera.platform.CameraCovW3Wave6Test",+            "com.vayunmathur.camera.platform.CameraCovW3Wave7Test",+            "com.vayunmathur.camera.platform.CameraCovW3Wave9Test",+            "com.vayunmathur.camera.platform.CameraCovX4CaptureTest",+            "com.vayunmathur.camera.platform.CameraCovX4CharacteristicsTest",+            "com.vayunmathur.camera.platform.CameraSessionBindRetryTest",+            "com.vayunmathur.camera.platform.CameraSessionsExtraTest",+            "com.vayunmathur.camera.platform.CameraSettingsExtraTest",+            "com.vayunmathur.camera.platform.CameraViewModelLogicTest",+            "com.vayunmathur.camera.platform.CaptureProcessingMathTest",+            "com.vayunmathur.camera.platform.CaptureRoutingExtraTest",+            "com.vayunmathur.camera.platform.ControlsRecordingExtraTest",+            "com.vayunmathur.camera.platform.FinalCoverageExtraTest",+            "com.vayunmathur.camera.platform.ManualControlsExtraTest",+            "com.vayunmathur.camera.platform.ManualPreviewExposureTest",+            "com.vayunmathur.camera.platform.MediaStoreSaverAndProcessingTest",+            "com.vayunmathur.camera.platform.MotionPhotoCaptureStateTest",+            "com.vayunmathur.camera.platform.NightCaptureRestoreTest",+            "com.vayunmathur.camera.platform.NightLogicExtraTest",+            "com.vayunmathur.camera.platform.NightSessionEntryExtraTest",+            "com.vayunmathur.camera.platform.QuerySessionConfigExtraTest",+            "com.vayunmathur.camera.platform.RecordingRebindDeferralTest",+            "com.vayunmathur.camera.platform.Restore3AExtraTest",+            "com.vayunmathur.camera.platform.SessionEntryPointsTest",+            "com.vayunmathur.camera.platform.SessionLaddersExtraTest",+            "com.vayunmathur.camera.platform.SingleCaptureNightTest",+            "com.vayunmathur.camera.platform.SloMoLogicExtraTest",+            "com.vayunmathur.camera.platform.ZslGatingTest",+            "com.vayunmathur.camera.ui.BottomControlsComposeExtraTest",+            "com.vayunmathur.camera.ui.CameraBindFailedComposeTest",+            "com.vayunmathur.camera.ui.CameraCovC2ScreenStatesTest",+            "com.vayunmathur.camera.ui.CameraCovC2SettingsTest",+            "com.vayunmathur.camera.ui.CameraCovW3ComposeTest",+            "com.vayunmathur.camera.ui.CameraCovW3Wave6ComposeTest",+            "com.vayunmathur.camera.ui.CameraScreenComposeTest",+            "com.vayunmathur.camera.ui.CameraScreenModesComposeTest",+            "com.vayunmathur.camera.ui.CameraSettingsPageComposeTest",+            "com.vayunmathur.camera.ui.PreviewGalleryComposeExtraTest",+            "com.vayunmathur.camera.ui.SettingsInteractionsComposeTest",+        )+    )+}+ dependencies {     implementation(libs.androidx.camera.core)     implementation(libs.androidx.camera.camera2)