Add testing documentation to README
This commit is contained in:
parent
511397c955
commit
47341ee2d0
2 changed files with 10 additions and 1 deletions
|
@ -8,3 +8,10 @@ Provides some nice utility methods for bash scripts.
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
See [bashutils.staropensource.de](https://bashutils.staropensource.de)
|
See [bashutils.staropensource.de](https://bashutils.staropensource.de)
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
You run bashutils' tests by invoking the `test.sh` script.
|
||||||
|
The test script accepts environment variables as configuration.
|
||||||
|
### Configuration
|
||||||
|
| VARIABLE | TYPE | DEFAULT | DESCRIPTION |
|
||||||
|
| `FAILFAST` | bool | `false` | Terminates if a test fails instead of continuing |
|
||||||
|
|
4
test.sh
4
test.sh
|
@ -2,6 +2,8 @@
|
||||||
set -uo pipefail
|
set -uo pipefail
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
|
|
||||||
|
unset TEST TESTS
|
||||||
|
|
||||||
TESTS="
|
TESTS="
|
||||||
# Logging
|
# Logging
|
||||||
logger_diag
|
logger_diag
|
||||||
|
@ -25,7 +27,7 @@ check_command_defined
|
||||||
function invalid() { echo ":: Error: Invalid test ${TEST}, skipping"; }
|
function invalid() { echo ":: Error: Invalid test ${TEST}, skipping"; }
|
||||||
function fail() {
|
function fail() {
|
||||||
echo -e ":: Test ${TEST} failed\n ${*//\\n/\\n }"
|
echo -e ":: Test ${TEST} failed\n ${*//\\n/\\n }"
|
||||||
[ -n "${FAILFAST}" ] && exit 1
|
[ "${TEST_FAILFAST}" == "true" ] && exit 1
|
||||||
}
|
}
|
||||||
## Assertions
|
## Assertions
|
||||||
function assert_equals() {
|
function assert_equals() {
|
||||||
|
|
Loading…
Reference in a new issue