Skip to content

test: Replace binaries with bytecode loaded from test deps#1341

Open
0xadam-brown wants to merge 12 commits into
mainfrom
chore/deps-not-binaries
Open

test: Replace binaries with bytecode loaded from test deps#1341
0xadam-brown wants to merge 12 commits into
mainfrom
chore/deps-not-binaries

Conversation

@0xadam-brown

@0xadam-brown 0xadam-brown commented Jun 23, 2026

Copy link
Copy Markdown
Member

📜 Description

Follow-up to the convo here about checked-in bytecode fixtures. For the easy cases, tests now load real library classes from test dependencies instead of committed .class files.

Why not the rest?

The remaining fixtures are harder in that we can't just fetch a dep from Maven + delete an existing binary. Instead, we'd have to pin deps or a fixture regen pipeline, each of which would be more involved than a quick-win, sometimes without much payoff.

💡 Motivation and Context

Let's us avoid (potentially fragile and always static) binary check-ins and instead rely on evergreen dependencies.

💚 How did you test it?

Ran test suite after swapping out binaries.

📝 Checklist

  • I reviewed the submitted code
  • I added tests to verify the changes
  • I updated the docs if needed
  • No breaking changes

🔮 Next steps

0xadam-brown and others added 10 commits June 10, 2026 17:27
… users (GRADLE-107)

Adds a new ASM bytecode method visitor that lets us auto-wrap all occurrences of SQLiteDriver with SentrySQLiteDriver whenever the driver is passed to Room.DatabaseBuilder.setDriver(...).

For instance:

val database = Room.databaseBuilder(context, MyDatabase::class.java, "dbName")
     .setDriver(AndroidSQLiteDriver())
     .build()

becomes:

val database = Room.databaseBuilder(context, MyDatabase::class.java, "dbName")
     .setDriver(SentrySQLiteDriver.create(AndroidSQLiteDriver()))
     .build()

The wrapping policy is naive in that every SQLiteDriver passed to setDriver() is wrapped. That's deliberate because SentrySQLiteDriver protects against double-wrapping internally, which lets us keep our visitor implementation simple.

Preconditions:

1. InstrumentationFeature.DATABASE is enabled
2. The owning app is using a version of sentry-android-sqlite that includes SentrySQLiteDriver

Coverage:

- Auto-wraps SQLiteDriver for all Room users (sole Room access point is via its Room.DatabaseBuilder.setDriver() method).
- SQLDelight users don't need driver auto-wrapping (they still use SupportSQLiteOpenHelper, which we already auto-wrap).
- The few developers who use SQLiteDriver directly will need to wrap it manually.
Replace checked-in RoomDatabase$Builder fixtures with classpath loading
from room-runtime-android and room3-runtime-android AARs so tests track
Dependabot version bumps automatically.

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Replace checked-in AndroidX SQLite framework and TypefaceCompatUtil
fixtures with classpath loading from sqlite-framework and androidx.core
AARs on the test classpath.

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@0xadam-brown 0xadam-brown force-pushed the chore/deps-not-binaries branch from b2f9e38 to aeecebf Compare June 23, 2026 20:59

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit aeecebf. Configure here.

Align sqlite-framework bytecode and FrameworkSQLiteStatement SemVer so
VisitorTest exercises the post-2.3.0 instrumentation path.

@runningcode runningcode left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Very nice! I think this is much easier to maintain than checking in .class files!

@runningcode

Copy link
Copy Markdown
Contributor

What do you mean by this?

Instead, we'd have to pin deps or a fixture regen pipeline

We do want to pin our dependencies as part of a security audit. I'm not sure what the fixture regen pipeline means

* - AndroidX SQLite framework classes: `androidx.sqlite:sqlite-framework`
* - `TypefaceCompatUtil`: `androidx.core:core`
*/
private val FIXTURE_TO_RESOURCE =

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.

wondering if we need to maintain this mapping or rather change VisitorTest parameters to fit the new structure? I guess simply passing a FQN should be enough when loading from an aar

mapOf(
"androidx.room.RoomDatabase\$Builder" to "RoomDatabase\$Builder",
"androidx.room3.RoomDatabase\$Builder" to "RoomDatabase3\$Builder",
"androidx.room.RoomDatabase\$Builder" to "androidx/room/RoomDatabase\$Builder.class",

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.

also not sure if this one is needed, we could just append .class when we load, right?

Base automatically changed from feat/wrap-sqlite-driver to main June 25, 2026 05:05
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.

3 participants