Skip to content

Commit 5684c2b

Browse files
avargitster
authored andcommitted
wildmatch test: use a paranoia pattern from nul_match()
Use a pattern from the nul_match() function in t7008-grep-binary.sh to make sure that we don't just fall through to the "else" if there's an unknown parameter. This is something I added in commit 77f6f44 ("grep: add a test helper function for less verbose -f \0 tests", 2017-05-20) to grep tests, which were modeled on these wildmatch tests, and I'm now porting back to the original wildmatch tests. I am not using the "say '...'; exit 1" pattern from t0000-basic.sh because if I fail I want to run the rest of the tests (unless under -i), and doing this makes sure we do that and don't exit right away without fully reporting our errors. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f5ebe8f commit 5684c2b

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

t/t3070-wildmatch.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ match() {
1010
test_expect_success "wildmatch: match '$3' '$4'" "
1111
test-wildmatch wildmatch '$3' '$4'
1212
"
13-
else
13+
elif test "$1" = 0
14+
then
1415
test_expect_success "wildmatch: no match '$3' '$4'" "
1516
! test-wildmatch wildmatch '$3' '$4'
1617
"
18+
else
19+
test_expect_success "PANIC: Test framework error. Unknown matches value $1" 'false'
1720
fi
1821
}
1922

@@ -23,10 +26,13 @@ imatch() {
2326
test_expect_success "iwildmatch: match '$2' '$3'" "
2427
test-wildmatch iwildmatch '$2' '$3'
2528
"
26-
else
29+
elif test "$1" = 0
30+
then
2731
test_expect_success "iwildmatch: no match '$2' '$3'" "
2832
! test-wildmatch iwildmatch '$2' '$3'
2933
"
34+
else
35+
test_expect_success "PANIC: Test framework error. Unknown matches value $1" 'false'
3036
fi
3137
}
3238

@@ -36,10 +42,13 @@ pathmatch() {
3642
test_expect_success "pathmatch: match '$2' '$3'" "
3743
test-wildmatch pathmatch '$2' '$3'
3844
"
39-
else
45+
elif test "$1" = 0
46+
then
4047
test_expect_success "pathmatch: no match '$2' '$3'" "
4148
! test-wildmatch pathmatch '$2' '$3'
4249
"
50+
else
51+
test_expect_success "PANIC: Test framework error. Unknown matches value $1" 'false'
4352
fi
4453
}
4554

0 commit comments

Comments
 (0)