Skip to content

Conversation

@nohwnd
Copy link
Member

@nohwnd nohwnd commented Nov 21, 2025

Fixes microsoft/vstest#15307

Context

The terminal node can be null before we receive the finish message. This will cause that some summaries are not accounted for and will be missing in the final output.

Changes Made

Always update data for messages that don't require active node.

Testing

Tested manually on local build of msbuild.

I was not able to trace why the node becomes null, please help.

Notes

Copilot AI review requested due to automatic review settings November 21, 2025 11:23
Copy link
Contributor

Copilot AI left a 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 fixes an issue where test run summaries were missing from the terminal logger output when the terminal node becomes null before receiving the test finish message. The fix ensures that test summary messages (TLTESTFINISH) are processed even when the active node is unavailable, while still protecting node-dependent operations (TLTESTPASSED/TLTESTSKIPPED) with explicit null checks.

Key Changes

  • Removed the node != null condition from the outer check, allowing all test-related extended messages to be processed regardless of node state
  • Added explicit nullable type annotation to the node variable for clarity
  • Added null checks specifically for TLTESTPASSED and TLTESTSKIPPED cases that require the node to update status
  • Removed trailing whitespace for code cleanliness

Copy link
Member

@AR-May AR-May left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes look reasonable and safe to merge to me.

It is unclear what leads to the node to be null, so we will need to investigate it. I will create an issue for that and take a look. I do not think it has to block this PR.

Copy link
Member

@JanProvaznik JanProvaznik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense to decouple

regarding when the node is null, copilot had an interesting hypothesis that it might be due to state not being restored after returning from MSBuild task

@JanProvaznik
Copy link
Member

/backport to vs17.14

@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2025

Started backporting to vs17.14 (link to workflow run)

@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2025

@JanProvaznik backporting to vs17.14 failed, the patch most likely resulted in conflicts. Please backport manually!

git am output
$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Add test summary always in terminal logger
Using index info to reconstruct a base tree...
M	src/Build/Logging/TerminalLogger/TerminalLogger.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Build/Logging/TerminalLogger/TerminalLogger.cs
CONFLICT (content): Merge conflict in src/Build/Logging/TerminalLogger/TerminalLogger.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Add test summary always in terminal logger
Error: The process '/usr/bin/git' failed with exit code 128

Link to workflow output

ViktorHofer pushed a commit that referenced this pull request Dec 4, 2025
**Description**

Running tests with dotnet test, users see inconsistent number of
projects and tests reported in the view. This is a UI only issue,
failing tests will still fail the build. It is still worth fixing the
issue because it makes the runs show repeatable numbers of tests to the
user.

The terminal node can be null before we receive the finish message. This
will cause that some summaries are not accounted for and will be missing
in the final output.

The node is null for this reason:
#12819 That fix is not
backported.

**Customer Impact:** Multiple runs of the same test suite report
different total counts of tests and projects.

**Regression?** No, this was never working correctly since the beginning
of test reporting in Terminal Logger.

**Risk:** Low, it impacts UI only.

Link the PR to the original issue and to the PR to main. 
PR to main is merged: #12801
Fixes microsoft/vstest#15307

No additional impact on packages or localization.
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.

The last line of what dotnet test prints is inconsistent.

4 participants