[release/9.0-staging][wbt] Prevent InvalidOperationException on TestOutputHelper logging.#116916
Merged
ilonatommy merged 36 commits intodotnet:release/9.0-stagingfrom Jul 9, 2025
Merged
Conversation
… write to xUnit TestOutputHelper after test context has expired.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR addresses race conditions that cause InvalidOperationException when logging via TestOutputHelper by adding exception handling, disposal guards, and consolidating logging logic.
- Wraps all
TestOutputHelper.WriteLinecalls in try-catch blocks with a warning marker on failure - Introduces an
isDisposedflag to prevent handlers from writing after disposal - Attempts to consolidate duplicate handler logic in
ToolCommand
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/mono/wasm/Wasm.Build.Tests/Common/ToolCommand.cs | Wrapped both error/output data handlers’ WriteLine calls in try-catch blocks |
| src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs | Added isDisposed flag and guards around logging; updated exception and log methods |
Comments suppressed due to low confidence (3)
src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs:601
- Add unit tests that simulate
TestOutputHelpercontext expiration to verify both the exception-catching path and the buffered output fallback are exercised.
void LogData(string label, string? message)
src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs:490
- [nitpick] The flag
isDisposedis used to guard logging after handlers detach. Consider renaming it to something more descriptive (e.g.,handlersDisposedorloggingDisabled) to clarify its purpose.
bool isDisposed = false;
src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs:620
- Currently
outputBuilder.AppendLineruns unconditionally, which may produce lines withnullwhenmessageis null. Guard this call withif (message != null)to avoid logging an empty or 'null' message.
outputBuilder.AppendLine($"{label} {message}");
InvalidOperationException on TestOutputHelper logging.InvalidOperationException on TestOutputHelper logging.
Member
Author
|
/azp run runtime |
|
Azure Pipelines failed to run 1 pipeline(s). |
Member
Author
|
/azp list |
This comment was marked as resolved.
This comment was marked as resolved.
This was referenced Jun 23, 2025
Contributor
|
Tagging subscribers to this area: @akoeplinger, @matouskozak, @simonrozsival |
jeffschwMSFT
approved these changes
Jun 26, 2025
Member
jeffschwMSFT
left a comment
There was a problem hiding this comment.
approved. please get a code review. we will treat this as tell mode
This was referenced Aug 7, 2025
Closed
Closed
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tell mode, it updates only the tests.
Contributes to #105315.
Fix race condition causing "There is no currently active test" exceptions:
It also fixes the CI after #116747 merge. The PR disabling MT tests did not remove runtime job dependency on the disabled jobs. That caused runtime jobs not to get triggered as the dependency was not satisfied. This PR reverts disabling WBT MT jobs and runtime-official, keeping library MT commented out.