jw-python/test/unit/python/jw/util/load_yaml/Makefile
Jan Lindemann d7454341e8
load_yaml: Implement jw.link expansion
Implement link expansion in _expand_links() to resolve jw.link markers
in YAML documents after the include/merge phase.  Two link forms are
supported:

- Inplace links  jw.link: "path.to.target" replace the marker entirely
  with the resolved value at the target path.
- Named links   jw.link: "name|path.to.target" replace the marker with
  {name: resolved_value}, using the first path segment as the key.

Paths use dot-separated segments.  Relative paths start with ".."
(like Python imports): "." stays at the current level, ".." goes up
one level, "..." two, and so on.  A single pipe character in the link
value separates the link name from the target path for named links.

The implementation includes:

- _parse_link(): splits a link value into (is_named, name, path)
- _resolve_path(): resolves an absolute or relative path to a value
- _expand_links_recursive(): walks the structure, expands links,
  detects cycles via a resolving set, and memoises via a resolved dict.

Cyclic links and missing targets both raise ValueError/KeyError.
jw.link markers with sibling keys are left unexpanded.

Add 86 unit tests covering the entire load_yaml module:

- Basic YAML loading, optional loading, root type checking
- Include directive (single, multiple, deep merge, circular detect)
- Inplace links, named links, relative paths (up, descend, same level)
- Transitive links, cycle detection, missing targets
- Regression tests, combined include+links, edge cases, type preservation

Signed-off-by: Jan Lindemann <jan@janware.com>
2026-08-12 23:10:12 +00:00

4 lines
93 B
Makefile

TOPDIR = ../../../../../..
include $(TOPDIR)/make/proj.mk
include $(JWBDIR)/make/py-test.mk