Skip to contentSkip to conversation

t5402: use test_path_* helpers instead of test -e and test -f

PATCH In review Tilak Kumar 3 participants 3 messages Oct 29

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 t5402: use test_path_* helpers instead of test -e and test -f

Use test_path_exists and test_path_is_missing instead of "test -e" and "! test -f" in the post-merge hook tests, so that a failure reports which path was unexpectedly missing or present instead of failing silently.

---
 t/t5402-post-merge-hook.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
t/t5402-post-merge-hook.sh +3 -3
index c77aa56421..1e222ac28f 100755
@@ -37,12 +37,12 @@ test_expect_success 'setup clone hooks' '
 
 test_expect_success 'post-merge does not run for up-to-date ' '
 	GIT_DIR=clone1/.git git merge $commit0 &&
-	! test -f clone1/.git/post-merge.args
+	test_path_is_missing clone1/.git/post-merge.args
 '
 
 test_expect_success 'post-merge runs as expected ' '
 	GIT_DIR=clone1/.git git merge $commit1 &&
-	test -e clone1/.git/post-merge.args
+	test_path_exists clone1/.git/post-merge.args
 '
 
 test_expect_success 'post-merge from normal merge receives the right argument ' '
@@ -51,7 +51,7 @@ test_expect_success 'post-merge from normal merge receives the right argument '
 
 test_expect_success 'post-merge from squash merge runs as expected ' '
 	GIT_DIR=clone2/.git git merge --squash $commit1 &&
-	test -e clone2/.git/post-merge.args
+	test_path_exists clone2/.git/post-merge.args
 '
 
 test_expect_success 'post-merge from squash merge receives the right argument ' '
Signature · 1 line
2.55.0
#1 lore raw
Quoted 30 lines · Tilak Kumar

Use test_path_exists and test_path_is_missing instead of "test -e" and "! test -f" in the post-merge hook tests, so that a failure reports which path was unexpectedly missing or present instead of failing silently.

---
 t/t5402-post-merge-hook.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
t/t5402-post-merge-hook.sh +2 -2
index c77aa56421..1e222ac28f 100755
@@ -37,12 +37,12 @@ test_expect_success 'setup clone hooks' '
 
 test_expect_success 'post-merge does not run for up-to-date ' '
 	GIT_DIR=clone1/.git git merge $commit0 &&
-	! test -f clone1/.git/post-merge.args
+	test_path_is_missing clone1/.git/post-merge.args
 '
 
 test_expect_success 'post-merge runs as expected ' '
 	GIT_DIR=clone1/.git git merge $commit1 &&
-	test -e clone1/.git/post-merge.args
+	test_path_exists clone1/.git/post-merge.args
 '
 
 test_expect_success 'post-merge from normal merge receives the right argument ' '

t/t5402-post-merge-hook.sh test_expect_success 'post-merge from normal merge receives the right argument ' · line 57

Quoted 8 lines
t/t5402-post-merge-hook.sh +1 -1
@@ -51,7 +51,7 @@ test_expect_success 'post-merge from normal merge receives the right argument '
 
 test_expect_success 'post-merge from squash merge runs as expected ' '
 	GIT_DIR=clone2/.git git merge --squash $commit1 &&
-	test -e clone2/.git/post-merge.args
+	test_path_exists clone2/.git/post-merge.args
 '
 
 test_expect_success 'post-merge from squash merge receives the right argument ' '

looks correct to me.

Signature · 4 lines
Mark Craig Chu-Carroll (@MarkChuCarroll at gitlab)
*** Software Tools/Math Geek - Software Engineer at Gitlab
*** Work Email: [email protected] / [email protected]
*** Personal Blog: http://goodmath.org/blog / Personal email: [email protected]
#2 lore raw
Quoted 15 lines · Mark C. Chu-Carroll
Quoted 14 lines · Tilak Kumar

Use test_path_exists and test_path_is_missing instead of "test -e" and "! test -f" in the post-merge hook tests, so that a failure reports which path was unexpectedly missing or present instead of failing silently.

...

test_expect_success 'post-merge from squash merge runs as expected ' '

t/t5402-post-merge-hook.sh +1 -1
 	GIT_DIR=clone2/.git git merge --squash $commit1 &&
-	test -e clone2/.git/post-merge.args
+	test_path_exists clone2/.git/post-merge.args
 '
Quoted 3 lines
Quoted 1 line

test_expect_success 'post-merge from squash merge receives the right argument ' '

looks correct to me.

Thanks for writing and reviewing. Queued.