tests.sh — simple test library for testing commands.
tests.sh expected to find files named *.test.sh
in the directory, provided by
-d
flag, and they are treated as testcases.
See reference at REFERENCE.md.
tests.sh --- simple test library for testing commands.
tests.sh expected to find files named *.test.sh in current directory, and
they are treated as testcases.
Usage:
tests.sh -h
tests.sh [-v] [-d <dir>] [-s <path>] -A [-a]
tests.sh [-v] [-d <dir>] [-s <path>] -O [<name>]
Options:
-h | --help Show this help.
-A Run all testcases in current directory.
-a Run all testcases in subdirectories of current directory.
-O <name> Run specified testcase only. If no testcase specified, last
failed testcase will be ran.
-s <path> Run specified setup file before running every testcase.
-d <dir> Change directory to specified before running testcases.
[default: current working directory].
-v Verbosity. Flag can be specified several times.
-v Simple debug:
- only evaluated commands via tests:eval or
tests:pipe will be printed
-vv Output debug:
- stdout and stderr of evaluated commands will be
printed.
- also, sourced files will be printed.
-vvv Extended debug:
- notes about namespace and sourced files will be
expanded.
- file contents put via tests:put will be printed.
-vvvv Extreme debug:
- evaluated commands will be printed in form they
will be evaluated.
- stdin input for tests:eval and tests:put will be
printed.
- default debug level for `-O` mode.
-vvvvv Insane debug:
- output of background tasks will be printed in
realtime (no proper use without highlighting).
-vvvvvv Debug debug (oh, well).
- produce messages for debuggin library for itself.
- Create directory
tests/
(name can vary); - Create testcases, named
<test-case-name>.test.sh
, contains test code, written in bash, for example:tests:put a.txt <<EOF 123 EOF tests:ensure wc -l a.txt tests:assert-stdout-re '^1 '
- Run whole test suite using:
./tests.sh -d tests/ -A
; - Run one testcase using:
./tests.sh -d tests/ -O <test-case-name>
; - Run last failed testcase using:
./test.sh -d tests -O
;
Local set up script should be specified via -s
flag. local.setup.sh
. It
will be sources every time before each testcase.