t/t6300: cleanup test_atom
Previously, when the executable part of "test_expect_{success,failure}" (inside "test_atom") got "eval"ed, it would have been syntactically incorrect if the second argument ($2, which is the format) to "test_atom" were enclosed in single quotes because the $variables would get interpolated even before the arguments to "test_expect_{success,failure}" are formed. So fix this and also some style issues along the way. Helped-by: Junio C Hamano <gitster@pobox.com> Mentored-by: Christian Couder <christian.couder@gmail.com> Mentored-by: Hariom Verma <hariom18599@gmail.com> Signed-off-by: Kousik Sanagavarapu <five231003@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
bcb6cae296
commit
04830eb762
|
@ -48,18 +48,22 @@ test_atom() {
|
||||||
sym) ref=refs/heads/sym ;;
|
sym) ref=refs/heads/sym ;;
|
||||||
*) ref=$1 ;;
|
*) ref=$1 ;;
|
||||||
esac
|
esac
|
||||||
|
format=$2
|
||||||
|
test_do=test_expect_${4:-success}
|
||||||
|
|
||||||
printf '%s\n' "$3" >expected
|
printf '%s\n' "$3" >expected
|
||||||
test_expect_${4:-success} $PREREQ "basic atom: $1 $2" "
|
$test_do $PREREQ "basic atom: $ref $format" '
|
||||||
git for-each-ref --format='%($2)' $ref >actual &&
|
git for-each-ref --format="%($format)" "$ref" >actual &&
|
||||||
sanitize_pgp <actual >actual.clean &&
|
sanitize_pgp <actual >actual.clean &&
|
||||||
test_cmp expected actual.clean
|
test_cmp expected actual.clean
|
||||||
"
|
'
|
||||||
|
|
||||||
# Automatically test "contents:size" atom after testing "contents"
|
# Automatically test "contents:size" atom after testing "contents"
|
||||||
if test "$2" = "contents"
|
if test "$format" = "contents"
|
||||||
then
|
then
|
||||||
# for commit leg, $3 is changed there
|
# for commit leg, $3 is changed there
|
||||||
expect=$(printf '%s' "$3" | wc -c)
|
expect=$(printf '%s' "$3" | wc -c)
|
||||||
test_expect_${4:-success} $PREREQ "basic atom: $1 contents:size" '
|
$test_do $PREREQ "basic atom: $ref contents:size" '
|
||||||
type=$(git cat-file -t "$ref") &&
|
type=$(git cat-file -t "$ref") &&
|
||||||
case $type in
|
case $type in
|
||||||
tag)
|
tag)
|
||||||
|
|
Loading…
Reference in New Issue