Skip to content

[tests] Make DotNetPublish pack assertions deterministic - #12359

Merged
jonathanpeppers merged 2 commits into
mainfrom
jonathanpeppers-fix-pack-path-assertion
Aug 12, 2026
Merged

[tests] Make DotNetPublish pack assertions deterministic#12359
jonathanpeppers merged 2 commits into
mainfrom
jonathanpeppers-fix-pack-path-assertion

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Changes

  • remove the filesystem-enumeration-order dependency from XASdkTests.DotNetPublish
  • validate the Microsoft.Android.Ref and managed Microsoft.Android.Runtime paths actually resolved in MSBuild's detailed output
  • preserve the existing latest/non-preview TFM gate and runtime API fallback behavior

Root cause

Directory.GetDirectories(...).LastOrDefault() used unspecified filesystem enumeration order, so a stale side-by-side pack could be selected as the expected path even when MSBuild resolved another installed version.

Validation

  • dotnet-local.cmd build src\Xamarin.Android.Build.Tasks\Tests\Xamarin.Android.Build.Tests\Xamarin.Android.Build.Tests.csproj -c Debug --no-restore -v:minimal

The focused DotNetPublish run was also attempted, but this worktree could not produce the full local workload because native runtime output bin\Debug\lib\runtimes\mono\android-arm\libmono-android.debug.so was unavailable. binlogtool confirmed the test stopped at workload resolution before reaching the changed assertion.

Assert against the reference and runtime pack paths resolved in MSBuild's detailed output instead of relying on filesystem enumeration order.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2e8c3c1d-c95e-4d35-ad95-0ff027d776f0
Copilot AI lite review requested due to automatic review settings August 12, 2026 14:11

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

Pull request overview

This PR updates the XASdkTests.DotNetPublish assertions to avoid relying on unspecified filesystem enumeration order when selecting installed Android workload packs, making the test outcome deterministic and validating that MSBuild actually resolved the expected pack paths.

Changes:

  • Replaced “pick last directory” logic with a deterministic assertion that exactly one installed pack path matches what MSBuild used.
  • Captured detailed dotnet publish output once and reused it for both ref/runtime pack assertions.
  • Added a small helper (AssertUsingPack) to centralize and tighten the pack-resolution validation.

Keep AssertUsingPack generic by deriving its search filename from the supplied assembly path.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2e8c3c1d-c95e-4d35-ad95-0ff027d776f0
@jonathanpeppers jonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Aug 12, 2026
@jonathanpeppers

Copy link
Copy Markdown
Member Author

@dalexsoto review

@dalexsoto dalexsoto 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.

Pack assertions now select the logged framework pack deterministically across configurations, and exact-head tests cover the changed paths.

@jonathanpeppers
jonathanpeppers merged commit c458a05 into main Aug 12, 2026
42 of 44 checks passed
@jonathanpeppers
jonathanpeppers deleted the jonathanpeppers-fix-pack-path-assertion branch August 12, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants