summaryrefslogtreecommitdiff
path: root/internal/lsp/handlers_end_to_end_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-16 04:33:36 +0200
committerPaul Buetow <paul@buetow.org>2026-03-16 04:33:36 +0200
commit95b0a9962861b2aef4a3e9538dd38608aca4bcfc (patch)
tree534a8c0f2bff31e612a9b12ff4d911bbead61c0c /internal/lsp/handlers_end_to_end_test.go
parentf55a1e88ea5948582d0e5a33efea0c5d806e1f4b (diff)
Document lock ordering, fix test data races, correct stateMu guard
- Add doc comments clarifying Server.mu and completionState.stateMu are independent (no ordering constraint). - Fix test using wrong lock (s.mu instead of stateMu) for lastLLMCall. - Replace time.Sleep polling in 7 tests with s.inflight.Wait() to eliminate data races under -race. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/lsp/handlers_end_to_end_test.go')
-rw-r--r--internal/lsp/handlers_end_to_end_test.go7
1 files changed, 2 insertions, 5 deletions
diff --git a/internal/lsp/handlers_end_to_end_test.go b/internal/lsp/handlers_end_to_end_test.go
index 4528c1d..15b38df 100644
--- a/internal/lsp/handlers_end_to_end_test.go
+++ b/internal/lsp/handlers_end_to_end_test.go
@@ -8,7 +8,6 @@ import (
"log"
"strings"
"testing"
- "time"
tut "codeberg.org/snonux/hexai/internal/testutil"
)
@@ -229,10 +228,8 @@ func TestDetectAndHandleChat_InsertsReply(t *testing.T) {
s.setDocument(uri, "What time?>\n\n")
out.Reset()
s.detectAndHandleChat(uri)
- // Allow async goroutine to write the request
- for i := 0; i < 100 && out.Len() == 0; i++ {
- time.Sleep(10 * time.Millisecond)
- }
+ // Wait for the background chat goroutine to finish writing.
+ s.inflight.Wait()
if out.Len() == 0 {
t.Fatalf("no output written by detectAndHandleChat")
}