Skip to main content

Doctests for your shell

Project description

Build Status

doctest-cli

Doctests for your shell. Run an executable, check the output.

Usage

Create a test script, say test.sh:

# Command
>>> echo hello
# Expected output
hello

# Another command
>>> echo 'Good bye!'
Good bye!

Test it:

./doctest-cli test.sh
doctest-cli: testing test/simple.sh
------------------------------------------------------------
All 2 tests passed

Dependencies

  • python

Extra

Check return code:

>>> false
$?=1

Check stderr output:

>>> echo error > /dev/stderr
! error

Custom shell:

#!/usr/local/bin/fish
>>> echo hello; and echo this is fish
hello
this is fish

Details

doctest-cli uses python's Subprocess module to spawn a new shell for each command and checks it against the provided output. All the environment variables are inherited from the current session.

Whitespace (including intervening newlines) is ignored. For example, the following test should pass:

>>>printf 'hello\n\n\n\n\n\nworld'
hello
world

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

doctest-cli-0.0.1.tar.gz (3.0 kB view hashes)

Uploaded Source

Built Distribution

doctest_cli-0.0.1-py3-none-any.whl (3.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page