From 2ada15aff3b9d5990258229cf6ccfcc8640bc9bd Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 17 May 2017 17:03:54 -0400 Subject: [PATCH] libtest: Fix bugs in assert_file_has_content() First, we need to preserve whitespace in the regexps. Second, in the error path, all of our variables were wrong. Commit 376a2cc3f51f434c8e7f649633fb131832276116 is an excellent poster child for how many bugs one can introduce in a single commit for a ~5 line function. Closes: #777 Approved by: jlebon --- tests/common/libtest.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/common/libtest.sh b/tests/common/libtest.sh index fbc9f440..85e3e443 100644 --- a/tests/common/libtest.sh +++ b/tests/common/libtest.sh @@ -143,10 +143,10 @@ assert_not_has_dir () { assert_file_has_content () { fpath=$1 shift - for re in $@; do + 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'" + sed -e 's/^/# /' < "$fpath" >&2 + echo 1>&2 "File '$fpath' doesn't match regexp '$re'" exit 1 fi done