t1006: split test utility functions into new 'lib-cat-file.sh'
This refactor extracts utility functions from the cat-file's test script 't1006-cat-file.sh' into a new 'lib-cat-file.sh' dedicated library file. A subsequent commit will need this functions, the goal is to improve code reuse and readability,enabling future tests to leverage these utilities without duplicating code. Signed-off-by: Pablo Sabater <pabloosabaterr@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>next
parent
3f565f7c9f
commit
84cef6dfa0
|
|
@ -0,0 +1,16 @@
|
|||
# Library of git-cat-file related test functions.
|
||||
|
||||
# Print a string without a trailing newline.
|
||||
echo_without_newline () {
|
||||
printf '%s' "$*"
|
||||
}
|
||||
|
||||
# Print a string without newlines and replace them with a NULL character (\0).
|
||||
echo_without_newline_nul () {
|
||||
echo_without_newline "$@" | tr '\n' '\0'
|
||||
}
|
||||
|
||||
# Calculate the length of a string.
|
||||
strlen () {
|
||||
echo_without_newline "$1" | wc -c | sed -e 's/^ *//'
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ test_description='git cat-file'
|
|||
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY/lib-loose.sh"
|
||||
. "$TEST_DIRECTORY"/lib-cat-file.sh
|
||||
|
||||
test_cmdmode_usage () {
|
||||
test_expect_code 129 "$@" 2>err &&
|
||||
|
|
@ -99,18 +100,6 @@ do
|
|||
'
|
||||
done
|
||||
|
||||
echo_without_newline () {
|
||||
printf '%s' "$*"
|
||||
}
|
||||
|
||||
echo_without_newline_nul () {
|
||||
echo_without_newline "$@" | tr '\n' '\0'
|
||||
}
|
||||
|
||||
strlen () {
|
||||
echo_without_newline "$1" | wc -c | sed -e 's/^ *//'
|
||||
}
|
||||
|
||||
run_tests () {
|
||||
type=$1
|
||||
object_name="$2"
|
||||
|
|
|
|||
Loading…
Reference in New Issue