Skip to content

Add experimental MTP-mode CTS config#14355

Draft
jankratochvilcz wants to merge 2 commits into
mainfrom
feature/cts-mtp-config
Draft

Add experimental MTP-mode CTS config#14355
jankratochvilcz wants to merge 2 commits into
mainfrom
feature/cts-mtp-config

Conversation

@jankratochvilcz

Copy link
Copy Markdown
Contributor

Summary

Adds an experimental, opt-in CTS (Clever Test Selection) configuration that drives this repo's tests in their native Microsoft.Testing.Platform (MTP) form (the default xUnit.v3 runner), instead of the *.VSTest wrappers that VSTest-mode CTS uses today.

  • New: scripts/cts/cts.config.mtp.json — targets the regular *.UnitTests MTP DLLs (**/artifacts/bin/*.UnitTests/Debug/net10.0/*.UnitTests.dll) and sets RunConfiguration.TestHostResponseTimeoutSeconds to tune the CTS per-batch wedged-host timeout.
  • Updated: scripts/cts/README.md — new "MTP mode (experimental)" section documenting usage and the caveat.

The VSTest path is intentionally left untouched (scripts/cts/cts.config.json, scripts/cts/*.ps1, azure-pipelines/cts-*.yml) and remains the CI mode.

Background

CTS could not previously drive MSBuild's tests in MTP form because the CTS↔host JSON-RPC session could hang indefinitely (the reason the *.VSTest wrappers exist). That hang was root-caused to two independent issues in the CTS tool's Testing Platform driver, both fixed on the CTS side (separate PR in the vs-code-coverage repo):

  1. Windows pipe-inheritance leak — the host's redirected stdout/stderr pipe handles could be inherited by a grandchild the host spawns; WaitForExitAsync then waits for a pipe EOF that never arrives.
  2. Wedged JSON-RPC handshake — a host could connect but never drive the session to completion, with no timeout on the driver side.

The CTS fix waits for real process exit + bounded output drain, and adds a per-batch timeout that kills a wedged host and retries the affected tests on a fresh process. That timeout is what TestHostResponseTimeoutSeconds in this config tunes.

Why experimental / draft

With xUnit.v3 3.2.2, a specific batch can still deterministically deadlock the test host in MTP server mode (the auto-generated entry point blocks sync-over-async on its run task — captured stack: Monitor.Wait ← TaskAwaiter.GetResult() ← XunitAutoGeneratedEntryPoint.Main). The CTS timeout+retry converts that from an infinite hang into a bounded outcome, but the deadlocking batch can still surface as a spurious failure. Fully green MTP-mode CTS is therefore gated on an upstream xUnit.v3 fix. Until then, VSTest mode remains the CI path and this config is opt-in only (not wired into any pipeline).

Testing

Validated end-to-end with the fixed CTS driver against real StringTools.UnitTests MTP tests: the driver now always terminates and writes a baseline (previously: infinite hang). The config-driven timeout was confirmed to be honored from the JSON file.

jankratochvilcz and others added 2 commits July 14, 2026 15:47
Adds scripts/cts/cts.config.mtp.json so CTS can drive this repo's tests in their
native Microsoft.Testing.Platform (xUnit.v3) form, driving the regular
*.UnitTests DLLs directly instead of the *.VSTest wrappers. It sets
RunConfiguration.TestHostResponseTimeoutSeconds to tune the CTS per-batch
wedged-host timeout that the CTS driver-resilience fix adds.

This is opt-in and not wired into CI: with xUnit.v3 3.2.2 a specific batch can
still deterministically deadlock the test host in MTP server mode, which the
CTS timeout+retry bounds but does not fully cure. VSTest mode remains the CI
path and is left untouched (cts.config.json, *.ps1, azure-pipelines/cts-*.yml).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The CTS-side timeout changed from a fixed per-batch cap to an opt-in,
inactivity-based window (reset on every host update). Update the MTP-mode
README so cts.config.mtp.json's TestHostResponseTimeoutSeconds=120 is described
as an inactivity window rather than a total-batch cap, and note the CTS default
is 0 (disabled) so this config is what opts in.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: a41f0f3c-f165-414e-a8c5-efb8deecd9c8
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.

1 participant