* Plan: flesh out PR7 (MCP server + Agent Skill) design stdio transport (no HTTP port), mlr mcp terminal in the main binary, SDK-vs-handroll decision, tool list, in-process vs subprocess split, run-tool safety (--no-shell prerequisite), single-sourced skill, tests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Add mlr mcp: MCP server + agent playbook; --no-shell gate (#2098 PR7) New terminal `mlr mcp` runs a Model Context Protocol server over stdio (spawned by MCP clients; no network port), exposing five tools -- list_capabilities, which, validate_dsl, describe_data, run -- plus an agent playbook as MCP prompt/resource. Catalog tools are served in-process from the help registries; the rest subprocess this same binary with MLR_ERRORS_JSON=1, a timeout, and an output cap. Prerequisite: a new --no-shell flag / MLR_NO_SHELL env var (one-way gate) disables the DSL system/exec functions, piped redirects, and --prepipe/--prepipex; the MCP server sets it on the commands it runs unless started with --allow-shell. Adds the github.com/modelcontextprotocol/go-sdk dependency. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Force LF checkout for the embedded SKILL.md (Windows CI fix) go:embed embeds checkout bytes, so a CRLF checkout on Windows made the embedded playbook differ per platform and failed TestPlaybookHasFrontmatter. Pin the file to eol=lf in .gitattributes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Move no-shell test DSL into per-case mlr files (Windows CI fix) Inline single-quoted DSL in cmd files is mangled by the Windows shell (single quotes are not quote characters there); the harness's put -f ${CASEDIR}/mlr pattern avoids shell quoting entirely. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| cases | ||
| cases-not-suitable-for-ci | ||
| expected | ||
| input | ||
| stdlib | ||
| README.md | ||
Miller regression tests
There are a few files unit-tested with Go's testing package -- a few dozen cases total.
The vast majority of Miller tests, though -- thousands of cases -- are tested by running scripted invocations of mlr with various flags and inputs, comparing against expected output, and checking the exit code back to the shell.
How to run the regression tests, in brief
Note: while this README.md file is within the test/ subdirectory, all paths in this file are written from the perspective of the user being cd'ed into the repository base directory, i.e. this directory's parent directory.
-
mlr regtest --help -
go test github.com/johnkerl/miller/v6/pkg/...— runs the Go unit tests (a few dozen cases).
Items for the duration of the Go port
mlr regtest -c ...runs the C version of Miller from the local checkout
More details
You can alias mr='mlr regtest' for convenience. With no arguments, mr runs all cases under test/cases/. Pass one or more paths to run only those directories or specific .cmd files.
mr— run all regression cases (default path istest/cases/).mr test/cases/foo— run only cases under that directory.mr -v test/cases/foo— same, plus per-command pass/fail; use-vvor-vvvfor more detail.mr -j test/cases/foo/0003— show the Miller command, any script, and actual output for that case (handy for debugging).mr -p test/cases/foo/0003— populate: write or overwriteexpoutandexperrfrom the current run (use when adding or updating expected output).mr -c ...— use the C build of Miller (e.g.-c→../c/mlr) instead of the current executable.
To review populated files before committing, run mr -p on the desired path, then git diff to inspect changes and git reset --hard to discard them.
Creating new cases
- Create a case directory under
test/cases/, e.g.test/cases/my-feature/0001. - Add a
cmdfile containing the Miller command line (one line), e.g.mlr cat test/input/simple.dkvp. - Use shared input under
test/input/, or add a localinputfile in the case directory; incmdyou can use${CASEDIR}so the command refers to the case directory (e.g.mlr cat ${CASEDIR}/input). - Run
mlr regtest -p test/cases/my-feature/0001to generateexpout(andexperrif the command produces stderr). If the command is expected to exit non-zero, add an emptyshould-failfile. - Run
mlr regtest test/cases/my-feature/0001(without-p) to confirm the case passes.
Optional: mlr — DSL script file when the test uses -f/put/filter; env — environment variables to set for the case (unset after).