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.
I’m curious, how does this compare to
expect?Good question. expect is for scripting interactive programs: you write the dialogue by hand (send this, wait for that prompt) and it drives the program through a pseudo-terminal.
behave is for non-interactive commands, and you don’t write the cases. It reads --help and the man page, generates a few hundred invocations (single flags, flag pairs, listed values, odd stdin, missing files, bad values), and records stdout, stderr and the exit code of each one as YAML. Then it replays the same cases against a second binary and diffs them. So the main use is checking a rewrite or a refactor against the original, like the uutils coreutils ports against GNU.
Each case just gets a fixed stdin and no terminal, so for a REPL or anything that prompts, expect is still the right tool.
Thank you for explaining. That’s interesting. I have no use for it, but it should come handy in more rewrites.


