Skip to content
Branch: master
Go to file

Latest commit


Failed to load latest commit information.
Latest commit message
Commit time


Circle CI

shrift is a minimal spec framework for testing your infrastructure using bash. shrift installs as a single script and executes bash one-liners as a test suite. No complex setup. No DSL.


Download shrift.

# download the script
$ curl -L -o shrift
# make executable
$ chmod +x shrift

Write and run your first spec.

# write a passing test
$ echo "test -x ./shrift" >
# execute with shrift
$ ./shrift


Spec Files

By default, shrift searches for files matching * in the current directory. You can pass a space-separated list of paths to shrift to expand the suite.

$ ./shrift specs                      # files in a sub-directory
$ ./shrift specs/{common,web}         # split up by role, one per directory
$ ./shrift specs/{common,web} # split up by role, one per file
$ ./shrift specs/**/*.sh              # globbing and wilcards are supported


Spec files must contain one test per line. A test is considered passing when the return code is 0. Any other condition is considered a failure.

# example spec file
test -f /etc/passwd
whoami | grep root
netstat -lntp | grep 80


Spec files may source a functions file or contain user-defined inline functions (contained on a single line) to encapsulate commonly used commands. For example, if there were a number of spec's checking for individual ports, instead of repeating the command, a one-liner function could be used instead.

# before function
netstat -lntp | grep 22
netstat -lntp | grep 80
netstat -lntp | grep 443

# define function
port() { netstat -lntp | grep $1; }

# after function
port 22
port 80
port 443

Sourcing a common functions file is also a supported workflow. For example:

function port() { netstat -lntp | grep $1; }
process() { ps ax | grep $1; }
mode() { stat -c "%a" $1 | grep $2; }

port 22
process sshd
mode /etc/passwd 644


By default, shrift executes the specs locally. shrift can also execute using docker exec and ssh, if the clients are already installed.

$ ./shrift -d [container_id]  # Run specs against a *running* container
$ ./shrift -s [hostname]      # Run specs against a remote host via SSH

For docker and ssh backends, custom client-specific options can be passed using -o 'opts...'.

For the ssh backends, each spec is executed using a separate ssh command. We recommend setting up ControlMaster and ControlPersist to re-use ssh sessions.


By default, shrift shows output from failing tests and a summary. If you want to see the output from all tests, set the verbose flag by passing -v.


A # comment line will start a new test block. shrift will add subsequent tests to the block until another comment or empty line is encountered. Blocks are only used in formatting output; they do not modify how the tests are executed.


MIT License

© 2015 This End Out, LLC


A minimal spec framework for running tests against your environment




You can’t perform that action at this time.