Skip to content

[tests] Share + shrink api-24.xml.in fixture (~56 MiB → 393 KB)#1484

Merged
jonathanpeppers merged 1 commit into
mainfrom
jonathanpeppers-shrink-api-24-fixtures
Jun 26, 2026
Merged

[tests] Share + shrink api-24.xml.in fixture (~56 MiB → 393 KB)#1484
jonathanpeppers merged 1 commit into
mainfrom
jonathanpeppers-shrink-api-24-fixtures

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

The two api-24.xml.in files under tests/ were each ~28 MiB (56 MiB total in the repo) and nearly identical — only 5 annotated-visibility="TESTS" markers (used by JavaTypeModelsTests.AnnotatedVisibility) differed.

This PR consolidates them into a single shared file under tests/TestData/ and trims it down to ~393 KB (685 of the original 3,823 types). All 30 tests still pass:

  • Java.Interop.Tools.JavaTypeSystem-Tests: 17/17
  • Xamarin.Android.Tools.ApiXmlAdjuster-Tests: 13/13

Changes

  • Move tests/Java.Interop.Tools.JavaTypeSystem-Tests/api-24.xml.intests/TestData/api-24.xml.in (preserves the TESTS annotations).
  • Delete the duplicate under tests/Xamarin.Android.Tools.ApiXmlAdjuster-Tests/.
  • Point both JavaApiTestHelper.cs files at the shared path.
  • Xamarin.Android.Tools.ApiXmlAdjuster's loader does not recognize annotated-visibility, so its helper strips that attribute in-memory before parsing.
  • Trim the shared XML to the transitive type-resolution closure required by the test assertions, then strip <method>, <field>, and <constructor> bodies from types whose bodies no test inspects. Bodies are kept only on a small allowlist:
    • android.database.ContentObservable + android.database.Observable — generic registerObserver mapping
    • java.util.concurrent.ConcurrentHashMapsearchEntries generic resolution
    • android.app.ActivityaddContentView BaseMethod lookup
    • android.animation.StateListAnimator, android.drm.DrmStore.ConstraintsColumnsAnnotatedVisibility

Result

Before After
Files 2 × ~28 MiB 1 × ~393 KB
Types 3,823 685
Tests 30/30 ✅ 30/30 ✅

Net diff: 5 files changed, 2637 insertions(+), 2087250 deletions(-).

The two `api-24.xml.in` files were ~28 MiB each (56 MiB total) and
nearly identical: only 5 `annotated-visibility="TESTS"` markers (used
by `JavaTypeModelsTests.AnnotatedVisibility`) differed.

Consolidate them into a single shared file under `tests/TestData/` and
strip it down to ~390 KB while keeping all 30 tests (17 in
`Java.Interop.Tools.JavaTypeSystem-Tests` + 13 in
`Xamarin.Android.Tools.ApiXmlAdjuster-Tests`) passing.

Changes:
* Move `Java.Interop.Tools.JavaTypeSystem-Tests/api-24.xml.in` to
  `tests/TestData/api-24.xml.in` (preserves the TESTS annotations).
* Delete the duplicate copy under
  `Xamarin.Android.Tools.ApiXmlAdjuster-Tests`.
* Point both `JavaApiTestHelper.cs` files at the shared path.
* `Xamarin.Android.Tools.ApiXmlAdjuster`'s loader does not recognize
  `annotated-visibility`; strip the attribute in-memory before parsing
  in that test project's helper.
* Trim the shared XML to the transitive type-resolution closure needed
  by the test assertions (685 types out of 3823), and additionally strip
  method/field/constructor bodies from types whose bodies aren't
  inspected by any test, keeping bodies only on a small allowlist
  (`ContentObservable`, `Observable`, `ConcurrentHashMap`,
  `Activity`, `StateListAnimator`,
  `DrmStore.ConstraintsColumns`).

Net repo size reduction: ~55.6 MiB.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 26, 2026 13:12

Copilot AI 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.

Pull request overview

Consolidates and significantly shrinks the api-24.xml.in test fixture so multiple test projects can share a single, much smaller API surface while preserving the few annotated-visibility="TESTS" markers needed by JavaTypeModelsTests.AnnotatedVisibility.

Changes:

  • Move to a shared fixture at tests/TestData/api-24.xml.in and trim it to the minimal transitive closure needed by assertions.
  • Remove the duplicate api-24.xml.in from tests/Xamarin.Android.Tools.ApiXmlAdjuster-Tests/.
  • Update both test helpers to load the shared fixture; ApiXmlAdjuster tests strip annotated-visibility before parsing.

Reviewed changes

Copilot reviewed 2 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/TestData/api-24.xml.in New shared, trimmed api-24 fixture (keeps a small number of annotated-visibility="TESTS" markers).
tests/Java.Interop.Tools.JavaTypeSystem-Tests/JavaApiTestHelper.cs Points JavaTypeSystem tests at the shared fixture path.
tests/Xamarin.Android.Tools.ApiXmlAdjuster-Tests/JavaApiTestHelper.cs Points ApiXmlAdjuster tests at the shared fixture and strips annotated-visibility before loading.
tests/Java.Interop.Tools.JavaTypeSystem-Tests/api-24.xml.in Removed/moved in favor of the shared tests/TestData fixture.
tests/Xamarin.Android.Tools.ApiXmlAdjuster-Tests/api-24.xml.in Removed duplicate fixture now replaced by shared tests/TestData copy.

Comment on lines +22 to 26
// The shared api-24.xml.in contains a handful of `annotated-visibility="TESTS"`
// markers used by Java.Interop.Tools.JavaTypeSystem-Tests. ApiXmlAdjuster's loader
// does not understand that attribute, so strip it before parsing.
var text = File.ReadAllText (ApiPath).Replace (" annotated-visibility=\"TESTS\"", "");
var api = new JavaApi ();

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I was going to fix this, but the GitHub app is freezing up because the diff is so large.

I think this is "good enough" and we can fix in the future if needed.

I mainly want to get this in, to improve the diff size at:

@jonathanpeppers jonathanpeppers merged commit b5741ec into main Jun 26, 2026
3 checks passed
@jonathanpeppers jonathanpeppers deleted the jonathanpeppers-shrink-api-24-fixtures branch June 26, 2026 13:33
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