Skip to content

Commit a4aef0f

Browse files
Ahmed Mustafaclaude
andcommitted
fix(tests): Fix test process hanging by removing background tasks
Root cause: Fire-and-forget Task.Run in ResourceManager.MaxConcurrency setter was preventing test process from exiting. Changes: 1. Removed Task.Run + Task.Delay pattern in ResourceManager - Dispose old semaphore immediately instead of after delay - Operations holding semaphore will complete normally 2. Added xunit.runner.json to disable parallel test execution - Prevents resource contention in CI environments - maxParallelThreads: 1 for deterministic execution Expected: Tests complete in ~2 seconds instead of timing out 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 863ba9a commit a4aef0f

4 files changed

Lines changed: 18 additions & 7 deletions

File tree

.claude/settings.local.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
"Bash(gh:*)",
1414
"Bash(git push:*)",
1515
"Bash(find:*)",
16-
"Bash(timeout 10 dotnet test:*)"
16+
"Bash(timeout 10 dotnet test:*)",
17+
"WebFetch(domain:github.com)",
18+
"Bash(timeout 120 dotnet test:*)"
1719
]
1820
}
1921
}

src/DotNetDevMCP.Orchestration/ResourceManager.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,9 @@ public int MaxConcurrency
4848
_semaphore = new SemaphoreSlim(value, value);
4949
_maxConcurrency = value;
5050

51-
// Dispose old semaphore after a delay to allow current operations to complete
52-
Task.Run(async () =>
53-
{
54-
await Task.Delay(1000);
55-
oldSemaphore.Dispose();
56-
});
51+
// Dispose old semaphore immediately - operations already holding the semaphore
52+
// will complete normally, and new operations will use the new semaphore
53+
oldSemaphore.Dispose();
5754
}
5855
}
5956
}

tests/DotNetDevMCP.Core.Tests/DotNetDevMCP.Core.Tests.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
<Using Include="Xunit" />
2020
</ItemGroup>
2121

22+
<ItemGroup>
23+
<Content Include="xunit.runner.json">
24+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
25+
</Content>
26+
</ItemGroup>
27+
2228
<ItemGroup>
2329
<ProjectReference Include="..\..\src\DotNetDevMCP.Orchestration\DotNetDevMCP.Orchestration.csproj" />
2430
</ItemGroup>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
3+
"parallelizeAssembly": false,
4+
"parallelizeTestCollections": false,
5+
"maxParallelThreads": 1
6+
}

0 commit comments

Comments
 (0)