diff mbox series

[03/11] t3407: use test_cmp_rev

Message ID dfa27d7a8e7e0a9e03e228653ebff639a449ac77.1631094563.git.gitgitgadget@gmail.com (mailing list archive)
State Superseded
Headers show
Series rebase: dereference tags | expand

Commit Message

Phillip Wood Sept. 8, 2021, 9:49 a.m. UTC
From: Phillip Wood <phillip.wood@dunelm.org.uk>

This provides better diagnostics if a test fails

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
---
 t/t3407-rebase-abort.sh | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Ævar Arnfjörð Bjarmason Sept. 8, 2021, 10:40 a.m. UTC | #1
On Wed, Sep 08 2021, Phillip Wood via GitGitGadget wrote:

> @@ -54,9 +54,9 @@ testrebase() {
>  		echo d >> a &&
>  		git add a &&
>  		test_must_fail git rebase --continue &&
> -		test $(git rev-parse HEAD) != $(git rev-parse main) &&
> +		! test_cmp_rev HEAD main &&

Use "test_cmp_rev !", making the shell do the negation is troublesome
for the same reason we don't do it with git command, it potentially
hides segfaults (and that test helper invokes "git", hence the optional
"!" first rgument).
Phillip Wood Sept. 8, 2021, 1:42 p.m. UTC | #2
On 08/09/2021 11:40, Ævar Arnfjörð Bjarmason wrote:
> 
> On Wed, Sep 08 2021, Phillip Wood via GitGitGadget wrote:
> 
>> @@ -54,9 +54,9 @@ testrebase() {
>>   		echo d >> a &&
>>   		git add a &&
>>   		test_must_fail git rebase --continue &&
>> -		test $(git rev-parse HEAD) != $(git rev-parse main) &&
>> +		! test_cmp_rev HEAD main &&
> 
> Use "test_cmp_rev !", making the shell do the negation is troublesome
> for the same reason we don't do it with git command, it potentially
> hides segfaults (and that test helper invokes "git", hence the optional
> "!" first argument).

Thanks, I didn't realize one could pass "!" to test_cmp_rev - it gives a 
better message on failure as well as avoiding hidden segfaults

Best Wishes

Phillip
diff mbox series

Patch

diff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh
index 0ad21966bc5..8d913d73bad 100755
--- a/t/t3407-rebase-abort.sh
+++ b/t/t3407-rebase-abort.sh
@@ -29,7 +29,7 @@  testrebase() {
 		test_must_fail git rebase$type main &&
 		test_path_is_dir "$dotest" &&
 		git rebase --abort &&
-		test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
+		test_cmp_rev to-rebase pre-rebase &&
 		test ! -d "$dotest"
 	'
 
@@ -39,9 +39,9 @@  testrebase() {
 		test_must_fail git rebase$type main &&
 		test_path_is_dir "$dotest" &&
 		test_must_fail git rebase --skip &&
-		test $(git rev-parse HEAD) = $(git rev-parse main) &&
+		test_cmp_rev HEAD main &&
 		git rebase --abort &&
-		test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
+		test_cmp_rev to-rebase pre-rebase &&
 		test ! -d "$dotest"
 	'
 
@@ -54,9 +54,9 @@  testrebase() {
 		echo d >> a &&
 		git add a &&
 		test_must_fail git rebase --continue &&
-		test $(git rev-parse HEAD) != $(git rev-parse main) &&
+		! test_cmp_rev HEAD main &&
 		git rebase --abort &&
-		test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
+		test_cmp_rev to-rebase pre-rebase &&
 		test ! -d "$dotest"
 	'
 
@@ -91,7 +91,7 @@  test_expect_success 'rebase --apply --quit' '
 	test_path_is_dir .git/rebase-apply &&
 	head_before=$(git rev-parse HEAD) &&
 	git rebase --quit &&
-	test $(git rev-parse HEAD) = $head_before &&
+	test_cmp_rev HEAD $head_before &&
 	test ! -d .git/rebase-apply
 '
 
@@ -102,7 +102,7 @@  test_expect_success 'rebase --merge --quit' '
 	test_path_is_dir .git/rebase-merge &&
 	head_before=$(git rev-parse HEAD) &&
 	git rebase --quit &&
-	test $(git rev-parse HEAD) = $head_before &&
+	test_cmp_rev HEAD $head_before &&
 	test ! -d .git/rebase-merge
 '