mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-04-07 02:56:44 +00:00
Improve test framework: assert '!' command...
The assert command now supports leading '!' args in its command, each negating the sense of the following command.
This commit is contained in:
parent
bae2e2e4c2
commit
9149c80297
@ -844,7 +844,13 @@ _tfw_parse_times_to_milliseconds() {
|
||||
}
|
||||
|
||||
_tfw_assert() {
|
||||
if ! "$@"; then
|
||||
local sense=
|
||||
while [ "$1" = '!' ]; do
|
||||
sense="$sense !"
|
||||
shift
|
||||
done
|
||||
"$@"
|
||||
if [ $sense $? -ne 0 ]; then
|
||||
_tfw_failmsg "assertion failed: ${_tfw_message:-$*}"
|
||||
_tfw_backtrace
|
||||
return 1
|
||||
|
@ -28,7 +28,7 @@ setup() {
|
||||
doc_GetCreateInstanceDir="Get creates instance directory"
|
||||
setup_GetCreateInstanceDir() {
|
||||
setup
|
||||
assert [ ! -d "$SERVALINSTANCE_PATH" ]
|
||||
assert ! [ -d "$SERVALINSTANCE_PATH" ]
|
||||
}
|
||||
test_GetCreateInstanceDir() {
|
||||
executeOk_servald config get
|
||||
@ -38,7 +38,7 @@ test_GetCreateInstanceDir() {
|
||||
doc_SetCreateInstanceDir="Set creates instance directory"
|
||||
setup_SetCreateInstanceDir() {
|
||||
setup
|
||||
assert [ ! -d "$SERVALINSTANCE_PATH" ]
|
||||
assert ! [ -d "$SERVALINSTANCE_PATH" ]
|
||||
}
|
||||
test_SetCreateInstanceDir() {
|
||||
executeOk_servald config set foo bar
|
||||
|
Loading…
x
Reference in New Issue
Block a user