Merge branch 'ab/test-lib'
Test framework clean-up. * ab/test-lib: test-lib-functions: assert correct parameter count test-lib-functions: remove bug-inducing "diagnostics" helper param test libs: rename "diff-lib" to "lib-diff" t/.gitattributes: sort lines test-lib-functions: move function to lib-bitmap.sh test libs: rename gitweb-lib.sh to lib-gitweb.sh test libs: rename bundle helper to "lib-bundle.sh" test-lib-functions: remove generate_zero_bytes() wrapper test-lib-functions: move test_set_index_version() to its user test lib: change "error" to "BUG" as appropriate test-lib: remove check_var_migration
This commit is contained in:
@ -32,11 +32,6 @@ test_set_editor () {
|
||||
export EDITOR
|
||||
}
|
||||
|
||||
test_set_index_version () {
|
||||
GIT_INDEX_VERSION="$1"
|
||||
export GIT_INDEX_VERSION
|
||||
}
|
||||
|
||||
test_decode_color () {
|
||||
awk '
|
||||
function name(n) {
|
||||
@ -116,13 +111,6 @@ remove_cr () {
|
||||
tr '\015' Q | sed -e 's/Q$//'
|
||||
}
|
||||
|
||||
# Generate an output of $1 bytes of all zeroes (NULs, not ASCII zeroes).
|
||||
# If $1 is 'infinity', output forever or until the receiving pipe stops reading,
|
||||
# whichever comes first.
|
||||
generate_zero_bytes () {
|
||||
test-tool genzeros "$@"
|
||||
}
|
||||
|
||||
# In some bourne shell implementations, the "unset" builtin returns
|
||||
# nonzero status when a variable to be unset was not set in the first
|
||||
# place.
|
||||
@ -735,34 +723,37 @@ 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
|
||||
}
|
||||
|
||||
test_path_is_dir () {
|
||||
test "$#" -ne 1 && BUG "1 param"
|
||||
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
|
||||
}
|
||||
|
||||
# Check if the directory exists and is empty as expected, barf otherwise.
|
||||
test_dir_is_empty () {
|
||||
test "$#" -ne 1 && BUG "1 param"
|
||||
test_path_is_dir "$1" &&
|
||||
if test -n "$(ls -a1 "$1" | egrep -v '^\.\.?$')"
|
||||
then
|
||||
@ -774,6 +765,7 @@ test_dir_is_empty () {
|
||||
|
||||
# Check if the file exists and has a size greater than zero
|
||||
test_file_not_empty () {
|
||||
test "$#" = 2 && BUG "2 param"
|
||||
if ! test -s "$1"
|
||||
then
|
||||
echo "'$1' is not a non-empty file."
|
||||
@ -782,6 +774,7 @@ test_file_not_empty () {
|
||||
}
|
||||
|
||||
test_path_is_missing () {
|
||||
test "$#" -ne 1 && BUG "1 param"
|
||||
if test -e "$1"
|
||||
then
|
||||
echo "Path exists:"
|
||||
@ -818,6 +811,7 @@ test_line_count () {
|
||||
}
|
||||
|
||||
test_file_size () {
|
||||
test "$#" -ne 1 && BUG "1 param"
|
||||
test-tool path-utils file-size "$1"
|
||||
}
|
||||
|
||||
@ -990,6 +984,7 @@ test_expect_code () {
|
||||
# - not all diff versions understand "-u"
|
||||
|
||||
test_cmp () {
|
||||
test "$#" -ne 2 && BUG "2 param"
|
||||
eval "$GIT_TEST_CMP" '"$@"'
|
||||
}
|
||||
|
||||
@ -1019,6 +1014,7 @@ test_cmp_config () {
|
||||
# test_cmp_bin - helper to compare binary files
|
||||
|
||||
test_cmp_bin () {
|
||||
test "$#" -ne 2 && BUG "2 param"
|
||||
cmp "$@"
|
||||
}
|
||||
|
||||
@ -1079,6 +1075,7 @@ verbose () {
|
||||
# otherwise.
|
||||
|
||||
test_must_be_empty () {
|
||||
test "$#" -ne 1 && BUG "1 param"
|
||||
test_path_is_file "$1" &&
|
||||
if test -s "$1"
|
||||
then
|
||||
@ -1102,7 +1099,7 @@ test_cmp_rev () {
|
||||
fi
|
||||
if test $# != 2
|
||||
then
|
||||
error "bug in the test script: test_cmp_rev requires two revisions, but got $#"
|
||||
BUG "test_cmp_rev requires two revisions, but got $#"
|
||||
else
|
||||
local r1 r2
|
||||
r1=$(git rev-parse --verify "$1") &&
|
||||
@ -1213,7 +1210,7 @@ test_atexit () {
|
||||
# doing so on Bash is better than nothing (the test will
|
||||
# silently pass on other shells).
|
||||
test "${BASH_SUBSHELL-0}" = 0 ||
|
||||
error "bug in test script: test_atexit does nothing in a subshell"
|
||||
BUG "test_atexit does nothing in a subshell"
|
||||
test_atexit_cleanup="{ $*
|
||||
} && (exit \"\$eval_ret\"); eval_ret=\$?; $test_atexit_cleanup"
|
||||
}
|
||||
@ -1611,33 +1608,6 @@ test_set_port () {
|
||||
eval $var=$port
|
||||
}
|
||||
|
||||
# Compare a file containing rev-list bitmap traversal output to its non-bitmap
|
||||
# counterpart. You can't just use test_cmp for this, because the two produce
|
||||
# subtly different output:
|
||||
#
|
||||
# - regular output is in traversal order, whereas bitmap is split by type,
|
||||
# with non-packed objects at the end
|
||||
#
|
||||
# - regular output has a space and the pathname appended to non-commit
|
||||
# objects; bitmap output omits this
|
||||
#
|
||||
# This function normalizes and compares the two. The second file should
|
||||
# always be the bitmap output.
|
||||
test_bitmap_traversal () {
|
||||
if test "$1" = "--no-confirm-bitmaps"
|
||||
then
|
||||
shift
|
||||
elif cmp "$1" "$2"
|
||||
then
|
||||
echo >&2 "identical raw outputs; are you sure bitmaps were used?"
|
||||
return 1
|
||||
fi &&
|
||||
cut -d' ' -f1 "$1" | sort >"$1.normalized" &&
|
||||
sort "$2" >"$2.normalized" &&
|
||||
test_cmp "$1.normalized" "$2.normalized" &&
|
||||
rm -f "$1.normalized" "$2.normalized"
|
||||
}
|
||||
|
||||
# Tests for the hidden file attribute on Windows
|
||||
test_path_is_hidden () {
|
||||
test_have_prereq MINGW ||
|
||||
|
Reference in New Issue
Block a user