mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-02-21 17:56:47 +00:00
Improve test framework: assertGrep error on bad file
This commit is contained in:
parent
aedb31e451
commit
cf03033429
@ -725,6 +725,16 @@ _tfw_assert_grep() {
|
||||
local file="$2"
|
||||
local pattern="$3"
|
||||
local message=
|
||||
if ! [ -e "$file" ]; then
|
||||
_tfw_error "$file does not exist"
|
||||
ret=254
|
||||
elif ! [ -f "$file" ]; then
|
||||
_tfw_error "$file is not a regular file"
|
||||
ret=254
|
||||
elif ! [ -r "$file" ]; then
|
||||
_tfw_error "$file is not readable"
|
||||
ret=254
|
||||
else
|
||||
local matches=$(( $(grep --regexp="$pattern" "$file" | wc -l) + 0 ))
|
||||
local done=false
|
||||
local ret=0
|
||||
@ -787,6 +797,7 @@ _tfw_assert_grep() {
|
||||
ret=254
|
||||
fi
|
||||
_tfw_shopt_restore
|
||||
fi
|
||||
if [ $ret -ne 0 ]; then
|
||||
_tfw_backtrace
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user