Skip to content

Add file-level @var directive - #65

Merged
sleipi merged 10 commits into
mainfrom
feat/60-file-level-var-directive
Sep 17, 2026
Merged

sleipi merged 10 commits into
mainfrom
feat/60-file-level-var-directive

Conversation

@sleipi

@sleipi sleipi commented Sep 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds a new frontmatter directive @var KEY=VALUE that sets a file-scoped default for {{KEY}} template substitution, so sibling .clitest files that differ by one value (a scenario directory, a tool version) need change only one frontmatter line instead of repeating it on every line.
  • Precedence: --var (CLI) > [captures] > @var (file) — falls out naturally by seeding the per-run captures map with the file's @var values at creation (vars.SeedCaptures), rather than a merge at every substitution call site.
  • File-level only; duplicate key or malformed value (no =) rejected as a parse-time error.

Closes #60

Test plan

  • go test ./... — all unit packages pass
  • make e2e — 139/139 e2e tests pass (incl. new test/e2e/var/ + validation fixtures)
  • make examples — 35 pass, 1 pre-existing skip (incl. new examples/09_var.clitest)
  • SPEC.md updated (priority list, directives table, #### @var subsection with scope/precedence notes)

sleipi and others added 10 commits September 17, 2026 11:35
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Adds SeedCaptures function that returns a copy of fileVars for seeding
per-run captures map. Ensures returned map never aliases input map.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@var only expands {{KEY}} in an entry's command line, since it rides
the same runtime path as [captures] substitution (vars.SubstituteCaptures,
called only on entry.Command). It does not expand in expected body or
[asserts] values, unlike --var, which is a raw whole-file-text pass run
before parsing. Add a Scope bullet to SPEC.md's @var subsection stating
this explicitly, plus a Variable substitution bullet parallel to @env's,
noting that --var placeholders and $VAR/${VAR} env vars expand inside
@var values themselves.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…plemented SeedCaptures approach

The original correction (MergeCaptures -> SeedCaptures rewrite) was made
before this branch's worktree was created and never made it into the
cherry-picked commit — the worktree carried the stale MergeCaptures text
while the plan and actual implementation already used SeedCaptures.
@sleipi sleipi added the enhancement New feature or request label Sep 17, 2026
@sleipi
sleipi merged commit fc57db9 into main Sep 17, 2026
7 checks passed
@sleipi
sleipi deleted the feat/60-file-level-var-directive branch September 17, 2026 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: file-level @var NAME=VALUE feeding {{NAME}}, so sibling test files can differ by one line

1 participant