test-lib-functions: remove bug-inducing "diagnostics" helper param
Remove the optional "diagnostics" parameter of the test_path_is_{file,dir,missing} functions. We have a lot of uses of these functions, but the only legitimate use of the diagnostics parameter is from when the functions themselves were introduced in2caf20c52b
(test-lib: user-friendly alternatives to test [-d|-f|-e], 2010-08-10). But as the the rest of this diff demonstrates its presence did more to silently introduce bugs in our tests. Fix such bugs in the tests added inae4e89e549
(gc: add --keep-largest-pack option, 2018-04-15), andc04ba51739
(t6046: testcases checking whether updates can be skipped in a merge, 2018-04-19). Let's also assert that those functions are called with exactly one parameter, a follow-up commit will add similar asserts to other functions in test-lib-functions.sh that we didn't have existing misuse of. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
ebd73f50c6
commit
45a2686441
@ -717,12 +717,12 @@ test_external_without_stderr () {
|
||||
}
|
||||
|
||||
# debugging-friendly alternatives to "test [-f|-d|-e]"
|
||||
# The commands test the existence or non-existence of $1. $2 can be
|
||||
# given to provide a more precise diagnosis.
|
||||
# The commands test the existence or non-existence of $1
|
||||
test_path_is_file () {
|
||||
test "$#" -ne 1 && BUG "1 param"
|
||||
if ! test -f "$1"
|
||||
then
|
||||
echo "File $1 doesn't exist. $2"
|
||||
echo "File $1 doesn't exist"
|
||||
false
|
||||
fi
|
||||
}
|
||||
@ -730,15 +730,16 @@ test_path_is_file () {
|
||||
test_path_is_dir () {
|
||||
if ! test -d "$1"
|
||||
then
|
||||
echo "Directory $1 doesn't exist. $2"
|
||||
echo "Directory $1 doesn't exist"
|
||||
false
|
||||
fi
|
||||
}
|
||||
|
||||
test_path_exists () {
|
||||
test "$#" -ne 1 && BUG "1 param"
|
||||
if ! test -e "$1"
|
||||
then
|
||||
echo "Path $1 doesn't exist. $2"
|
||||
echo "Path $1 doesn't exist"
|
||||
false
|
||||
fi
|
||||
}
|
||||
|
Reference in New Issue
Block a user