Skip to content

Make the trycmd snapshot tests real - #18

Merged
ndbroadbent merged 7 commits into
mainfrom
tools/trycmd
Dec 4, 2026
Merged

ndbroadbent merged 7 commits into
mainfrom
tools/trycmd

Conversation

@ndbroadbent

@ndbroadbent ndbroadbent commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Item 5 of the agent-tools work. Stacked on #17 (expand), whose stack goes #14, #13. The base is tools/expand.

Why they were ignored

trycmd only runs commands inside fenced code blocks (console or trycmd). The old .trycmd files had no fences, so every case was reported as ignored. Their expected output was also stale (cd isn't supported, and the messages were old).

What changed

  • tests/cmd/help.trycmd: full help for cigen and for validate, explain, expand, hash and generate.
  • tests/cmd/validate.trycmd with validate.in/, a split config with three mistakes:
    • validate as text and as JSON;
    • generate printing the same errors;
    • a missing --config.
  • tests/cmd/project.trycmd with project.in/, a small project: validate, explain as text and JSON, hash --job, an unknown job, and expand as YAML and JSON. It runs in a sandbox (project.out/ exists), so the cigen repo's git doesn't change what the patterns match.
  • tests/cli.rs sets CIGEN_PLUGIN_DIR and points GIT_DIR at a path that doesn't exist. Inside the pre-commit hook, the inherited GIT_DIR made hash list this repo's files; trycmd can't unset a variable. The comment says how to refresh: TRYCMD=overwrite cargo test --test cli -- cli_coverage.
  • cigen's version and the hash that depends on it are elided ([..]), so a version bump doesn't break the snapshots. tests/explain.rs already checks that explain's hash equals hash --job's.
  • cigen's tests input group gains tests/cmd/**, because the .in/ fixtures are inputs.

Tests

cargo test --test cli runs 17 cases and none are ignored. task ci and the pre-commit hook pass.


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

The .trycmd files had no fenced code blocks, so trycmd ignored every case,
and their expected output was years stale. They now cover every command's
help, validate on a broken config (text, JSON, and generate printing the
same errors), and validate, explain, hash --job and expand on a small
project. The project case runs in a sandbox (project.out/), and GIT_DIR
points nowhere, so neither the cigen repo nor a git hook's environment
changes what the patterns match. cigen's version and the hash it feeds
are elided, so a release doesn't break them.

Refresh with TRYCMD=overwrite cargo test --test cli -- cli_coverage.
@ndbroadbent
ndbroadbent changed the base branch from tools/expand to main December 4, 2026 04:22
@ndbroadbent
ndbroadbent merged commit 470cfcf into main Dec 4, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant