Skip to content

Invoke-MSTestWithCoverage.ps1 asserts coverage threshold before Set-Content, leaving the raw un-post-processed Cobertura on disk when the gate fails #565

Description

@drmoisan

Summary

scripts/vscode/Invoke-MSTestWithCoverage.ps1 asserts the coverage threshold before it writes the
post-processed Cobertura document to disk. When the assertion fails, the script throws and the
post-processed document is discarded, leaving the raw un-post-processed document at the output path.

Detail

At scripts/vscode/Invoke-MSTestWithCoverage.ps1:341-343 the threshold assertion runs ahead of the
Set-Content that persists the post-processed XML. The ordering inverts the intended behaviour in
the failing case:

Impact

Only the failure path is affected; a passing run writes the correct document. But the failure path is
exactly when someone reads the artifact to diagnose the shortfall, and what they find is a document
with different numbers than the one that produced the failure message. It also means a failed gate
leaves behind an artifact that, if fed to any downstream consumer, reports the pre-#441 inflated
denominator.

Suggested resolution

Move the Set-Content above the assertion so the judged document is persisted before the threshold
is evaluated. This is a statement reorder, not a logic change, and should be covered by a Pester test
asserting that a sub-threshold run still leaves the post-processed document on disk.

Found during the build-ci-coverage-gate-fidelity epic fan-in review; identified independently by
two review passes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions