Skip to content

Commit dd4bcd6

Browse files
Tweak stdio test
1 parent 7505d2a commit dd4bcd6

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

ModelContextProtocol.slnx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
<File Path="global.json" />
5757
<File Path="LICENSE" />
5858
<File Path="logo.png" />
59+
<File Path="Makefile" />
5960
<File Path="nuget.config" />
6061
<File Path="README.MD" />
6162
</Folder>

tests/ModelContextProtocol.Tests/Transport/StdioClientTransportTests.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,11 @@ public async Task CreateAsync_ValidProcessInvalidServer_Throws()
1616
string id = Guid.NewGuid().ToString("N");
1717

1818
StdioClientTransport transport = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ?
19-
new(new() { Command = "cmd", Arguments = ["/c", id] }, LoggerFactory) :
20-
new(new() { Command = "ls", Arguments = [id] }, LoggerFactory);
19+
new(new() { Command = "cmd", Arguments = ["/c", $"timeout /t 2 /nobreak >nul & echo {id} >&2 & exit /b 1"] }, LoggerFactory) :
20+
new(new() { Command = "sh", Arguments = ["-c", $"sleep 2s; echo {id} >&2; exit 1"] }, LoggerFactory);
2121

2222
IOException e = await Assert.ThrowsAsync<IOException>(() => McpClient.CreateAsync(transport, loggerFactory: LoggerFactory, cancellationToken: TestContext.Current.CancellationToken));
23-
if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
24-
{
25-
Assert.Contains(id, e.ToString());
26-
}
23+
Assert.Contains(id, e.ToString());
2724
}
2825

2926
[Fact(Skip = "Platform not supported by this test.", SkipUnless = nameof(IsStdErrCallbackSupported))]
@@ -44,8 +41,8 @@ public async Task CreateAsync_ValidProcessInvalidServer_StdErrCallbackInvoked()
4441
};
4542

4643
StdioClientTransport transport = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ?
47-
new(new() { Command = "cmd", Arguments = ["/c", id], StandardErrorLines = stdErrCallback }, LoggerFactory) :
48-
new(new() { Command = "ls", Arguments = [id], StandardErrorLines = stdErrCallback }, LoggerFactory);
44+
new(new() { Command = "cmd", Arguments = ["/c", $"timeout /t 2 /nobreak >nul & echo {id} >&2 & exit /b 1"], StandardErrorLines = stdErrCallback }, LoggerFactory) :
45+
new(new() { Command = "sh", Arguments = ["-c", $"sleep 2s; echo {id} >&2; exit 1"], StandardErrorLines = stdErrCallback }, LoggerFactory);
4946

5047
await Assert.ThrowsAsync<IOException>(() => McpClient.CreateAsync(transport, loggerFactory: LoggerFactory, cancellationToken: TestContext.Current.CancellationToken));
5148

0 commit comments

Comments
 (0)