Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

test(ci): make the Windows path guard fixture polyglot so CI indexes Go end to end

Ilya Brykaua874b6bc95f3
diff --git a/tests/windows/test_non_ascii_path.py b/tests/windows/test_non_ascii_path.py
index 686ff9842..bd7de22a4 100644
--- a/tests/windows/test_non_ascii_path.py
+++ b/tests/windows/test_non_ascii_path.py
@@ -2,8 +2,8 @@
Guards the fix for issue #636 / #357 (landed on main via #700) at the product
surface (real codebase-memory-mcp process, real SQLite DB, real stdio). Two
-byte-identical TypeScript fixtures are indexed: one under an ASCII parent path,
-one under a non-ASCII parent path. The invariant under test:
+byte-identical polyglot fixtures (TypeScript + Go, #1959) are indexed: one under
+an ASCII parent path, one under a non-ASCII parent path. The invariant under test:
A byte-identical fixture must produce equivalent graph counts regardless of
whether its absolute path contains non-ASCII characters.
@@ -54,6 +54,81 @@ MAIN_TS = (
"run();\n"
)
+# Dummy Go package covering the shapes the Go/cgo extraction work (#1932
+# family) showed were previously invisible to CI: struct fields and a method,
+# a build-tag twin pair sharing one function name, a cgo file (C preamble,
+# `C.` call, `//export` directive), and a channel producer/consumer pair
+# (#1959). Go qualified names embed the containing directory, so these also
+# put non-ASCII repo paths through the Go pipeline passes.
+GO_MOD = "module example.com/fixture\n\ngo 1.22\n"
+
+GO_STORE = """package gopkg
+
+type Store struct {
+ Total int
+ Name string
+}
+
+func (s *Store) Push(x int) {
+ s.Total = s.Total + x
+}
+
+func NewStore(name string) *Store {
+ return &Store{Name: name}
+}
+"""
+
+GO_FLUSH_LINUX = """//go:build linux
+
+package gopkg
+
+func FlushDisk() int { return 1 }
+"""
+
+GO_FLUSH_WINDOWS = """//go:build windows
+
+package gopkg
+
+func FlushDisk() int { return 2 }
+"""
+
+GO_BRIDGE = """package gopkg
+
+/*
+#include <stdio.h>
+static void announce(void) { puts("hi"); }
+*/
+import "C"
+
+//export FixtureReady
+func FixtureReady() int { return 3 }
+
+func Announce() {
+ C.announce()
+}
+"""
+
+GO_EVENTS = """package gopkg
+
+func Produce(events chan string) {
+ events <- "tick"
+}
+
+func Drain(events chan string) string {
+ v := <-events
+ return v
+}
+"""
+
+GO_FILES = (
+ ("go.mod", GO_MOD),
+ ("gopkg/store.go", GO_STORE),
+ ("gopkg/flush_linux.go", GO_FLUSH_LINUX),
+ ("gopkg/flush_windows.go", GO_FLUSH_WINDOWS),
+ ("gopkg/bridge.go", GO_BRIDGE),
+ ("gopkg/events.go", GO_EVENTS),
+)
+
# Distinct non-ASCII scripts — each must behave like the ASCII baseline.
NON_ASCII_SEGMENTS = {
"latin1_accents": "café_repo",
@@ -244,6 +319,11 @@ def make_fixture(root):
for name, text in (("math.ts", MATH_TS), ("main.ts", MAIN_TS)):
with open(os.path.join(src, name), "wb") as f:
f.write(text.encode("utf-8")) # exact bytes, identical across copies
+ for rel, text in GO_FILES:
+ path = os.path.join(root, rel.replace("/", os.sep))
+ os.makedirs(os.path.dirname(path) or root, exist_ok=True)
+ with open(path, "wb") as f:
+ f.write(text.encode("utf-8"))
def no_project_error(index_txt, repo, cache):
@@ -323,6 +403,25 @@ def index_and_count(binary, repo, cache):
except Exception:
pass
out["definition_nodes"] = defs
+ # Go-file definitions separately: the Go passes derive qualified names
+ # from the containing directory, so they meet non-ASCII paths on a
+ # different route than the TS passes; a Go-specific count catches a
+ # regression that total counts could mask (#1959).
+ go_defs = 0
+ for label in ("Function", "Method"):
+ q = ("MATCH (n:%s) WHERE n.file_path CONTAINS '.go' "
+ "RETURN count(n)" % label)
+ r = s.call_tool("query_graph",
+ {"query": q, "project": name, "format": "json"},
+ timeout=60)
+ t, _ = s.tool_text(r)
+ try:
+ rows = json.loads(t).get("rows") or []
+ if rows and rows[0]:
+ go_defs += int(rows[0][0])
+ except Exception:
+ pass
+ out["go_definition_nodes"] = go_defs
return out
@@ -363,11 +462,16 @@ def main():
if base.get("error") or not base.get("nodes"):
print("SETUP FAIL: ASCII baseline did not index: %r" % base)
return 2
- print("baseline (ASCII): nodes=%s edges=%s definitions=%s" %
- (base["nodes"], base["edges"], base["definition_nodes"]))
+ print("baseline (ASCII): nodes=%s edges=%s definitions=%s go=%s" %
+ (base["nodes"], base["edges"], base["definition_nodes"],
+ base["go_definition_nodes"]))
if base["definition_nodes"] < 1:
print("SETUP FAIL: ASCII baseline produced no definitions: %r" % base)
return 2
+ if base["go_definition_nodes"] < 1:
+ print("SETUP FAIL: ASCII baseline extracted no Go definitions: %r"
+ % base)
+ return 2
for key, seg in NON_ASCII_SEGMENTS.items():
repo = os.path.join(work, seg)
@@ -376,13 +480,15 @@ def main():
ok = (not got.get("error")
and got.get("nodes") == base["nodes"]
and got.get("edges") == base["edges"]
- and got.get("definition_nodes") == base["definition_nodes"])
+ and got.get("definition_nodes") == base["definition_nodes"]
+ and got.get("go_definition_nodes") == base["go_definition_nodes"])
status = "PASS" if ok else "FAIL"
- print("[%s] non-ascii/%-14s nodes=%s edges=%s definitions=%s "
- "(baseline %s/%s/%s) name=%r" %
+ print("[%s] non-ascii/%-14s nodes=%s edges=%s definitions=%s go=%s "
+ "(baseline %s/%s/%s/%s) name=%r" %
(status, key, got.get("nodes"), got.get("edges"),
- got.get("definition_nodes"), base["nodes"], base["edges"],
- base["definition_nodes"], got.get("name")))
+ got.get("definition_nodes"), got.get("go_definition_nodes"),
+ base["nodes"], base["edges"], base["definition_nodes"],
+ base["go_definition_nodes"], got.get("name")))
if not ok:
# The counts alone cannot explain a venue-specific failure;
# surface the captured error verbatim so CI logs carry the
@@ -400,7 +506,9 @@ def main():
if (not retry.get("error")
and retry.get("nodes") == base["nodes"]
and retry.get("edges") == base["edges"]
- and retry.get("definition_nodes") == base["definition_nodes"]):
+ and retry.get("definition_nodes") == base["definition_nodes"]
+ and retry.get("go_definition_nodes")
+ == base["go_definition_nodes"]):
print(" %s retry matched baseline -- order-dependent, "
"not path-dependent" % key)
else: