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:
Andrew Bettison 2012-08-27 15:56:55 +09:30
parent bae2e2e4c2
commit 9149c80297
2 changed files with 9 additions and 3 deletions

View File

@ -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

View File

@ -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