Skip to content

Commit 72aae6d

Browse files
avargitster
authored andcommitted
gettext tests: don't ignore "test-tool regex" exit code
Amend a prerequisite check added in 5c1ebcc (grep/icase: avoid kwsset on literal non-ascii strings, 2016-06-25) to do invoke 'test-tool regex' in such a way that we'll notice if it dies under SANITIZE=leak due to having a memory leak, as opposed to us not having the "ICASE" support we're checking for. Because we weren't making a distinction between the two I'd marked these tests as passing under SANITIZE=leak in 03d85e2 (leak tests: mark remaining leak-free tests as such, 2021-12-17). Doing this is tricky. Ideally "test_lazy_prereq" would materialize as a "real" test that we could check the exit code of with the same signal matching that "test_must_fail" does. However lazy prerequisites aren't real tests, and are instead lazily materialized in the guts of "test_have_prereq" when we've already started another test. We could detect the abort() (or similar) there and pass that exit code down, and fail the test that caused the prerequisites to be materialized. But that would require extensive changes to test-lib.sh and test-lib-functions.sh. Let's instead simply check if the exit code of "test-tool regex" is zero, and if so set the prerequisites. If it's non-zero let's run it again with "test_must_fail". We'll thus make a distinction between "bad" non-zero (segv etc) and "good" (exit 1 etc.). Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cf10c5b commit 72aae6d

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

t/t7812-grep-icase-non-ascii.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,19 @@ test_expect_success GETTEXT_LOCALE 'setup' '
1111
export LC_ALL
1212
'
1313

14-
test_have_prereq GETTEXT_LOCALE &&
15-
test-tool regex "HALLÓ" "Halló" ICASE &&
16-
test_set_prereq REGEX_LOCALE
14+
test_expect_success GETTEXT_LOCALE 'setup REGEX_LOCALE prerequisite' '
15+
# This "test-tool" invocation is identical...
16+
if test-tool regex "HALLÓ" "Halló" ICASE
17+
then
18+
test_set_prereq REGEX_LOCALE
19+
else
20+
21+
# ... to this one, but this way "test_must_fail" will
22+
# tell a segfault or abort() from the regexec() test
23+
# itself
24+
test_must_fail test-tool regex "HALLÓ" "Halló" ICASE
25+
fi
26+
'
1727

1828
test_expect_success REGEX_LOCALE 'grep literal string, no -F' '
1929
git grep -i "TILRAUN: Halló Heimur!" &&

0 commit comments

Comments
 (0)