Skip to content
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

Add WinUI tests to PlatformServices #1234

Merged
merged 1 commit into from
Sep 8, 2022

Conversation

Evangelink
Copy link
Member

No description provided.

@Evangelink Evangelink enabled auto-merge (squash) September 8, 2022 10:39
@Evangelink Evangelink merged commit ee68fd6 into microsoft:main Sep 8, 2022
@Evangelink Evangelink deleted the net6-winui branch September 8, 2022 10:54
Vijay-Braidable added a commit to Vijay-Braidable/testfx that referenced this pull request Oct 26, 2024
… references

The GetFormattedExceptionMessage method in ExceptionHelper.cs recursively traverses
the inner exceptions of an exception to build a formatted error message string.
However, it did not handle the case where the inner exceptions have a cyclic
reference, causing an infinite loop.

This change fixes that issue by keeping track of the exceptions seen during traversal
in a HashSet. If an exception is encountered again, it breaks out of the loop and
appends a "[Cyclic Exception Reference]" message to the output, avoiding the infinite
recursion.

The key changes are:

Introduce a HashSet seenExceptions to keep track of exceptions
encountered so far.

Check if the current exception has already been seen. If so, append a
"[Cyclic Exception Reference]" message and break out of the loop.

If the current exception hasn't been seen, add it to the seenExceptions set
and continue processing as before.

A new test class ExceptionHelperTests has also been added with two test methods:

GetFormattedExceptionMessage_WithCyclicExceptions_ShouldNotLoopInfinitely -
Verifies that cyclic exceptions are handled correctly and don't cause infinite loops.

GetFormattedExceptionMessage_WithNoCyclicExceptions_ShouldFormatNormally -
Ensures that the normal formatting still works as expected for non-cyclic exceptions.

This fixes microsoft#1234

Files changed:

src/Adapter/MSTest.TestAdapter/Execution/ExceptionHelper.cs
test/UnitTests/MSTestAdapter.UnitTests/Execution/ExceptionHelperTests.cs
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.

2 participants