From 6c29d988bd3e051e11286b7b2a5555d9d855e2f3 Mon Sep 17 00:00:00 2001 From: safishamsi Date: Fri, 14 Aug 2026 14:21:34 +0100 Subject: [PATCH] test(wiki): make the bracketed-label parity case non-vacuous (#2597) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The parity check keyed on the whole [display](target) pattern, so a link whose display text contains brackets (Array[T] Models) never matched and the bracket case asserted nothing. Key on the ](target) boundary instead — wiki targets contain no ) or whitespace — so bracketed labels are actually checked. Co-Authored-By: Claude Opus 4.8 (1M context) --- CHANGELOG.md | 1 + tests/test_wiki_link_filename_parity.py | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 800ed319..a7ed74fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Full release notes with details on each version: [GitHub Releases](https://githu ## 0.9.42 (unreleased) - Fix: a cross-file INFERRED `uses` edge now binds to the symbol whose body actually references the imported name (a module-level function is a valid source; a co-located class that never touches the import gets no edge), instead of fanning out from the import line to every class in the importing file (#2652, thanks @ousamabenyounes). A reference at module top level, with no enclosing symbol, emits no edge. +- Fix: a wiki article link now targets the article's filename verbatim instead of a percent-encoded twin, so a label with `( ) & #` or non-ASCII characters no longer produces a link that names no file on disk; the link and the on-disk filename share one canonicalization (#2597, thanks @abhay-codes07). - Feature: OCaml `.ml`/`.mli` extraction via tree-sitter-ocaml (optional `[ocaml]` extra). Extracts modules, top-level and module-level values/functions, types and their variant constructors, `open` imports, and function calls; qualified calls (`Geo.area`) resolve to the value, and cross-file `open`/call targets collapse onto the unique real definition via the corpus stub rewire. - Fix: a JS/TS `for...of` / `for...in` loop binding is now shadowed, so passing it as a call argument no longer fabricates an `indirect_call` edge to an unrelated same-named callable (#2685, thanks @ousamabenyounes); completes the loop/closure/catch shadow family (#2568/#2569/#2517). - Fix: graph provenance (`built_at_commit`) is stamped from the analysed repository rather than the shell's working directory, so `graphify extract` run from elsewhere records the target's commit, not the caller's (#2534 family; #2699, thanks @C0KERNEL). diff --git a/tests/test_wiki_link_filename_parity.py b/tests/test_wiki_link_filename_parity.py index 69a9a224..11ed2ed5 100644 --- a/tests/test_wiki_link_filename_parity.py +++ b/tests/test_wiki_link_filename_parity.py @@ -20,11 +20,16 @@ import pytest from graphify.wiki import _safe_filename, to_wiki # Deliberately does not decode: the target is compared exactly as written. -_MD_LINK = re.compile(r"\[([^\]]+)\]\(([^)]+)\)") +# Key on the `](target)` boundary rather than the whole `[display](target)` so a +# display text that itself contains brackets (e.g. `Array[T] Models`) is still +# captured — a display-anchored regex silently skips those links, making the +# bracket case a vacuous pass. Wiki targets never contain `)` (parens are dropped +# from the slug) or whitespace (spaces become `_`), so `[^)\s]+` is exact. +_MD_TARGET = re.compile(r"\]\(([^)\s]+)\)") def _targets(text: str) -> list[str]: - return [t for _d, t in _MD_LINK.findall(text) if "://" not in t] + return [t for t in _MD_TARGET.findall(text) if "://" not in t] def _wiki(tmp_path, labels: dict[int, str], god: list[dict] | None = None):