From 376a2cc3f51f434c8e7f649633fb131832276116 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 11 May 2017 16:13:46 -0400 Subject: [PATCH] libtest: Support matching multiple regexps in files For a future patch. Closes: #652 Approved by: jlebon --- tests/common/libtest.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/common/libtest.sh b/tests/common/libtest.sh index 7d849ba6..fbc9f440 100644 --- a/tests/common/libtest.sh +++ b/tests/common/libtest.sh @@ -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() {