libtest: Support matching multiple regexps in files

For a future patch.

Closes: #652
Approved by: jlebon
This commit is contained in:
Colin Walters 2017-05-11 16:13:46 -04:00 committed by Atomic Bot
parent 3fae2eaf89
commit 376a2cc3f5

View File

@ -141,11 +141,15 @@ assert_not_has_dir () {
}
assert_file_has_content () {
if ! grep -q -e "$2" "$1"; then
sed -e 's/^/# /' < "$1" >&2
echo 1>&2 "File '$1' doesn't match regexp '$2'"
exit 1
fi
fpath=$1
shift
for re in $@; do
if ! grep -q -e "$re" "$fpath"; then
sed -e 's/^/# /' < "$1" >&2
echo 1>&2 "File '$1' doesn't match regexp '$2'"
exit 1
fi
done
}
assert_file_empty() {