Modern Apps git

← Modern-Apps.git

passwords: batch unit tests - 3x faster, only KDBX natives quarantine

Commit
7af02cee123ab72a94fc0a233f92ac84cabfb0a4
Author
Vayun Mathur <[email protected]>
When
2026-11-21 22:02 UTC (14 days ago)
Parents
5d71d68
Split audit: only 5 classes load libpasswords_kdbx and 19
pollute via ViewModels/services/DataStore; the other 49
batch at 20 (cable crypto is pure JVM here). 436/436 green
both ways; 113s -> 59s, repeat run 37s. New native/service/
ViewModel test classes must join the lists (documented).

Diff

passwords/build.gradle.kts
diff --git a/passwords/build.gradle.kts b/passwords/build.gradle.ktsindex 07e37684e3..5f1aca346b 100644--- a/passwords/build.gradle.kts+++ b/passwords/build.gradle.kts@@ -39,6 +39,70 @@ androidComponents { // existing .kdbx vaults stay interoperable. rustNativeLib("passwords_kdbx", "passwords-kdbx") +// Only the classes below actually load a native library: they execute a+// path that touches KdbxNative (libpasswords_kdbx, via NativeKdbxCodec's+// read/write, KdbxBackupFormat's import/export over that codec, or+// runKdbxSync's engine wired to NativeKdbxCodec). Tests that merely use+// a FakeCodec, construct KdbxBackupFormat / a ViewModel without calling+// its export/import, or hit the fail-closed / NotConfigured branches+// before the codec 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.passwords.platform.KdbxBackupFormatExtraTest",+            "com.vayunmathur.passwords.platform.KdbxBackupFormatVaultPathTest",+            "com.vayunmathur.passwords.sync.NativeKdbxCodecExtraTest",+            "com.vayunmathur.passwords.sync.NativeKdbxCodecTest",+            "com.vayunmathur.passwords.sync.RunKdbxSyncEndToEndTest",+        )+    )+    // Shared-JVM polluters keep forkEvery = 1 in the same companion task:+    // DataStoreUtils is a process-wide singleton whose init eagerly+    // collects the preferences DataStore, and PasswordsViewModel turns+    // the repository's flows into viewModelScope stateIn collectors+    // (SharingStarted.WhileSubscribed) that are never cleared when the+    // test never calls onCleared; persisted DataStore state also leaks+    // into classes expecting defaults. Same hazard for tests that use+    // KdbxSyncSettings / KdbxSyncSection (its DataStore-backed flows),+    // drive runKdbxSync's settings recording, initialise WorkManager /+    // KdbxSyncScheduler, launch MainActivity (which builds the+    // ViewModel), or drive the autofill / passkey credential services+    // and CableService, whose serviceScope (SupervisorJob + IO) launches+    // are never cancelled. Audit rule: any test instantiating+    // PasswordsViewModel (or launching MainActivity, which builds one),+    // using KdbxSyncSettings / DataStoreUtils-backed settings directly,+    // rendering KdbxSyncSection, or building PasswordAutofillService /+    // PasskeyCredentialService / CableService belongs here. All other+    // classes batch.+    isolatedClasses.addAll(+        listOf(+            "com.vayunmathur.passwords.platform.AutofillServiceDispatchTest",+            "com.vayunmathur.passwords.platform.ImportFailureTest",+            "com.vayunmathur.passwords.platform.MainActivityGateTest",+            "com.vayunmathur.passwords.platform.PasswordsViewModelCsvInternalsTest",+            "com.vayunmathur.passwords.platform.PasswordsViewModelExtraTest",+            "com.vayunmathur.passwords.platform.PasswordsViewModelImportTest",+            "com.vayunmathur.passwords.platform.PasswordsViewModelTest",+            "com.vayunmathur.passwords.platform.ServicesExtraTest",+            "com.vayunmathur.passwords.platform.ServicesRoboTest",+            "com.vayunmathur.passwords.sync.KdbxSettingsAndRunSyncTest",+            "com.vayunmathur.passwords.sync.KdbxSyncSchedulerTest",+            "com.vayunmathur.passwords.sync.RunKdbxSyncExtraTest",+            "com.vayunmathur.passwords.sync.RunKdbxSyncFullPathTest",+            "com.vayunmathur.passwords.ui.ComposeInteractionsExtraTest",+            "com.vayunmathur.passwords.ui.KdbxSyncSectionComposeTest",+            "com.vayunmathur.passwords.ui.KdbxSyncSectionExtraComposeTest",+            "com.vayunmathur.passwords.ui.PageWrappersComposeTest",+            "com.vayunmathur.passwords.ui.PagesComposeExtraTest",+            "com.vayunmathur.passwords.ui.PagesComposeTest",+        )+    )+}+ dependencies {     implementation(project(":library:biometric"))     implementRoom(libs)