Skip to content

Commit b28dbd3

Browse files
smancilltarleb
authored andcommitted
table-short-captions: ensure test do run
The new tests introduced by 5466859 (table-short-captions: replace golden files with expected strings, 2019-05-10) have been broken all this time. They always pass because they actually do not check anything. The assert_contains function receives the test string to be searched on stdin, but inside the function it is wrongly assumed to be in $1, which is not set. Thus, grep searches for the empty string and all the tests always pass. Fix by consuming stdin inside the function to get the content to check, which ensures the content is given as the query to grep.
1 parent bb071b8 commit b28dbd3

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

table-short-captions/test-table-short-captions-crossref.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ latex_result="$(cat -)"
44

55
assert_contains ()
66
{
7-
printf '%s' "$latex_result" | grep -qF "$1" -
7+
content="$(cat -)"
8+
printf '%s' "$latex_result" | grep -qF "$content" -
89
if [ $? -ne 0 ]; then
9-
printf 'Output does not contain `%s`.\n' "$1" >&2
10+
printf 'Output does not contain `%s`.\n' "$content" >&2
1011
exit 1
1112
fi
1213
}

table-short-captions/test-table-short-captions.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ latex_result="$(cat -)"
44

55
assert_contains ()
66
{
7-
printf '%s' "$latex_result" | grep -qF "$1" -
7+
content="$(cat -)"
8+
printf '%s' "$latex_result" | grep -qF "$content" -
89
if [ $? -ne 0 ]; then
9-
printf 'Output does not contain `%s`.\n' "$1" >&2
10+
printf 'Output does not contain `%s`.\n' "$content" >&2
1011
exit 1
1112
fi
1213
}

0 commit comments

Comments
 (0)