forgejo-mcp/test/race
Christoph 4d7d2cde3f test: add race condition reproducer for #76
Add test/race/ package with concurrent tool handler tests that exercise
the code paths reported in issue #76 (concurrent map writes).

Tests included:
- TestConcurrentToolCalls: hammers all tools from 20 goroutines
- TestConcurrentSameToolRepeated: per-tool concurrent stress test
- TestConcurrentListAndRegister: race between registration and listing
- TestInitFlagParseBug: documents cmd.init() flag.Parse() issue
- TestNilResponseDeref: documents nil resp.StatusCode bug found during investigation

Run with: go test -race -count=10 -timeout 120s ./test/race/

Note: The exact mapassign_fast64 crash from #76 could not be reproduced
with the current codebase under the race detector. The race may be
version-specific, transient, or triggered by specific timing in the
mcp-go stdio worker pool.

Additional findings:
1. cmd.init() calls flag.Parse() on global CommandLine, making
   'go test ./cmd/' impossible (flag conflict with test framework)
2. Tool handlers access resp.StatusCode before checking err != nil,
   causing nil pointer dereference when API calls fail

Refs: https://codeberg.org/goern/forgejo-mcp/issues/76
2026-02-19 06:41:27 +01:00
..
race_test.go test: add race condition reproducer for #76 2026-02-19 06:41:27 +01:00