Files
graphify/tests/test_pr10_watch_overrides.py
9c66fd30dc feat(config): declare languages for ambiguous extensions via .graphifyrc (#2961)
An ambiguous extension (`.inc`, `.h`, TS-family, ...) is hard-mapped to one
global default; when that is wrong the file does not error — it parses as the
wrong language and yields a few incidental nodes, so the graph looks populated
while the real symbols are missing. A project can now declare what an extension
means via `language.<ext>=<language|.ext>` lines in `.graphifyrc` (which already
holds `viz_node_limit`). The declaration flows through file classification,
extractor selection, grammar/resolution, imports, watch, and the AST cache
(salt + manifest language field + incremental invalidation), is thread-local
per scan root, and is forwarded to the worker pool. Default detection is
byte-for-byte unchanged when no declaration is present.

Landed from PR #3789 (squashed), which carried @abhay-codes07's original #3075
forward with reviewed follow-ups. Authorship credited to both contributors.

Co-Authored-By: Andre Brait <andrebrait@gmail.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-12 12:16:17 +01:00

26 lines
1.1 KiB
Python

"""Root configuration controls extraction even when excluded from the corpus."""
import pytest
from tests.test_language_override_lifecycle import drive_watch, graph_labels
@pytest.mark.parametrize("replacement", [False, True])
def test_ignored_root_configuration_still_rebuilds_the_graph(tmp_path, monkeypatch, replacement):
events = pytest.importorskip("watchdog.events")
(tmp_path / ".graphifyignore").write_text(".*\n" if replacement else ".graphifyrc\n")
(tmp_path / "page.tpl").write_text("<?php function configured() {}\n")
config = tmp_path / ".graphifyrc"
def change():
if replacement:
staged = tmp_path / ".replacement"
staged.write_text("language.tpl=php\n")
staged.replace(config)
return events.FileMovedEvent(str(staged), str(config))
config.write_text("language.tpl=php\n")
return events.FileModifiedEvent(str(config))
drive_watch(tmp_path, monkeypatch, [change])
assert "configured()" in graph_labels(tmp_path)
assert (tmp_path / "graphify-out" / "needs_update").read_text() == "1"