Skip to content

Commit 94a2dff

Browse files
halter73Copilot
andcommitted
Make InheritEnvironmentVariables_DefaultTrue test use same var as False test
Both DefaultTrue and False tests now check HOME (Unix) / USERNAME (Windows) so they form a symmetric pair asserting opposite outcomes on the same signal. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 9ce7245 commit 94a2dff

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

tests/ModelContextProtocol.Tests/Transport/StdioClientTransportTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,19 +153,19 @@ public async Task EscapesCliArgumentsCorrectly(string? cliArgumentValue)
153153
[Fact(Skip = "Platform not supported by this test.", SkipUnless = nameof(IsStdErrCallbackSupported))]
154154
public async Task InheritEnvironmentVariables_DefaultTrue_ChildSeesParentEnvVars()
155155
{
156-
// PATH is always set in a real process environment. Verify the child sees it
157-
// under the default (inherit) behavior without mutating the parent process.
156+
// Check the same variable the False test checks for absence (HOME on Unix, USERNAME on Windows)
157+
// so the two tests form a direct symmetric pair: one asserts it IS set, the other asserts it is NOT.
158158
var tcs = new TaskCompletionSource<string>();
159159
StdioClientTransport transport = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ?
160-
new(new() { Command = "cmd", Arguments = ["/c", "if defined PATH (echo PATH_IS_SET >&2) else (echo PATH_NOT_SET >&2) & exit /b 1"], StandardErrorLines = line => tcs.TrySetResult(line) }, LoggerFactory) :
161-
new(new() { Command = "sh", Arguments = ["-c", "if [ -n \"$PATH\" ]; then echo PATH_IS_SET >&2; else echo PATH_NOT_SET >&2; fi; exit 1"], StandardErrorLines = line => tcs.TrySetResult(line) }, LoggerFactory);
160+
new(new() { Command = "cmd", Arguments = ["/c", "if defined USERNAME (echo USERNAME_IS_SET >&2) else (echo USERNAME_NOT_SET >&2) & exit /b 1"], StandardErrorLines = line => tcs.TrySetResult(line) }, LoggerFactory) :
161+
new(new() { Command = "sh", Arguments = ["-c", "if [ -n \"$HOME\" ]; then echo HOME_IS_SET >&2; else echo HOME_NOT_SET >&2; fi; exit 1"], StandardErrorLines = line => tcs.TrySetResult(line) }, LoggerFactory);
162162

163163
await Assert.ThrowsAnyAsync<IOException>(() => McpClient.CreateAsync(transport, loggerFactory: LoggerFactory, cancellationToken: TestContext.Current.CancellationToken));
164164

165165
using var cts = new CancellationTokenSource(TestConstants.DefaultTimeout);
166166
string capturedLine = await tcs.Task.WaitAsync(cts.Token);
167167

168-
Assert.Equal("PATH_IS_SET", capturedLine.Trim());
168+
Assert.Equal(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "USERNAME_IS_SET" : "HOME_IS_SET", capturedLine.Trim());
169169
}
170170

171171
[Fact(Skip = "Platform not supported by this test.", SkipUnless = nameof(IsStdErrCallbackSupported))]

0 commit comments

Comments
 (0)