]> git.ipfire.org Git - thirdparty/git.git/commit
t7300-clean.sh: use test_path_* helper functions for error logging
authorAbraham Samuel Adekunle <abrahamadekunle50@gmail.com>
Wed, 9 Oct 2024 18:22:02 +0000 (18:22 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 9 Oct 2024 22:04:39 +0000 (15:04 -0700)
commit77af53f56f100b49fdcf294f687b36064d16feca
tree0bd325885a2fc0aee89261b9619246e21304fcdc
parent777489f9e09c8d0dd6b12f9d90de6376330577a2
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 <abrahamadekunle50@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7300-clean.sh