Skip to contentSkip to conversation

replace test -f with test_path_is_file

PATCH In review Shubham Verma 2 participants 2 messages Mar 11, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 replace test -f with test_path_is_file

Although test -f has the same functionality as test_path_is_file(), in the case where test_path_is_file() fails, we get much better debugging information.

Replace test -f with test_path_is_file() so that future developers will have a better experience debugging these test cases.

---
 t/t9801-git-p4-branch.sh | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)
t/t9801-git-p4-branch.sh +19 -19
index 67ff2711f5..214c2a183d 100755
@@ -200,19 +200,19 @@ test_expect_success 'git p4 clone simple branches' '
 		git p4 clone --dest=. --detect-branches //depot@all &&
 		git log --all --graph --decorate --stat &&
 		git reset --hard p4/depot/branch1 &&
-		test -f file1 &&
-		test -f file2 &&
-		test -f file3 &&
+		test_path_is_file file1 &&
+		test_path_is_file file2 &&
+		test_path_is_file file3 &&
 		grep update file2 &&
 		git reset --hard p4/depot/branch2 &&
-		test -f file1 &&
-		test -f file2 &&
+		test_path_is_file file1 &&
+		test_path_is_file file2 &&
 		test ! -f file3 &&
 		! grep update file2 &&
 		git reset --hard p4/depot/branch3 &&
-		test -f file1 &&
-		test -f file2 &&
-		test -f file3 &&
+		test_path_is_file file1 &&
+		test_path_is_file file2 &&
+		test_path_is_file file3 &&
 		grep update file2 &&
 		cd "$cli" &&
 		cd branch1 &&
@@ -603,22 +603,22 @@ test_expect_success 'git p4 clone simple branches with base folder on server sid
 		git p4 clone --dest=. --use-client-spec  --detect-branches //depot@all &&
 		git log --all --graph --decorate --stat &&
 		git reset --hard p4/depot/branch1 &&
-		test -f file1 &&
-		test -f file2 &&
-		test -f file3 &&
-		test -f sub_file1 &&
+		test_path_is_file file1 &&
+		test_path_is_file file2 &&
+		test_path_is_file file3 &&
+		test_path_is_file sub_file1 &&
 		grep update file2 &&
 		git reset --hard p4/depot/branch2 &&
-		test -f file1 &&
-		test -f file2 &&
+		test_path_is_file file1 &&
+		test_path_is_file file2 &&
 		test ! -f file3 &&
-		test -f sub_file1 &&
+		test_path_is_file sub_file1 &&
 		! grep update file2 &&
 		git reset --hard p4/depot/branch3 &&
-		test -f file1 &&
-		test -f file2 &&
-		test -f file3 &&
-		test -f sub_file1 &&
+		test_path_is_file file1 &&
+		test_path_is_file file2 &&
+		test_path_is_file file3 &&
+		test_path_is_file sub_file1 &&
 		grep update file2 &&
 		cd "$cli" &&
 		cd branch1 &&
Signature · 1 line
2.17.1
#1 lore raw

Hi, Shubham. Welcome to the community!

Quoted 2 lines · Shubham Verma

Subject: [GSOC] [PATCH] replace test -f with test_path_is_file

It's common to prefix the patch title with "area: ", where "area" corresponds to the codebase section which the patch is modifying. This makes it easier to understand the scope of the change. You can check what others have been using for this specific file with git log --no-merges t/t9801-git-p4-branch.sh. In this case, I think a better alternative would be: "t9801: replace test -f with test_path_is_file"

Quoted 4 lines

Although test -f has the same functionality as test_path_is_file(), in the case where test_path_is_file() fails, we get much better debugging information.

Replace test -f with test_path_is_file() so that future developers will have a better experience debugging these test cases.

It's also a good practice to wrap the commit body in 72 columns. This will, for example, help viewing the message in most terminals. And, please, add your Signed-off-by[1] in the footer of the message.

[1]: https://github.com/git/git/blob/master/Documentation/SubmittingPatches#L299

Quoted 3 lines
---
 t/t9801-git-p4-branch.sh | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

As for the changes, LGTM :)