X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=t%2Ftest-lib-functions.sh;h=109d1b548ce4ed4798e332fa31ddc404e1b49fc0;hb=45a2686441b0ea53ad9acef8b01dad2efdd98a90;hp=2f08ce7cba57ae59770cf56b06dfed9ffc72253e;hpb=d9e1cd555d828135e514f34cb9a942f76ceb234a;p=thirdparty%2Fgit.git diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 2f08ce7cba..109d1b548c 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -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. @@ -178,19 +166,28 @@ debug () { GIT_DEBUGGER="${GIT_DEBUGGER}" "$@" <&6 >&5 2>&7 } -# Call test_commit with the arguments -# [-C ] [ [ []]]" +# Usage: test_commit [options] [ [ []]] +# -C : +# Run all git commands in directory +# --notick +# Do not call test_tick before making a commit +# --append +# Use "echo >>" instead of "echo >" when writing "" to +# "" +# --signoff +# Invoke "git commit" with --signoff +# --author +# Invoke "git commit" with --author # # This will commit a file with the given contents and the given commit # message, and tag the resulting commit with the given tag name. # # , , and all default to . -# -# If the first argument is "-C", the second argument is used as a path for -# the git invocations. test_commit () { notick= && + append= && + author= && signoff= && indir= && while test $# != 0 @@ -199,6 +196,13 @@ test_commit () { --notick) notick=yes ;; + --append) + append=yes + ;; + --author) + author="$2" + shift + ;; --signoff) signoff="$1" ;; @@ -214,13 +218,20 @@ test_commit () { done && indir=${indir:+"$indir"/} && file=${2:-"$1.t"} && - echo "${3-$1}" > "$indir$file" && + if test -n "$append" + then + echo "${3-$1}" >>"$indir$file" + else + echo "${3-$1}" >"$indir$file" + fi && git ${indir:+ -C "$indir"} add "$file" && if test -z "$notick" then test_tick fi && - git ${indir:+ -C "$indir"} commit $signoff -m "$1" && + git ${indir:+ -C "$indir"} commit \ + ${author:+ --author "$author"} \ + $signoff -m "$1" && git ${indir:+ -C "$indir"} tag "${4:-$1}" } @@ -706,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 } @@ -719,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 } @@ -1082,7 +1094,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") && @@ -1193,7 +1205,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" } @@ -1591,33 +1603,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 ||