Skip Navigation

behave: record how a CLI tool behaves, then replay it against a rewrite of that tool

behave is a small Go tool (MIT) I made for checking whether a rewritten command line tool still behaves like the original.

You point it at the original binary. It reads --help, generates a few hundred cases (each flag, some values, stdin and file inputs, bad arguments), runs them and records stdout, stderr and the exit code into a YAML spec. Then you replay that spec against the new binary and every difference shows up as a failing case. Timestamps, pids and temp paths can be masked with regex rules, and the spec can live in CI.

I mostly used it on the uutils Rust rewrites of GNU coreutils, findutils, sed and procps. That led to 44 upstream bug reports and 51 fix PRs, 34 of them merged.

Install: go install github.com/emirmrkaljevic/behave/cmd/behave@latest (or the Homebrew tap). Feedback welcome.

github.com

Comments (3)