shpec provides rspec-like testing for POSIX sh scripts.
Example:
#!/bin/sh
describe 'my-script'
it 'outputs hostname'
# sugar for: expr "$(my-script)" = "$(hostname)"
# but with diagnostic output in case of failure
expect "$(my-script)" to = "$(hostname)"
end
it 'performs arithmetic'
expect "$(my-script 1 + 1)" to = 2
end
endWhen run:
$ shpec -f my-script-shpec.sh
my-script
outputs hostname
performs arithmetic
Comparison failed (using =):
Expected:
2
Got:
1
FAIL my-script-shpec.sh
$ echo $?
1
# Install in /usr/local
$ make test
$ sudo make installThe default installation location is /usr/local. If you want to
install shpec somewhere else, set PREFIX.
# Install somewhere else
$ PREFIX=/tmp make installDario Hamidi <dario.hamidi@gmail.com>, 2013, Github
All code is licensed under the GNU GPL. Documentation is licensed under the GNU FDL.