-
Notifications
You must be signed in to change notification settings - Fork 547
[RGen] Bump tests to use xunit 3 to improve the devloop #23892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Port the rgen tests to xunit 3 to improve the devloop by allowing to perform several asserts in a single exception. This allows to be able to assert all the fields of a struct making working with failed asserts in complex structs much easier. To achieve that we had to: 1. Port to xunit3 to be able to access the test current context to deal with multiple asserts. This includes updating our custom attributes. 2. Update all async methods to use the test context cancelation token, should $make tests more reliable when we are using async. The xunit analyzer was screaming at us. 3. Add some methods to test complex structs (more to come). This will make working with the rgen tests a lot easier when they fail.
There was a problem hiding this comment.
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 rgen test projects to use xUnit 3 to improve the developer workflow by enabling multiple assertions to be checked in a single test failure. The main changes include migrating from xUnit 2 to xUnit 3, updating async methods to use test context cancellation tokens, and adding helper methods for testing complex structures.
Key Changes
- Migration from xUnit 2 to xUnit 3 with updated test attributes and framework usage
- Addition of cancellation token support for all async test operations using
TestContext.Current.CancellationToken
- Introduction of custom assertion methods (
AssertEx
) for multi-scope testing of complex structures
Reviewed Changes
Copilot reviewed 59 out of 59 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
tests/rgen/xunit.runner.json | Configuration file for xUnit runner settings |
tests/rgen//Microsoft..Tests.csproj | Updated package references from xUnit 2 to xUnit 3 |
tests/rgen/Microsoft.Macios.Generator.Tests/AssertEx.cs | New custom assertion class with multi-scope testing capabilities |
tests/rgen/Directory.Build.props | Centralized package version management for test projects |
tests/common/ConfigurationXUnit.cs | Updated test data attributes for xUnit 3 compatibility |
tests/rgen/**/*Tests.cs | Updated test methods to use cancellation tokens with Roslyn APIs |
src/rgen/Microsoft.Macios.Generator/Availability/*.cs | Minor refactoring of availability system properties |
src/rgen/Microsoft.Macios.Generator/DictionaryComparer.cs | Updated generic constraints for readonly dictionary support |
src/rsp/dotnet/*-defines-dotnet.rsp | Added new framework defines for platform support |
Comments suppressed due to low confidence (1)
src/rgen/Microsoft.Macios.Generator/Availability/PlatformAvailability.cs:1
- This line declares a variable
x
that is assigned but never used. It should be removed as it serves no purpose.
// Copyright (c) Microsoft Corporation.
|
||
try { | ||
Assert.True (condition); | ||
} catch (EqualException ex) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The catch block catches EqualException
but Assert.True
throws TrueException
when the condition is false, not EqualException
. This should catch TrueException
instead.
} catch (EqualException ex) { | |
} catch (TrueException ex) { |
Copilot uses AI. Check for mistakes.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
37707a0
to
7d0c01b
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [PR Build #eca1685] Build passed (Detect API changes) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [CI Build #eca1685] Build passed (Build packages) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
MethodInfo testMethod, | ||
DisposalTracker disposalTracker) | ||
{ | ||
var classInstance = Activator.CreateInstance (dataAttributeType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be more AOT-friendly, unless I'm missing why it wouldn't work:
var classInstance = Activator.CreateInstance (dataAttributeType); | |
var classInstance = new T (); |
✅ [CI Build #eca1685] Build passed (Build macOS tests) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
💻 [CI Build #eca1685] Tests on macOS X64 - Mac Sonoma (14) passed 💻✅ All tests on macOS X64 - Mac Sonoma (14) passed. Pipeline on Agent |
💻 [CI Build #eca1685] Tests on macOS M1 - Mac Ventura (13) passed 💻✅ All tests on macOS M1 - Mac Ventura (13) passed. Pipeline on Agent |
💻 [CI Build #eca1685] Tests on macOS arm64 - Mac Sequoia (15) passed 💻✅ All tests on macOS arm64 - Mac Sequoia (15) passed. Pipeline on Agent |
💻 [CI Build #eca1685] Tests on macOS M1 - Mac Monterey (12) passed 💻✅ All tests on macOS M1 - Mac Monterey (12) passed. Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
💻 [CI Build #eca1685] Tests on macOS arm64 - Mac Tahoe (26) passed 💻✅ All tests on macOS arm64 - Mac Tahoe (26) passed. Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
🔥 [CI Build #eca1685] Test results 🔥Test results❌ Tests failed on VSTS: test results 2 tests crashed, 2 tests failed, 101 tests passed. Failures❌ generator tests
Html Report (VSDrops) Download ❌ introspection tests🔥 Failed catastrophically on VSTS: test results - introspection (no summary found). Html Report (VSDrops) Download ❌ monotouch tests (iOS)🔥 Failed catastrophically on VSTS: test results - monotouch_ios (no summary found). Html Report (VSDrops) Download ❌ xcframework tests
Html Report (VSDrops) Download Successes✅ cecil: All 1 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
Port the rgen tests to xunit 3 to improve the devloop by allowing to perform several asserts in a single exception. This allows to be able to assert all the fields of a struct making working with failed asserts in complex structs much easier. To achieve that we had to:
This will make working with the rgen tests a lot easier when they fail.