Repository navigation
perf(tests): begin conversion of tests from Robolectric to JVM - #22903
Conversation
Use `anki-backend-core` (JVM) for local backend builds and test fixtures https://redirect.github.com/ankidroid/Anki-Android-Backend/pull/770 Assisted-by: GPT-6.1-Sol xhigh
Remove Android runtime dependencies from libanki and use SLF4J logging. Keep Android cursor adapters in anki-common and restrict FrameworkDatabase to the helpers used by its callers. Document moving shared cursor paging and conversion logic into anki-backend-core. Assisted-by: GPT-6.1-Sol xhigh
`JvmTest.runTest` now uses the coroutine test scheduler, allowing ViewModel/collection tests to move away from Robolectric. Same code as already used by Robolectric Assisted-by: GPT-6.1-Sol xhigh
Assisted-by: GPT-6.1-Sol xhigh
Assisted-by: GPT-6.1-Sol xhigh
InstantTaskExecutorRule (AndroidX) is used so we don't need an Android looper. Assisted-by: GPT-6.1-Sol xhigh
OnDiskJvmTest allows for these to execute using a temp directory for these tests. Assisted-by: GPT-6.1-Sol xhigh
Assisted-by: GPT-6.1-Sol xhigh
Assisted-by: GPT-6.1-Sol xhigh
Keeping the integration checks under the Android runner (WorkManager-related) Assisted-by: GPT-6.1-Sol xhigh
Run settings checks on the JVM and retain a Robolectric integration test that verifies the factory loads the saved action and display durations. Assisted-by: GPT-6.1-Sol xhigh
Assisted-by: GPT-6.1-Sol xhigh
Assisted-by: GPT-6.1-Sol xhigh
mikehardy
left a comment
There was a problem hiding this comment.
Assisted-by: Grok 4.7
Thank you — splitting :libanki JVM SQL/cursor helpers from Android cursors while keeping the paging and leak checks in tests is the right foundation.
Locally I rebased onto main without force-pushing (prep stayed at the PR tip). I ran lint (lintAll, ktlintCheck, lint-rules:test), unit tests (jacocoUnitTestReport), and release emulator tests (TEST_RELEASE_BUILD=true via run_emulator_tests.py on emulator-5556 / API35_GAPI); all passed.
Reviewed the new :libanki module with Rust-backed DB/DBCursor, shared JVM test config, SLF4J logging in libanki, and moving pure JVM tests off Robolectric while WorkManager cases stay on device tests.
some acceptable findings, no action required, just leaving for posterity: libanki logs need an SLF4J provider on device; StringToLong.strtol edge cases; DB.mod still public and unused.
Note
Assisted-by: GPT-6.1-Sol xhigh
Purpose / Description
This is a very small and hopefully easy-to-review slice of the CI performance work which I've been running in the background.
This kicks off the work in a small, reviewable PR, and paves the way for larger changes.
I explicitly avoided including any large changes, or changes which affected production code in this commit (besides the libanki update).
It's here... this PR isn't much yet... but it opens us up for significantly faster tests!
Fixes
Approach
0.1.76-anki26.09.3+ depend directly onanki-backend-core.libankito the JVM: replace Timber with SLF4J and split out DB helpers.JvmTestfunctionality withRobolectricTestOnDiskJvmTestfor future extensionHow Has This Been Tested?
This is tests - heavily tested a larger PR where we had ~55% total test time reduction
On a subset of the tests which are affected by this PR:
31.79s -> 18.61s on my M1. 1 run
Checklist