Repository navigation
[tests] Verify build work instead of timing it - #13696
Conversation
Assert the generated resource classes without requiring the parser to finish within a machine-dependent time limit. Co-authored-by: Copilot App <[email protected]>
Verify that an unchanged resource build skips compilation, and that design-time builds generate resource designers without invoking Android compilation or packaging tasks (including Aapt2Compile and R8), rather than comparing wall-clock build durations. Match the detailed MSBuild log format, which has no task ID suffix, so both positive and negative assertions are meaningful. Co-authored-by: Copilot App <[email protected]>
Keep the target execution checks and verify that an unchanged build skips compilation instead of comparing build durations. Pin the ABI so the touched intermediate assemblies match the generated ones, including on arm64 hosts. Co-authored-by: Copilot App <[email protected]>
App startup does not mean the file watcher is ready. Retry distinct edits until the update handler reports success rather than sleeping before a single edit. Pass the selected adb serial to dotnet watch so the test works when multiple devices are connected. Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
The hot-reload retry and device-selection changes need human review and successful on-device validation because the reported run stopped at a WebSocket HTTP 409 conflict before applying any update.
No open issues 🎉
What changed in this PR
This PR makes .NET for Android tests less sensitive to machine load by checking generated output and executed build work instead of elapsed time.
Changes:
- Replace parser timing checks with generated-class assertions and build-duration comparisons with incremental-work checks.
- Verify design-time builds avoid Android compilation tasks, and pin the incremental-build fixture to x86_64.
- Retry distinct hot-reload edits until an update is observed, and pass the selected device to
dotnet watch.
Reported build and host-side tests passed. The hot-reload change remains unverified because a reported pre-existing WebSocket conflict blocked the device test.
| File | Description |
|---|---|
| tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs | Selects the watch device and waits for an observed hot-reload update through bounded edit retries. |
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/ManagedResourceParserTests.cs | Replaces repeated timed parsing with a generated-class count assertion. |
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/IncrementalBuildTest.cs | Pins the fixture ABI and checks that unchanged builds skip CoreCompile. |
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidUpdateResourcesTest.cs | Checks skipped incremental work and excludes Android compilation tasks from design-time builds. |
Review effort: Balanced
|
/review |
|
✅ Android PR Reviewer completed successfully!
|
There was a problem hiding this comment.
No blocking code findings; 2d0007b. Findings: 0 errors, 0 warnings, 1 non-blocking suggestion, posted inline.
Replacing elapsed-time comparisons with skipped-target and generated-output assertions is a sound improvement. The positive resource-designer log check helps ensure the negative task checks are meaningful, and the explicit ABI/device selection is consistent with the test helpers.
CI: All 39 GitHub checks report success, including the aggregate dotnet-android check for Azure build 1693169. Direct Azure build/timeline verification was unavailable because the CLI requests failed during initialization/authentication, so I could not independently confirm Azure job or non-gating device-test results. The PR also explicitly reports that the changed hot-reload path remains unverified after a macOS HTTP 409 failure; green checks alone do not establish that this device scenario passed. This review was source-based; I did not run local builds or device tests.
Generated by Android PR Reviewer for #13696 · copilot · gpt61 · 55.7 AIC · ⌖ 8.01 AIC · ⊞ 20.3K
Comment /review to run again
| var path = Path.Combine ("temp", TestName); | ||
| void AssertNoAndroidCompilation (ProjectBuilder builder) | ||
| { | ||
| foreach (var task in new [] { "Aapt2Compile", "Aapt2Link", "Javac", "D8", "R8" }) { |
There was a problem hiding this comment.
🤖 💡 Testing — Consider extending this task list to cover packaging as well, for example BuildAppBundle, BuildApkSet, and AndroidApkSigner. The new assertions directly detect unwanted compilation, but a design-time build that unexpectedly packages or signs already-generated outputs could still pass them. Checking those tasks would cover the compilation-and-packaging invariant described in the PR without bringing back a timing threshold.
{Rule: Test assertions must be specific}
ManagedParserGeneratesResourceClasses, formerly the parser speed test, only checked that 20 classes were generated. The same fixture and ManagedResourceParser.Parse path are already compared in full by GenerateDesignerFileWithÜmläüts and CompareAapt2AndManagedParserOutput. Co-authored-by: Copilot App <[email protected]>
Build duration depends on machine load and does not establish whether the expected work ran. Replace timing comparisons with checks of generated results and incremental work, and synchronize the hot-reload test with an observed update.
Remove the managed resource parser performance test
Delete
ManagedResourceParserTests.CheckPerformanceOfManagedParser, rather than retaining its temporaryManagedParserGeneratesResourceClassesrewrite. Its 160 ms threshold was sensitive to host load, and the remaining assertion only counted 20 generated classes.GenerateDesignerFileWithÜmläütsandCompareAapt2AndManagedParserOutputexercise the same fixture and managed parser path while comparing generated output. The deletion intentionally drops the parser timing signal; it does not replace it with a benchmark.Incremental resources and design-time builds
For an unchanged resource build, check that compilation and resource targets are skipped. For design-time builds, positively identify the resource-designer task and check that Android compilation and packaging tasks, including
Aapt2CompileandR8, did not run. These assertions detect unnecessary work directly instead of assuming that a faster build avoided it.Incremental target scheduling
Keep the target-execution assertions and verify that an unchanged application build skips
CoreCompile, rather than comparing the durations of clean and incremental builds. Pin the fixture's ABI so its intermediate-assembly checks inspect the files actually generated on arm64 hosts.Hot-reload readiness
App startup does not guarantee that the watcher has begun observing edits. Submit distinct edits until the update handler reports an applied update, using the existing bounded wait as a hang guard. Pass the selected device serial to
dotnet watchso another connected emulator cannot receive the run.Validation
Earlier validation was run with all five layers applied on macOS; intermediate branch heads were not built separately.
make prepare CONFIGURATION=Debug && make leeroy CONFIGURATION=Debug MSBUILD_ARGS='-m:4'— passed../dotnet-local.sh test bin/TestDebug/net11.0/Xamarin.Android.Build.Tests.dll --filter 'Name~ManagedParserGeneratesResourceClasses|Name~CancelStopsKeytool' -v minimal— passed (2 tests), before the parser test was deleted../dotnet-local.sh test bin/TestDebug/net11.0/Xamarin.Android.Build.Tests.dll --filter 'Name~RepetiviteBuildUpdateSingleResource|Name~BuildAppWithManagedResourceParserAndLibraries' -v minimal— passed (4 tests across CoreCLR and NativeAOT, including the later repetitive-build cases)../dotnet-local.sh test bin/TestDebug/net11.0/Xamarin.Android.Build.Tests.dll --filter 'Name~AppProjectTargetsDoNotBreak|Name~BasicApplicationRepetitiveBuild' -v minimal— passed (3 tests).ADB_TARGET='-s emulator-5558' ./dotnet-local.sh test bin/TestDebug/MSBuildDeviceIntegration/net11.0/MSBuildDeviceIntegration.dll --filter 'Name~DotNetWatchHotReload' -v minimal— failed on macOS with a pre-existing WebSocket conflict:Microsoft.Android.Run.dllconnects to the watch server first, so the app receives HTTP 409 before applying an update. The changed hot-reload path therefore remains unverified.After the deletion, the #13696 test sources were checked out into a separate worktree and built against its existing Debug SDK; this was not a full checkout of the layer's product code. With
Vset to the session'sfiles/audit-deletionsdirectory:./dotnet-local.sh build src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Xamarin.Android.Build.Tests.csproj -bl:$V/13696-build.binlog— passed../dotnet-local.sh test bin/TestDebug/net11.0/Xamarin.Android.Build.Tests.dll --filter 'FullyQualifiedName~Xamarin.Android.Build.Tests.ManagedResourceParserTests' --logger "trx;LogFileName=13696-parser.trx" --results-directory $V— 13 passed, 0 failed, 0 skipped, includingGenerateDesignerFileWithÜmläütsandCompareAapt2AndManagedParserOutput.