The shelltestrunner package

Run a given program through "shell" tests specifed by one or more test
files, each of which can specify: command-line arguments, input, expected
output, expected stderr output, and expected exit code. This was
extracted from the hledger project, inspired by the tests in John
Wiegley's ledger project, and uses test-framework's test runner.

Each expected field can have either a regular expression match
expression, in which case the test passes if the output is matched, or 0
or more data lines, in which case the output must match these exactly. A
! preceding a regexp negates the match. The regular expression syntax
is that supported by the regexpr library.

Apart from the command line, all fields are optional. Only fields
specified in the test will be tested, unless you use the
-i/--implicit-tests flag, which will test for empty stdout, empty stderr,
or 0 exit code where fields are omitted.