Skip to content

test[DeckPickerContextMenu]: load the backend so the test can run first - #21604

Merged
david-allison merged 1 commit into
ankidroid:mainfrom
criticalAY:fix/deck-picker-context-menu-backend
Aug 26, 2026
Merged

david-allison merged 1 commit into
ankidroid:mainfrom
criticalAY:fix/deck-picker-context-menu-backend

Conversation

@criticalAY

@criticalAY criticalAY commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Note

Assisted-by: Claude Opus 5

Purpose / Description

DeckPickerContextMenuTest does not extend RobolectricTest, so it never calls RustBackendLoader.ensureSetup(). It only passes when some test that does happens to run earlier in the same JVM. When it runs first, every one of its tests dies on:

java.lang.UnsatisfiedLinkError: 'byte[][] net.ankiweb.rsdroid.NativeMethods.openBackend(byte[])'
    at net.ankiweb.rsdroid.Backend.<init>(Backend.kt:86)
    at com.ichi2.anki.CollectionManager.getTR(CollectionManager.kt:188)
    at com.ichi2.anki.dialogs.DeckPickerContextMenu$DeckPickerContextMenuOption.label(DeckPickerContextMenu.kt:98)

Fixes

How Has This Been Tested?

CI and here:

  • ./gradlew :AnkiDroid:testPlayDebugUnitTest --tests "com.ichi2.anki.dialogs.DeckPickerContextMenuTest"

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the [Google Accessibility Scanner]

@criticalAY criticalAY added the Review High Priority Request for high priority review label Aug 25, 2026
@criticalAY criticalAY mentioned this pull request Aug 25, 2026
4 of 5 tasks
@david-allison

Copy link
Copy Markdown
Member

@david-allison

Copy link
Copy Markdown
Member

You can use JvmTest I believe

@criticalAY
criticalAY force-pushed the fix/deck-picker-context-menu-backend branch from 5644ce5 to f382052 Compare August 26, 2026 18:46
@criticalAY

Copy link
Copy Markdown
Contributor Author

What do you think about fixing this upstream?

Yeah makes more sense. Will review the PR upstream give me few hours

@david-allison david-allison left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm an "approve" here regardless, if there's a TODO: PERF to move it can be done

DeckPickerContextMenuTest extended no test base class, so the rust
 backend was never loaded for it. It only passed when some test which
 does load it happened to run earlier in the same JVM.

Test class discovery order is filesystem dependent, so an unrelated new
 test class elsewhere in the tree can push it to the front and turn the
 macOS JUnit job red while ubuntu and windows stay green.

JvmTest loads the backend in its fixture, so the class stands on its own.

Part of ankidroid#14796

Assisted-by: Claude Opus 5
@criticalAY
criticalAY force-pushed the fix/deck-picker-context-menu-backend branch from f382052 to d6fa5f8 Compare August 26, 2026 19:44
@criticalAY criticalAY added Needs Second Approval Has one approval, one more approval to merge and removed Needs Review labels Aug 26, 2026
@david-allison
david-allison added this pull request to the merge queue Aug 26, 2026
Merged via the queue into ankidroid:main with commit 1fa3a24 Aug 26, 2026
24 of 25 checks passed
@github-actions github-actions Bot added this to the 2.25 release milestone Aug 26, 2026
@github-actions github-actions Bot removed Review High Priority Request for high priority review Needs Second Approval Has one approval, one more approval to merge labels Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants