Uh oh!
There was an error while loading. Please reload this page.
Add black-box baseline tests for dotnet-test pipe protocol (#51615 prep) - #9153
Conversation
…otnet/sdk#51615) This PR introduces a hand-rolled `FakeDotnetTestSdk` harness plus three baseline acceptance tests that pin today's wire-format behavior of `Microsoft.Testing.Platform` running under `--server dotnettestcli`. The harness is intentionally black-box: it uses only `System.IO.Pipes.NamedPipeServerStream` from the BCL and re-implements the dotnet-test wire format (`int32 size | int32 serializerId | body`, with leading `ushort fieldCount` in handshake/event bodies) directly. This was necessary because the production IPC types under `src/Platform/Microsoft.Testing.Platform/IPC/*` are decorated with `[Microsoft.CodeAnalysis.Embedded]` and so cannot be referenced across assembly boundaries even with `InternalsVisibleTo`. As a side benefit the harness now also acts as a contract test for the wire format. The three tests: 1. `DotnetTestPipe_TestAppAdvertisesAndNegotiatesProtocolV100_Today` pins protocol negotiation: the test app advertises `1.0.0`, and a fake SDK that advertises `1.0.0` negotiates `1.0.0`. 2. `DotnetTestPipe_EmitsTestSessionStartAndEnd` pins that a single no-op session produces exactly one `TestSessionEvent` with `SessionType=TestSessionStart` and one with `TestSessionEnd`. 3. `DotnetTestPipe_ChildEmitsNoStdoutOrStderrForPassingRun_Baseline` pins that today the test app emits nothing to stdout/stderr under pipe mode for a passing no-op run (banner is already silenced via the existing `_isServerMode` check in `TerminalOutputDevice`). These baselines lock down the current behavior so subsequent work on dotnet/sdk#51615 (live stdout/stderr forwarding, `IOutputDevice` routing through the pipe, protocol bump to 1.0.1) can be reviewed against an explicit before/after. No product code changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a black-box acceptance test harness and baseline tests that exercise the current --server dotnettestcli --dotnet-test-pipe wire protocol behavior of Microsoft.Testing.Platform when run under dotnet test, to enable clear before/after review for the upcoming dotnet/sdk#51615 behavior changes.
Changes:
- Introduces a minimal pipe protocol reader/writer (
DotnetTestPipeProtocol) implemented using only BCL types. - Adds a fake “dotnet test SDK” harness (
FakeDotnetTestSdk) that hosts the pipe server, performs handshake negotiation, and captures frames. - Adds three baseline acceptance tests that pin current protocol negotiation, session start/end events, and “no stdout/stderr” behavior under pipe mode.
Show a summary per file
| File | Description |
|---|---|
| test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/DotnetTestPipe/FakeDotnetTestSdkResult.cs | DTO capturing handshake/messages/process output observed during a pipe-mode run. |
| test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/DotnetTestPipe/FakeDotnetTestSdk.cs | Fake SDK pipe server harness + handshake/version negotiation logic. |
| test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/DotnetTestPipe/DotnetTestPipeProtocol.cs | Black-box framing + handshake and session-event decoding/encoding helpers. |
| test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/DotnetTestPipe/DotnetTestPipeBaselineTests.cs | Baseline acceptance tests + inline test asset used to drive pipe-mode behavior. |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 3
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Amaury Levé (Evangelink)
commented
Jun 15, 2026
🧪 Test quality grade — PR #91533 new integration tests graded across 1 file. All three earn A — clear Arrange/Act/Assert structure, multiple meaningful assertions with rich diagnostic failure messages, and no anti-patterns. The baseline-contract pattern (documenting current behavior so regressions are visible as intentional diffs) is a particularly valuable technique for protocol tests.
This advisory comment was generated automatically. Grades are heuristic and informational — they do not block merging. Re-run with
|
Uh oh!
There was an error while loading. Please reload this page.
Amaury Levé (Evangelink)
left a comment
There was a problem hiding this comment.
🤖 Automated content by GitHub Copilot. Posted via a maintainer's GitHub token, so it appears under their account — the account owner did not write or approve this content personally. Generated by the Expert Code Review (on PR ready) workflow. · 930.5 AIC · ⌖ 12.4 AIC · ◷
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Trim SDK supported-version tokens and project app versions via Select - Fix misleading CurrentUserOnly comment (harness targets $(NetCurrent)) - Advance stream past extra SessionType bytes to stay aligned - Remove unnecessary Task.Run wrapper around already-async ExecuteAsync - Make SelectHighestMutuallySupportedVersion private static - Add assertion message for SentHandshakeReply guard - Use Regex-typed DoesNotMatchRegex overload to keep Compiled flag Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
Prep PR for dotnet/sdk#51615 ("Improve stdout/stderr handling of MTP test apps under
dotnet test").This PR is intentionally product-code-free. It introduces a black-box
acceptance harness and three baseline tests that pin today's wire-format
behavior of
Microsoft.Testing.Platformrunning under--server dotnettestcli, so that the upcoming behavior changes (livestdout/stderr forwarding,
IOutputDevicerouting through the pipe,protocol bump to
1.0.1) can be reviewed against an explicit before/after.Why a black-box harness?
The production IPC types under
src/Platform/Microsoft.Testing.Platform/IPC/*(
NamedPipeServer,IRequest,IResponse,NamedPipeBase, all baseserializers) carry
[Microsoft.CodeAnalysis.Embedded], which means theyare emitted as private copies per assembly and cannot be referenced from
the acceptance test project even with
InternalsVisibleTo.Rather than copy-link ~30 files into the test project (and silently
diverge from product over time), the harness re-implements the wire
format on top of
System.IO.Pipes.NamedPipeServerStream. As a sidebenefit, it now also doubles as a contract test for the wire format.
What's in the PR
Baseline tests
DotnetTestPipe_TestAppAdvertisesAndNegotiatesProtocolV100_Todaypins that the test app advertises
1.0.0and that a fake SDKadvertising
1.0.0negotiates1.0.0.DotnetTestPipe_EmitsTestSessionStartAndEndpins that a singleno-op session produces exactly one
TestSessionEventwithSessionType=TestSessionStartand one withTestSessionEnd.DotnetTestPipe_ChildEmitsNoStdoutOrStderrForPassingRun_Baselinepins that today the test app emits nothing to stdout/stderr under
pipe mode for a passing no-op run (the banner is already silenced
via the existing
_isServerModecheck inTerminalOutputDevice).Test results
No product code changes. No public API changes.
Follow-ups (separate PRs)
under
--server dotnettestcliinstead of writing to localIConsole(closesConsider: Disable MTP's own TerminalTestReporter when running under server mode (pipe specifically maybe?) #7161 too). Adds new
LogMessagemessage.1.0.1(both sides advertise1.0.1;1.0.0) plus newStandardStreamChunkmessage for livestdout/stderr forwarding (opt-in via handshake flag).
surface (
--live-outputor equivalent).Once Phase 1 lands, these baseline tests will need to be adjusted to
match the new contracts; today they intentionally describe the current
behavior so the diff is reviewable.