Skip to content

Commit 77af53f

Browse files
devdekunlegitster
authored andcommitted
t7300-clean.sh: use test_path_* helper functions for error logging
This test script uses "test - [def]", but when a test fails because the file passed to it does not exist, it fails silently without an error message. Use test_path_* helper functions, which are designed to give better error messages when their expectations are not met. I have added a mechanical validation that applies the same transformation done in this patch, when the test script is passed to a sed script as shown below. sed -e 's/^\( *\)test -f /\1test_path_is_file /' \ -e 's/^\( *\)test -d /\1test_path_is_dir /' \ -e 's/^\( *\)test -e /\1test_path_exists /' \ -e 's/^\( *\)! test -[edf] /\1test_path_is_missing /' \ -e 's/^\( *\)test ! -[edf] /\1test_path_is_missing /' \ "$1" >foo.sh Reviewers can use the sed script to tranform the original test script and compare the result in foo.sh with the results of applying the patch. You will see an instance of "!(test -e 3)" which was manually replaced with ""test_path_is_missing 3", and everything else should match. Careful and deliberate observation was done to check instances where "test ! - [df] foo" was used in the test script to make sure that the test instances were expecting foo to EITHER be a file or a directory, and NOT a possibility of being both as this would make replacing "test ! -f foo" with "test_path_is_missing foo" unreasonable. In the tests control flow, foo has been created as EITHER a reguar file OR a directory and should NOT exist after "git clean" or "git clean -d", as the case maybe, has been called. This made it reasonable to replace "test ! -[df] foo" with "test_path_is_missing foo". Signed-off-by: Abraham Samuel Adekunle <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 777489f commit 77af53f

File tree

1 file changed

+185
-185
lines changed

1 file changed

+185
-185
lines changed

0 commit comments

Comments
 (0)