Skip to content

Commit 5f612a9

Browse files
committed
t2000: modernize path checks to use helper functions
Replace bare 'test -f/-d' and 'test ! -h ... && test -f/-d' assertions with their dedicated test_path_is_* helpers: - 'test -f path0 && test -d path1 && test -f path1/file1' becomes individual test_path_is_file/test_path_is_dir calls. - 'test ! -h <path> && test -d/-f <path>' patterns become test_path_is_dir_not_symlink/test_path_is_file_not_symlink calls. These helpers produce clearer diagnostic output on failure (e.g. 'File path0 doesn't exist') rather than a bare exit code, making test failures easier to debug. Found via: git grep 'test -[efd]' t/ CC: Christian Couder <christian.couder@gmail.com> CC: Karthik Nayak <karthik.188@gmail.com> CC: Justin Tobler <jltobler@gmail.com> CC: Siddharth Asthana <siddharthasthana31@gmail.com> CC: Ayush Chandekar <ayu.chandekar@gmail.com> Signed-off-by: alibaba0010 <zakariyahali100@gmail.com>
1 parent 41688c1 commit 5f612a9

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

t/t2000-conflict-when-checking-files-out.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ test_expect_success \
5858

5959
test_expect_success \
6060
'git checkout-index conflicting paths.' \
61-
'test -f path0 && test -d path1 && test -f path1/file1'
61+
'test_path_is_file path0 &&
62+
test_path_is_dir path1 &&
63+
test_path_is_file path1/file1'
6264

6365
test_expect_success SYMLINKS 'checkout-index -f twice with --prefix' '
6466
mkdir -p tar/get &&
@@ -127,9 +129,9 @@ test_debug 'show_files $tree2'
127129

128130
test_expect_success \
129131
'checking out conflicting path with -f' \
130-
'test ! -h path2 && test -d path2 &&
131-
test ! -h path3 && test -d path3 &&
132-
test ! -h path2/file0 && test -f path2/file0 &&
133-
test ! -h path3/file1 && test -f path3/file1'
132+
'test_path_is_dir_not_symlink path2 &&
133+
test_path_is_dir_not_symlink path3 &&
134+
test_path_is_file_not_symlink path2/file0 &&
135+
test_path_is_file_not_symlink path3/file1'
134136

135137
test_done

0 commit comments

Comments
 (0)