[02/15] t6120-describe: modernize the 'check_describe' helper
diff mbox series

Message ID 20190919214712.7348-3-szeder.dev@gmail.com
State New
Headers show
Series
  • name-rev: eliminate recursion
Related show

Commit Message

SZEDER Gábor Sept. 19, 2019, 9:46 p.m. UTC
The 'check_describe' helper function runs 'git describe' outside of
'test_expect_success' blocks, with extra hand-rolled code to record
and examine its exit code.

Update this helper and move the 'git decribe' invocation inside the
'test_expect_success' block.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
---
 t/t6120-describe.sh | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

Comments

Junio C Hamano Sept. 20, 2019, 9:49 p.m. UTC | #1
SZEDER Gábor <szeder.dev@gmail.com> writes:

> The 'check_describe' helper function runs 'git describe' outside of
> 'test_expect_success' blocks, with extra hand-rolled code to record
> and examine its exit code.
>
> Update this helper and move the 'git decribe' invocation inside the
> 'test_expect_success' block.

Thanks for a fix.  This makes quite a lot of sense.

>
> Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
> ---
>  t/t6120-describe.sh | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh
> index 0bf7e0c8bc..07e6793e84 100755
> --- a/t/t6120-describe.sh
> +++ b/t/t6120-describe.sh
> @@ -14,14 +14,12 @@ test_description='test describe'
>  check_describe () {
>  	expect="$1"
>  	shift
> -	R=$(git describe "$@" 2>err.actual)
> -	S=$?
> -	cat err.actual >&3
> -	test_expect_success "describe $*" '
> -	test $S = 0 &&
> +	describe_opts="$@"
> +	test_expect_success "describe $describe_opts" '
> +	R=$(git describe $describe_opts 2>err.actual) &&
>  	case "$R" in
>  	$expect)	echo happy ;;
> -	*)	echo "Oops - $R is not $expect";
> +	*)	echo "Oops - $R is not $expect" &&
>  		false ;;
>  	esac
>  	'

Patch
diff mbox series

diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh
index 0bf7e0c8bc..07e6793e84 100755
--- a/t/t6120-describe.sh
+++ b/t/t6120-describe.sh
@@ -14,14 +14,12 @@  test_description='test describe'
 check_describe () {
 	expect="$1"
 	shift
-	R=$(git describe "$@" 2>err.actual)
-	S=$?
-	cat err.actual >&3
-	test_expect_success "describe $*" '
-	test $S = 0 &&
+	describe_opts="$@"
+	test_expect_success "describe $describe_opts" '
+	R=$(git describe $describe_opts 2>err.actual) &&
 	case "$R" in
 	$expect)	echo happy ;;
-	*)	echo "Oops - $R is not $expect";
+	*)	echo "Oops - $R is not $expect" &&
 		false ;;
 	esac
 	'