Skip to content

Commit 283b365

Browse files
René Scharfegitster
authored andcommitted
t1402: work around shell quoting issue on NetBSD
The test fails for me on NetBSD 6.0.1 and reports: ok 1 - ref name '' is invalid ok 2 - ref name '/' is invalid ok 3 - ref name '/' is invalid with options --allow-onelevel ok 4 - ref name '/' is invalid with options --normalize error: bug in the test script: not 2 or 3 parameters to test-expect-success The alleged bug is in this line: invalid_ref NOT_MINGW '/' '--allow-onelevel --normalize' invalid_ref() constructs a test case description using its last argument, but the shell seems to split it up into two pieces if it contains a space. Minimal test case: # on NetBSD with /bin/sh $ a() { echo $#-$1-$2; } $ t="x"; a "${t:+$t}" 1-x- $ t="x y"; a "${t:+$t}" 2-x-y $ t="x y"; a "${t:+x y}" 1-x y- # and with bash $ t="x y"; a "${t:+$t}" 1-x y- $ t="x y"; a "${t:+x y}" 1-x y- This may be a bug in the shell, but here's a simple workaround: Construct the description string first and store it in a variable, and then use that to call test_expect_success(). Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4208fa5 commit 283b365

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

t/t1402-check-ref-format.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ valid_ref() {
1111
prereq=$1
1212
shift
1313
esac
14-
test_expect_success $prereq "ref name '$1' is valid${2:+ with options $2}" "
14+
desc="ref name '$1' is valid${2:+ with options $2}"
15+
test_expect_success $prereq "$desc" "
1516
git check-ref-format $2 '$1'
1617
"
1718
}
@@ -22,7 +23,8 @@ invalid_ref() {
2223
prereq=$1
2324
shift
2425
esac
25-
test_expect_success $prereq "ref name '$1' is invalid${2:+ with options $2}" "
26+
desc="ref name '$1' is invalid${2:+ with options $2}"
27+
test_expect_success $prereq "$desc" "
2628
test_must_fail git check-ref-format $2 '$1'
2729
"
2830
}

0 commit comments

Comments
 (0)