mirror of
https://github.com/git/git
synced 2024-10-28 19:25:47 +00:00
t0030-t0050: avoid pipes with Git on LHS
Pipes ignore error codes of LHS command and thus we should not use them with Git in tests. As an alternative, use a 'tmp' file to write the Git output so we can test the exit code. Signed-off-by: Shubham Mishra <shivam828787@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
9b6d1fc48a
commit
eed36fce38
2 changed files with 50 additions and 28 deletions
|
@ -13,6 +13,10 @@ s40=' '
|
||||||
sss="$s40$s40$s40$s40$s40$s40$s40$s40$s40$s40" # 400
|
sss="$s40$s40$s40$s40$s40$s40$s40$s40$s40$s40" # 400
|
||||||
ttt="$t40$t40$t40$t40$t40$t40$t40$t40$t40$t40" # 400
|
ttt="$t40$t40$t40$t40$t40$t40$t40$t40$t40$t40" # 400
|
||||||
|
|
||||||
|
printf_git_stripspace () {
|
||||||
|
printf "$1" | git stripspace
|
||||||
|
}
|
||||||
|
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
'long lines without spaces should be unchanged' '
|
'long lines without spaces should be unchanged' '
|
||||||
echo "$ttt" >expect &&
|
echo "$ttt" >expect &&
|
||||||
|
@ -225,32 +229,38 @@ test_expect_success \
|
||||||
|
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
'text without newline at end should end with newline' '
|
'text without newline at end should end with newline' '
|
||||||
test $(printf "$ttt" | git stripspace | wc -l) -gt 0 &&
|
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt" &&
|
||||||
test $(printf "$ttt$ttt" | git stripspace | wc -l) -gt 0 &&
|
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt" &&
|
||||||
test $(printf "$ttt$ttt$ttt" | git stripspace | wc -l) -gt 0 &&
|
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$ttt" &&
|
||||||
test $(printf "$ttt$ttt$ttt$ttt" | git stripspace | wc -l) -gt 0
|
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$ttt$ttt"
|
||||||
'
|
'
|
||||||
|
|
||||||
# text plus spaces at the end:
|
# text plus spaces at the end:
|
||||||
|
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
'text plus spaces without newline at end should end with newline' '
|
'text plus spaces without newline at end should end with newline' '
|
||||||
test $(printf "$ttt$sss" | git stripspace | wc -l) -gt 0 &&
|
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$sss" &&
|
||||||
test $(printf "$ttt$ttt$sss" | git stripspace | wc -l) -gt 0 &&
|
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$sss" &&
|
||||||
test $(printf "$ttt$ttt$ttt$sss" | git stripspace | wc -l) -gt 0 &&
|
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$ttt$sss" &&
|
||||||
test $(printf "$ttt$sss$sss" | git stripspace | wc -l) -gt 0 &&
|
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$sss$sss" &&
|
||||||
test $(printf "$ttt$ttt$sss$sss" | git stripspace | wc -l) -gt 0 &&
|
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$ttt$sss$sss" &&
|
||||||
test $(printf "$ttt$sss$sss$sss" | git stripspace | wc -l) -gt 0
|
test_stdout_line_count -gt 0 printf_git_stripspace "$ttt$sss$sss$sss"
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
'text plus spaces without newline at end should not show spaces' '
|
'text plus spaces without newline at end should not show spaces' '
|
||||||
! (printf "$ttt$sss" | git stripspace | grep " " >/dev/null) &&
|
printf "$ttt$sss" | git stripspace >tmp &&
|
||||||
! (printf "$ttt$ttt$sss" | git stripspace | grep " " >/dev/null) &&
|
! grep " " tmp >/dev/null &&
|
||||||
! (printf "$ttt$ttt$ttt$sss" | git stripspace | grep " " >/dev/null) &&
|
printf "$ttt$ttt$sss" | git stripspace >tmp &&
|
||||||
! (printf "$ttt$sss$sss" | git stripspace | grep " " >/dev/null) &&
|
! grep " " tmp >/dev/null &&
|
||||||
! (printf "$ttt$ttt$sss$sss" | git stripspace | grep " " >/dev/null) &&
|
printf "$ttt$ttt$ttt$sss" | git stripspace >tmp &&
|
||||||
! (printf "$ttt$sss$sss$sss" | git stripspace | grep " " >/dev/null)
|
! grep " " tmp >/dev/null &&
|
||||||
|
printf "$ttt$sss$sss" | git stripspace >tmp &&
|
||||||
|
! grep " " tmp >/dev/null &&
|
||||||
|
printf "$ttt$ttt$sss$sss" | git stripspace >tmp &&
|
||||||
|
! grep " " tmp >/dev/null &&
|
||||||
|
printf "$ttt$sss$sss$sss" | git stripspace >tmp &&
|
||||||
|
! grep " " tmp >/dev/null
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
|
@ -282,12 +292,18 @@ test_expect_success \
|
||||||
|
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
'text plus spaces at end should not show spaces' '
|
'text plus spaces at end should not show spaces' '
|
||||||
! (echo "$ttt$sss" | git stripspace | grep " " >/dev/null) &&
|
echo "$ttt$sss" | git stripspace >tmp &&
|
||||||
! (echo "$ttt$ttt$sss" | git stripspace | grep " " >/dev/null) &&
|
! grep " " tmp >/dev/null &&
|
||||||
! (echo "$ttt$ttt$ttt$sss" | git stripspace | grep " " >/dev/null) &&
|
echo "$ttt$ttt$sss" | git stripspace >tmp &&
|
||||||
! (echo "$ttt$sss$sss" | git stripspace | grep " " >/dev/null) &&
|
! grep " " tmp >/dev/null &&
|
||||||
! (echo "$ttt$ttt$sss$sss" | git stripspace | grep " " >/dev/null) &&
|
echo "$ttt$ttt$ttt$sss" | git stripspace >tmp &&
|
||||||
! (echo "$ttt$sss$sss$sss" | git stripspace | grep " " >/dev/null)
|
! grep " " tmp >/dev/null &&
|
||||||
|
echo "$ttt$sss$sss" | git stripspace >tmp &&
|
||||||
|
! grep " " tmp >/dev/null &&
|
||||||
|
echo "$ttt$ttt$sss$sss" | git stripspace >tmp &&
|
||||||
|
! grep " " tmp >/dev/null &&
|
||||||
|
echo "$ttt$sss$sss$sss" | git stripspace >tmp &&
|
||||||
|
! grep " " tmp >/dev/null
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
|
@ -339,11 +355,16 @@ test_expect_success \
|
||||||
|
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
'spaces without newline at end should not show spaces' '
|
'spaces without newline at end should not show spaces' '
|
||||||
! (printf "" | git stripspace | grep " " >/dev/null) &&
|
printf "" | git stripspace >tmp &&
|
||||||
! (printf "$sss" | git stripspace | grep " " >/dev/null) &&
|
! grep " " tmp >/dev/null &&
|
||||||
! (printf "$sss$sss" | git stripspace | grep " " >/dev/null) &&
|
printf "$sss" | git stripspace >tmp &&
|
||||||
! (printf "$sss$sss$sss" | git stripspace | grep " " >/dev/null) &&
|
! grep " " tmp >/dev/null &&
|
||||||
! (printf "$sss$sss$sss$sss" | git stripspace | grep " " >/dev/null)
|
printf "$sss$sss" | git stripspace >tmp &&
|
||||||
|
! grep " " tmp >/dev/null &&
|
||||||
|
printf "$sss$sss$sss" | git stripspace >tmp &&
|
||||||
|
! grep " " tmp >/dev/null &&
|
||||||
|
printf "$sss$sss$sss$sss" | git stripspace >tmp &&
|
||||||
|
! grep " " tmp >/dev/null
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
|
|
|
@ -104,7 +104,8 @@ test_expect_failure CASE_INSENSITIVE_FS 'add (with different case)' '
|
||||||
rm camelcase &&
|
rm camelcase &&
|
||||||
echo 1 >CamelCase &&
|
echo 1 >CamelCase &&
|
||||||
git add CamelCase &&
|
git add CamelCase &&
|
||||||
camel=$(git ls-files | grep -i camelcase) &&
|
git ls-files >tmp &&
|
||||||
|
camel=$(grep -i camelcase tmp) &&
|
||||||
test $(echo "$camel" | wc -l) = 1 &&
|
test $(echo "$camel" | wc -l) = 1 &&
|
||||||
test "z$(git cat-file blob :$camel)" = z1
|
test "z$(git cat-file blob :$camel)" = z1
|
||||||
'
|
'
|
||||||
|
|
Loading…
Reference in a new issue