bots-garden/mini-mepublic Fork
⑂ 213c720
Commits
⬇ Clone ▾
git clone https://git.rickub.com/bots-garden/mini-me.git
git clone ssh://git@rickub.com/bots-garden/mini-me.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Download ZIP

📦 Mini Me

k33g committed 2026-10-16T09:29:30+02:00 Browse files
213c720 parent: 5d7d40f
modified internal/lsp/lsp_test.go +22 -0
@@ -111,6 +111,27 @@ func (f *fakeServer) awaitDoc(t *testing.T, u uri.URI, version int32) string {
111111 }
112112 }
113113
114+// awaitPublication waits until the client has received the server's first
115+// publication for path.
116+//
117+// The fake publishes on didOpen from a goroutine, so the publication for a
118+// file opened by an earlier call can still be in flight when the next call
119+// starts. A Diagnostics call that reads its "before" counter in that window
120+// sees the late publication as fresh and drops the "(as last published)"
121+// label — correct behaviour, but not the case the test means to check. It
122+// failed that way on a GitHub runner (2026-10-16).
123+func awaitPublication(t *testing.T, c *Client, path string) {
124+ t.Helper()
125+ s, err := c.serverFor(context.Background(), path)
126+ if err != nil {
127+ t.Fatal(err)
128+ }
129+ fresh, err := s.waitPublication(context.Background(), uri.File(mustAbs(path)), 0, 2*time.Second)
130+ if err != nil || !fresh {
131+ t.Fatalf("no publication received for %s: %v", path, err)
132+ }
133+}
134+
114135 func (f *fakeServer) Definition(_ context.Context, p *protocol.DefinitionParams) (protocol.DefinitionResult, error) {
115136 return protocol.LocationSlice{{URI: p.TextDocument.URI, Range: span(2, 5, 2, 10)}}, nil
116137 }
@@ -205,6 +226,7 @@ func TestOperationsOverAFakeServer(t *testing.T) {
205226 }
206227 // main.go was opened by the calls above and has not changed since: no
207228 // new publication comes, the last one is reported as such.
229+ awaitPublication(t, c, "main.go")
208230 got, err = c.Diagnostics(ctx, "main.go")
209231 if err != nil || got != "1 diagnostic(s) in main.go (as last published):\nwarning main.go:3:6 unused function [fake]" {
210232 t.Errorf("diagnostics on an open file: %q, %v", got, err)
@@ -111,6 +111,27 @@ func (f *fakeServer) awaitDoc(t *testing.T, u uri.URI, version int32) string {
111 }111 }
112 }112 }
113 113
114+// awaitPublication waits until the client has received the server's first
115+// publication for path.
116+//
117+// The fake publishes on didOpen from a goroutine, so the publication for a
118+// file opened by an earlier call can still be in flight when the next call
119+// starts. A Diagnostics call that reads its "before" counter in that window
120+// sees the late publication as fresh and drops the "(as last published)"
121+// label — correct behaviour, but not the case the test means to check. It
122+// failed that way on a GitHub runner (2026-10-16).
123+func awaitPublication(t *testing.T, c *Client, path string) {
124+ t.Helper()
125+ s, err := c.serverFor(context.Background(), path)
126+ if err != nil {
127+ t.Fatal(err)
128+ }
129+ fresh, err := s.waitPublication(context.Background(), uri.File(mustAbs(path)), 0, 2*time.Second)
130+ if err != nil || !fresh {
131+ t.Fatalf("no publication received for %s: %v", path, err)
132+ }
133+}
134+
114 func (f *fakeServer) Definition(_ context.Context, p *protocol.DefinitionParams) (protocol.DefinitionResult, error) {135 func (f *fakeServer) Definition(_ context.Context, p *protocol.DefinitionParams) (protocol.DefinitionResult, error) {
115 return protocol.LocationSlice{{URI: p.TextDocument.URI, Range: span(2, 5, 2, 10)}}, nil136 return protocol.LocationSlice{{URI: p.TextDocument.URI, Range: span(2, 5, 2, 10)}}, nil
116 }137 }
@@ -205,6 +226,7 @@ func TestOperationsOverAFakeServer(t *testing.T) {
205 }226 }
206 // main.go was opened by the calls above and has not changed since: no227 // main.go was opened by the calls above and has not changed since: no
207 // new publication comes, the last one is reported as such.228 // new publication comes, the last one is reported as such.
229+ awaitPublication(t, c, "main.go")
208 got, err = c.Diagnostics(ctx, "main.go")230 got, err = c.Diagnostics(ctx, "main.go")
209 if err != nil || got != "1 diagnostic(s) in main.go (as last published):\nwarning main.go:3:6 unused function [fake]" {231 if err != nil || got != "1 diagnostic(s) in main.go (as last published):\nwarning main.go:3:6 unused function [fake]" {
210 t.Errorf("diagnostics on an open file: %q, %v", got, err)232 t.Errorf("diagnostics on an open file: %q, %v", got, err)