[PATCH v2 0/3] test-lib-functions.sh: trickery to make -x less verbose
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Apr 20, 2021, 12:29 UTC
- Message-ID
- <cover-0.3-0000000000-20210420T122706Z-avarab@gmail.com>
- In-Reply-To
- <cover-00.16-00000000000-20210412T110456Z-avarab@gmail.com>
This series makes the "-x" output less verbose for our various helper functions, mainly using the trickery of feeding "$@" to "test" to rely on it to die when given too many arguments.
Since v1 the only change is adding a comment as suggested by Eric Sunshine, it's not ideal as noted in <87pmyp2led.fsf@evledraar.gmail.com> (I wish these were just in one file, so we could have a comment at the top), but will aid future maintenance anyway.
Ævar Arnfjörð Bjarmason (3): test-lib-functions: normalize test_path_is_missing() debugging Revert and amend "test-lib-functions: assert correct parameter count" test-lib-functions: remove last two parameter count assertions
t/test-lib-functions.sh | 72 +++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 42 deletions(-)
Range-diff against v1:
1: a3e20ef18f < -: ---------- test-lib: split up and deprecate test_create_repo()
2: c22e3f7764 = 1: fd33f6d71f test-lib-functions: normalize test_path_is_missing() debugging
3: 6f9e09a201 ! 2: 67ddd821df Revert and amend "test-lib-functions: assert correct parameter count"
@@ Commit message
## t/test-lib-functions.sh ##
@@ t/test-lib-functions.sh: test_external_without_stderr () {
+ }
+
# debugging-friendly alternatives to "test [-f|-d|-e]"
- # The commands test the existence or non-existence of $1
+-# The commands test the existence or non-existence of $1
++# The commands test the existence or non-existence of
++# a given argument.
++#
++# The pattern of using "$@" to "test" instead of "$1" is not a bug. We
++# are counting on "test" to error on too many arguments if more than
++# one is given. Checking "$#" explicitly would lead to overly verbose
++# -x output.
test_path_is_file () {
- test "$#" -ne 1 && BUG "1 param"
- if ! test -f "$1"
4: b7b11a60bc = 3: 8fd51861b5 test-lib-functions: remove last two parameter count assertions-- 2.31.1.723.gf6bad1b9ba1