tests: Fix regex escaping in test-summary-view.sh

There were some regex special characters in the pattern strings, which I
think were causing the test to fail on some Travis builds due to using
an invalid regex.

Fix that by matching using fixed strings instead. We don’t need regexes
here. Use a new assert_file_has_content_literal to do that for us.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #838
Approved by: cgwalters
This commit is contained in:
Philip Withnall 2017-05-08 16:04:26 +01:00 committed by Atomic Bot
parent 4e13361c8e
commit 9690a54e47
2 changed files with 16 additions and 11 deletions

View File

@ -85,6 +85,13 @@ assert_file_has_content () {
fi fi
} }
assert_file_has_content_literal () {
if ! grep -q -F -e "$2" "$1"; then
sed -e 's/^/# /' < "$1" >&2
fatal "File '$1' doesn't match fixed string list '$2'"
fi
}
assert_symlink_has_content () { assert_symlink_has_content () {
if ! test -L "$1"; then if ! test -L "$1"; then
echo 1>&2 "File '$1' is not a symbolic link" echo 1>&2 "File '$1' is not a symbolic link"

View File

@ -47,20 +47,18 @@ ${CMD_PREFIX} ostree --repo=repo pull --mirror origin
# Check the summary file exists in the checkout, and can be viewed. # Check the summary file exists in the checkout, and can be viewed.
assert_has_file repo/summary assert_has_file repo/summary
output=$(${OSTREE} summary --view) ${OSTREE} summary --view > summary.txt
echo "$output" | sed -e 's/^/# /' assert_file_has_content_literal summary.txt "* main"
echo "$output" | grep --quiet --no-messages "* main" assert_file_has_content_literal summary.txt "* other"
echo "$output" | grep --quiet --no-messages "* other" assert_file_has_content_literal summary.txt "ostree.summary.last-modified"
echo "$output" | grep --quiet --no-messages "ostree.summary.last-modified" assert_file_has_content_literal summary.txt "Static Deltas (ostree.static-deltas): {}"
echo "$output" | grep --quiet --no-messages "Static Deltas (ostree.static-deltas): {}"
echo "ok view summary" echo "ok view summary"
# Check the summary can be viewed raw too. # Check the summary can be viewed raw too.
raw_output=$(${OSTREE} summary --view --raw) ${OSTREE} summary --view --raw > raw-summary.txt
echo "$raw_output" | sed -e 's/^/# /' assert_file_has_content_literal raw-summary.txt "('main', ("
echo "$raw_output" | grep --quiet --no-messages "('main', (" assert_file_has_content_literal raw-summary.txt "('other', ("
echo "$raw_output" | grep --quiet --no-messages "('other', (" assert_file_has_content_literal raw-summary.txt "{'ostree.summary.last-modified': <uint64"
echo "$raw_output" | grep --quiet --no-messages "{'ostree.summary.last-modified': <uint64"
echo "ok view summary raw" echo "ok view summary raw"
libtest_cleanup_gpg libtest_cleanup_gpg