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 77f6f4406f ("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 <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Jan 30, 2018 at 21:21 UTC 5684c2bc69d6b06cca708a859843c9b2468068d8
1 file changed +12 -3
t/t3070-wildmatch.sh
+12 -3
@@ -10,10 +10,13 @@ match() {
10 test_expect_success "wildmatch: match '$3' '$4'" "
11 test-wildmatch wildmatch '$3' '$4'
12 "
13 - else
13 + elif test "$1" = 0
14 + then
15 test_expect_success "wildmatch: no match '$3' '$4'" "
16 ! test-wildmatch wildmatch '$3' '$4'
17 "
18 + else
19 + test_expect_success "PANIC: Test framework error. Unknown matches value $1" 'false'
20 fi
21 }
22
@@ -23,10 +26,13 @@ imatch() {
26 test_expect_success "iwildmatch: match '$2' '$3'" "
27 test-wildmatch iwildmatch '$2' '$3'
28 "
26 - else
29 + elif test "$1" = 0
30 + then
31 test_expect_success "iwildmatch: no match '$2' '$3'" "
32 ! test-wildmatch iwildmatch '$2' '$3'
33 "
34 + else
35 + test_expect_success "PANIC: Test framework error. Unknown matches value $1" 'false'
36 fi
37 }
38
@@ -36,10 +42,13 @@ pathmatch() {
42 test_expect_success "pathmatch: match '$2' '$3'" "
43 test-wildmatch pathmatch '$2' '$3'
44 "
39 - else
45 + elif test "$1" = 0
46 + then
47 test_expect_success "pathmatch: no match '$2' '$3'" "
48 ! test-wildmatch pathmatch '$2' '$3'
49 "
50 + else
51 + test_expect_success "PANIC: Test framework error. Unknown matches value $1" 'false'
52 fi
53 }
54