diff mbox series

[v3,01/11] t6027: modernise tests

Message ID 20201005122646.27994-2-alban.gruin@gmail.com
State New
Headers show
Series Rewrite the remaining merge strategies from shell to C | expand

Commit Message

Alban Gruin Oct. 5, 2020, 12:26 p.m. UTC
Some tests in t6027 uses a if/then/else to check if a command failed or
not, but we have the `test_must_fail' function to do it correctly for us
nowadays.

Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
---
 t/t6407-merge-binary.sh | 27 ++++++---------------------
 1 file changed, 6 insertions(+), 21 deletions(-)

Comments

Junio C Hamano Oct. 6, 2020, 8:50 p.m. UTC | #1
Alban Gruin <alban.gruin@gmail.com> writes:

> Some tests in t6027 uses a if/then/else to check if a command failed or

s/uses/use/;

> not, but we have the `test_must_fail' function to do it correctly for us
> nowadays.

Makes sense.  The patch text reads good, too.

> Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
> ---
>  t/t6407-merge-binary.sh | 27 ++++++---------------------
>  1 file changed, 6 insertions(+), 21 deletions(-)
>
> diff --git a/t/t6407-merge-binary.sh b/t/t6407-merge-binary.sh
> index 4e6c7cb77e..071d3f7343 100755
> --- a/t/t6407-merge-binary.sh
> +++ b/t/t6407-merge-binary.sh
> @@ -5,7 +5,6 @@ test_description='ask merge-recursive to merge binary files'
>  . ./test-lib.sh
>  
>  test_expect_success setup '
> -
>  	cat "$TEST_DIRECTORY"/test-binary-1.png >m &&
>  	git add m &&
>  	git ls-files -s | sed -e "s/ 0	/ 1	/" >E1 &&
> @@ -35,33 +34,19 @@ test_expect_success setup '
>  '
>  
>  test_expect_success resolve '
> -
>  	rm -f a* m* &&
>  	git reset --hard anchor &&
> -
> -	if git merge -s resolve master
> -	then
> -		echo Oops, should not have succeeded
> -		false
> -	else
> -		git ls-files -s >current
> -		test_cmp expect current
> -	fi
> +	test_must_fail git merge -s resolve master &&
> +	git ls-files -s >current &&
> +	test_cmp expect current
>  '
>  
>  test_expect_success recursive '
> -
>  	rm -f a* m* &&
>  	git reset --hard anchor &&
> -
> -	if git merge -s recursive master
> -	then
> -		echo Oops, should not have succeeded
> -		false
> -	else
> -		git ls-files -s >current
> -		test_cmp expect current
> -	fi
> +	test_must_fail git merge -s recursive master &&
> +	git ls-files -s >current &&
> +	test_cmp expect current
>  '
>  
>  test_done
diff mbox series

Patch

diff --git a/t/t6407-merge-binary.sh b/t/t6407-merge-binary.sh
index 4e6c7cb77e..071d3f7343 100755
--- a/t/t6407-merge-binary.sh
+++ b/t/t6407-merge-binary.sh
@@ -5,7 +5,6 @@  test_description='ask merge-recursive to merge binary files'
 . ./test-lib.sh
 
 test_expect_success setup '
-
 	cat "$TEST_DIRECTORY"/test-binary-1.png >m &&
 	git add m &&
 	git ls-files -s | sed -e "s/ 0	/ 1	/" >E1 &&
@@ -35,33 +34,19 @@  test_expect_success setup '
 '
 
 test_expect_success resolve '
-
 	rm -f a* m* &&
 	git reset --hard anchor &&
-
-	if git merge -s resolve master
-	then
-		echo Oops, should not have succeeded
-		false
-	else
-		git ls-files -s >current
-		test_cmp expect current
-	fi
+	test_must_fail git merge -s resolve master &&
+	git ls-files -s >current &&
+	test_cmp expect current
 '
 
 test_expect_success recursive '
-
 	rm -f a* m* &&
 	git reset --hard anchor &&
-
-	if git merge -s recursive master
-	then
-		echo Oops, should not have succeeded
-		false
-	else
-		git ls-files -s >current
-		test_cmp expect current
-	fi
+	test_must_fail git merge -s recursive master &&
+	git ls-files -s >current &&
+	test_cmp expect current
 '
 
 test_done