Skip to content

Commit e004537

Browse files
yotsudaclaude
andcommitted
Fix flaky macOS test: isolate agent ID to prevent parallel test class interference
WaitForCompletion_PreviouslyBusyPidDisappeared used shared "default" agent ID, which raced with PipeDiscoveryServiceTests calling ConsumeKnownBusyPids on the same singleton. Use AllocateSubAgentId() for test isolation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d257cf2 commit e004537

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Tests/Unit/Proxy/PowerShellToolsTests.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,9 +566,13 @@ public async Task WaitForCompletion_PreviouslyBusyPidDisappeared_ReturnsClosedMe
566566
var sessionManager = ConsoleSessionManager.Instance;
567567
const int testPid = 88802;
568568

569+
// Use a unique agent ID to avoid race with parallel test classes (e.g. PipeDiscoveryServiceTests)
570+
// that also call ConsumeKnownBusyPids on the singleton with "default" agent ID
571+
var isolatedAgentId = sessionManager.AllocateSubAgentId();
572+
569573
sessionManager.TryAssignNameToPid(testPid);
570574
var expectedDisplayName = sessionManager.GetConsoleDisplayName(testPid);
571-
sessionManager.MarkPipeBusy(TestAgentId, testPid);
575+
sessionManager.MarkPipeBusy(isolatedAgentId, testPid);
572576

573577
_mockPipeDiscoveryService
574578
.Setup(s => s.CollectAllCachedOutputsAsync(It.IsAny<string>(), It.IsAny<string?>(), It.IsAny<CancellationToken>()))
@@ -579,7 +583,7 @@ public async Task WaitForCompletion_PreviouslyBusyPidDisappeared_ReturnsClosedMe
579583
_mockPowerShellService.Object,
580584
_mockPipeDiscoveryService.Object,
581585
timeout_seconds: 1,
582-
agent_id: TestAgentId);
586+
agent_id: isolatedAgentId);
583587

584588
// Assert: console display name (not raw pipe name) in closed message
585589
Assert.Contains(expectedDisplayName, result);

0 commit comments

Comments
 (0)