Skip to content

Commit 417930b

Browse files
author
Tarek Mahmoud Sayed
committed
Fix conformance test false failures on Windows due to libuv cleanup crash
The Node.js conformance runner can crash during cleanup on Windows with a libuv assertion (UV_HANDLE_CLOSING) that produces a non-zero exit code even when all conformance checks passed. This change adds a fallback that parses the 'Test Results:' summary in stdout to determine success when the process exit code is non-zero. Also updates package-lock.json with latest dependency versions.
1 parent 9705707 commit 417930b

2 files changed

Lines changed: 51 additions & 19 deletions

File tree

package-lock.json

Lines changed: 17 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/ModelContextProtocol.AspNetCore.Tests/ServerConformanceTests.cs

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Diagnostics;
22
using System.Text;
3+
using System.Text.RegularExpressions;
34
using ModelContextProtocol.Tests.Utils;
45

56
namespace ModelContextProtocol.ConformanceTests;
@@ -207,10 +208,40 @@ public async Task RunConformanceTest_HttpCustomHeaderServerValidation()
207208
process.OutputDataReceived -= outputHandler;
208209
process.ErrorDataReceived -= errorHandler;
209210

211+
var stdoutText = outputBuilder.ToString();
212+
var stderrText = errorBuilder.ToString();
213+
214+
// The Node.js conformance runner can crash during cleanup on Windows with a libuv
215+
// assertion ("!(handle->flags & UV_HANDLE_CLOSING)") that produces a non-zero exit
216+
// code even though every conformance check passed. When that happens, fall back to
217+
// parsing the "Test Results:" summary in stdout to decide success.
218+
bool success = process.ExitCode == 0 || ConformanceOutputIndicatesSuccess(stdoutText);
219+
210220
return (
211-
Success: process.ExitCode == 0,
212-
Output: outputBuilder.ToString(),
213-
Error: errorBuilder.ToString()
221+
Success: success,
222+
Output: stdoutText,
223+
Error: stderrText
214224
);
215225
}
226+
227+
/// <summary>
228+
/// Parses the conformance runner output for a "Test Results:" line such as
229+
/// "Passed: 3/3, 0 failed, 0 warnings" and returns true when all checks passed
230+
/// and none failed.
231+
/// </summary>
232+
private static bool ConformanceOutputIndicatesSuccess(string output)
233+
{
234+
// Match lines like "Passed: 3/3, 0 failed, 0 warnings"
235+
var match = Regex.Match(output, @"Passed:\s*(\d+)/(\d+),\s*(\d+)\s*failed");
236+
if (!match.Success)
237+
{
238+
return false;
239+
}
240+
241+
int passed = int.Parse(match.Groups[1].Value);
242+
int total = int.Parse(match.Groups[2].Value);
243+
int failed = int.Parse(match.Groups[3].Value);
244+
245+
return passed == total && failed == 0 && total > 0;
246+
}
216247
}

0 commit comments

Comments
 (0)