shelltestrunner: A tool for testing command-line programs.

[ program, testing ] [ Propose Tags ]

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.

Usage:

shelltestrunner [opts] executable testfile1 [testfile2 ...] [-- <test-framework runner opts>]

You can pass options through to test-framework's runner; they must go after -- at the end. You may be able to get a big speedup by running tests in parallel: try -- -j8.

Test file format:

# 0 or more comment lines beginning with #
-opt1 -opt2 arg1 arg2 # command line args, executable will be prepended
<<<
0 or more lines of input
>>> [/regexp/]
[..or 0 or more lines of expected output]
>>>2 [/regexp/]
[..or 0 or more lines of expected error output]
>>>= [/regexp/]
[..or expected numeric exit code]

The expected fields can also have a regular expression match expression following the delimiter on the same line, with no other data lines, in which case the test passes if the output is matched by the regexp. The regexp is enclosed in forward slashess. A ! preceding the expression negates the match. For example, to check that stdout does not contain "axe":

>>> !/axe/

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 whenever fields are omitted.

Issues:

  • output order is mixed up

  • option processing is weak

  • can't test input/output which does not end with newline

Wishlist:

  • configurable delimiters

  • multiple tests per file

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.2.1, 1.3, 1.3.1, 1.3.2, 1.3.3, 1.3.4, 1.3.5, 1.9, 1.9.0.1, 1.10
Dependencies base (>=3 && <4.18), HUnit, parseargs (>=0.1 && <0.2), parsec, process, regexpr (>=0.5.1), test-framework, test-framework-hunit (>=0.2 && <0.3) [details]
License LicenseRef-GPL
Author Simon Michael <simon@joyful.com>
Maintainer Simon Michael <simon@joyful.com>
Revised Revision 1 made by AndreasAbel at 2023-06-30T08:16:38Z
Category Testing
Home page http://joyful.com/darcsweb/darcsweb.cgi?r=shelltestrunner
Uploaded by SimonMichael at 2009-07-14T23:44:58Z
Distributions Debian:1.9, LTSHaskell:1.10, NixOS:1.10, Stackage:1.10
Reverse Dependencies 1 direct, 0 indirect [details]
Executables shelltestrunner
Downloads 21122 total (80 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2016-12-31 [all 7 reports]