Address review feedback on #9047 (GetRunningTasks buffer reuse)#9056
Conversation
- Clarify <remarks> contract: the hazard is calling GetRunningTasks
again on the *same* instance before consuming the previously-returned
buffer; buffers from different instances are independent. Also notes
that the production caller is single-threaded (render loop), so
copilot-pull-request-reviewer's thread-safety concerns do not apply.
- Replace brittle `Assert.Contains("3", ...)` with exact-text
assertion matching the maxCount=1 test's pattern, so the assertion
cannot accidentally pass for unrelated digits in a formatted/
localized string.
- Expose ActiveTestsRunning_MoreTestsCount to the unit-test project
via the IS_MTP_UNIT_TESTS block in PlatformResources.cs (the
resource accessor is hand-maintained).
There was a problem hiding this comment.
Pull request overview
This PR is a follow-up to #9047 that aligns the GetRunningTasks contract documentation with the actual buffer-reuse invariant, tightens a unit test assertion to avoid false positives, and exposes an additional resource accessor for unit tests.
Changes:
- Updated
TestNodeResultsState.GetRunningTasksXML remarks to clarify same-instance buffer reuse and the single-threaded production call pattern. - Strengthened
TestNodeResultsState_GetRunningTasks_WhenMoreThanMax_TruncatesAndAppendsSummaryto assert the exact localized summary text (instead of a substring match). - Added an
IS_MTP_UNIT_TESTSresource accessor forActiveTestsRunning_MoreTestsCountinPlatformResources.cs.
Show a summary per file
| File | Description |
|---|---|
| test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs | Tightens the truncation summary assertion to match the production formatting and avoid brittle substring matching. |
| src/Platform/Microsoft.Testing.Platform/Resources/PlatformResources.cs | Exposes ActiveTestsRunning_MoreTestsCount under IS_MTP_UNIT_TESTS so unit tests can format the summary string using the real localized resource. |
| src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TestNodeResultsState.cs | Clarifies the GetRunningTasks buffer reuse contract and thread-safety expectations in XML documentation. |
Copilot's findings
- Files reviewed: 3/3 changed files
- Comments generated: 0
🧪 Test quality grade — PR #90561 test method graded across 1 file. The PR upgrades a loose substring assertion (
This advisory comment was generated automatically. Grades are heuristic
|
Follow-up to #9047 (already merged) addressing review feedback that arrived on the merged PR:
<remarks>onGetRunningTasksso the contract reflects the actual invariant — the hazard is calling it again on the same instance before consuming the prior buffer (buffers from different instances are independent and may be held concurrently). Also note that the production caller (AnsiTerminalTestProgressFrame) is single-threaded, addressing the thread-safety concern raised bycopilot-pull-request-reviewer.Assert.Contains("3", tasks[2].Text)with an exact-text assertion that matches themaxCount=1test's pattern. The previous loose substring match could pass for unrelated reasons if the resource format ever changes (any'3'anywhere in a localized string).ActiveTestsRunning_MoreTestsCountto the unit-test project via theIS_MTP_UNIT_TESTSblock inPlatformResources.cs(hand-maintained accessor).No behavior change — pure docs + test tightening + a hand-maintained resource accessor.