mirror of
https://github.com/git/git
synced 2024-08-25 02:35:46 +00:00
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:
commit
d68fccef86
4
t/.gitattributes
vendored
4
t/.gitattributes
vendored
|
@ -1,13 +1,13 @@
|
|||
t[0-9][0-9][0-9][0-9]/* -whitespace
|
||||
/chainlint/*.expect eol=lf
|
||||
/diff-lib/* eol=lf
|
||||
/lib-diff/* eol=lf
|
||||
/t0110/url-* binary
|
||||
/t3206/* eol=lf
|
||||
/t3900/*.txt eol=lf
|
||||
/t3901/*.txt eol=lf
|
||||
/t4034/*/* eol=lf
|
||||
/t4013/* eol=lf
|
||||
/t4018/* eol=lf
|
||||
/t4034/*/* eol=lf
|
||||
/t4051/* eol=lf
|
||||
/t4100/* eol=lf
|
||||
/t4101/* eol=lf
|
||||
|
|
8
t/README
8
t/README
|
@ -917,13 +917,13 @@ library for your script to use.
|
|||
|
||||
Check whether a file has the length it is expected to.
|
||||
|
||||
- test_path_is_file <path> [<diagnosis>]
|
||||
test_path_is_dir <path> [<diagnosis>]
|
||||
test_path_is_missing <path> [<diagnosis>]
|
||||
- test_path_is_file <path>
|
||||
test_path_is_dir <path>
|
||||
test_path_is_missing <path>
|
||||
|
||||
Check if the named path is a file, if the named path is a
|
||||
directory, or if the named path does not exist, respectively,
|
||||
and fail otherwise, showing the <diagnosis> text.
|
||||
and fail otherwise.
|
||||
|
||||
- test_when_finished <script>
|
||||
|
||||
|
|
26
t/lib-bitmap.sh
Normal file
26
t/lib-bitmap.sh
Normal file
|
@ -0,0 +1,26 @@
|
|||
# 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"
|
||||
}
|
|
@ -9,6 +9,11 @@ test_description='skip-worktree bit test'
|
|||
|
||||
sane_unset GIT_TEST_SPLIT_INDEX
|
||||
|
||||
test_set_index_version () {
|
||||
GIT_INDEX_VERSION="$1"
|
||||
export GIT_INDEX_VERSION
|
||||
}
|
||||
|
||||
test_set_index_version 3
|
||||
|
||||
cat >expect.full <<EOF
|
||||
|
|
|
@ -101,7 +101,8 @@ test_expect_success 'rebase -i with the exec command' '
|
|||
) &&
|
||||
test_path_is_file touch-one &&
|
||||
test_path_is_file touch-two &&
|
||||
test_path_is_missing touch-three " (should have stopped before)" &&
|
||||
# Missing because we should have stopped by now.
|
||||
test_path_is_missing touch-three &&
|
||||
test_cmp_rev C HEAD &&
|
||||
git rebase --continue &&
|
||||
test_path_is_file touch-three &&
|
||||
|
|
|
@ -7,7 +7,7 @@ test_description='Test built-in diff output engine.
|
|||
|
||||
'
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/diff-lib.sh
|
||||
. "$TEST_DIRECTORY"/lib-diff.sh
|
||||
|
||||
echo >path0 'Line 1
|
||||
Line 2
|
||||
|
|
|
@ -7,7 +7,7 @@ test_description='Test rename detection in diff engine.
|
|||
|
||||
'
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/diff-lib.sh
|
||||
. "$TEST_DIRECTORY"/lib-diff.sh
|
||||
|
||||
test_expect_success 'setup' '
|
||||
cat >path0 <<-\EOF &&
|
||||
|
|
|
@ -7,11 +7,11 @@ test_description='More rename detection
|
|||
|
||||
'
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
|
||||
. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash
|
||||
|
||||
test_expect_success \
|
||||
'prepare reference tree' \
|
||||
'cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
|
||||
'cat "$TEST_DIRECTORY"/lib-diff/COPYING >COPYING &&
|
||||
echo frotz >rezrov &&
|
||||
git update-index --add COPYING rezrov &&
|
||||
tree=$(git write-tree) &&
|
||||
|
@ -99,7 +99,7 @@ test_expect_success \
|
|||
|
||||
test_expect_success \
|
||||
'prepare work tree once again' \
|
||||
'cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
|
||||
'cat "$TEST_DIRECTORY"/lib-diff/COPYING >COPYING &&
|
||||
git update-index --add --remove COPYING COPYING.1'
|
||||
|
||||
# tree has COPYING and rezrov. work tree has COPYING and COPYING.1,
|
||||
|
|
|
@ -10,7 +10,7 @@ copy of symbolic links, but should not produce rename/copy followed
|
|||
by an edit for them.
|
||||
'
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/diff-lib.sh
|
||||
. "$TEST_DIRECTORY"/lib-diff.sh
|
||||
|
||||
test_expect_success SYMLINKS \
|
||||
'prepare reference tree' \
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
test_description='Same rename detection as t4003 but testing diff-raw.'
|
||||
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
|
||||
. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash
|
||||
|
||||
test_expect_success 'setup reference tree' '
|
||||
cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
|
||||
cat "$TEST_DIRECTORY"/lib-diff/COPYING >COPYING &&
|
||||
echo frotz >rezrov &&
|
||||
git update-index --add COPYING rezrov &&
|
||||
tree=$(git write-tree) &&
|
||||
|
@ -64,7 +64,7 @@ test_expect_success 'validate output from rename/copy detection (#2)' '
|
|||
# nows how to say Copy.
|
||||
|
||||
test_expect_success 'validate output from rename/copy detection (#3)' '
|
||||
cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
|
||||
cat "$TEST_DIRECTORY"/lib-diff/COPYING >COPYING &&
|
||||
git update-index --add --remove COPYING COPYING.1 &&
|
||||
|
||||
cat <<-EOF >expected &&
|
||||
|
|
|
@ -7,17 +7,17 @@ test_description='Rename interaction with pathspec.
|
|||
|
||||
'
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
|
||||
. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash
|
||||
|
||||
test_expect_success 'prepare reference tree' '
|
||||
mkdir path0 path1 &&
|
||||
cp "$TEST_DIRECTORY"/diff-lib/COPYING path0/COPYING &&
|
||||
cp "$TEST_DIRECTORY"/lib-diff/COPYING path0/COPYING &&
|
||||
git update-index --add path0/COPYING &&
|
||||
tree=$(git write-tree) &&
|
||||
echo $tree
|
||||
'
|
||||
|
||||
blob=$(git hash-object "$TEST_DIRECTORY/diff-lib/COPYING")
|
||||
blob=$(git hash-object "$TEST_DIRECTORY/lib-diff/COPYING")
|
||||
test_expect_success 'prepare work tree' '
|
||||
cp path0/COPYING path1/COPYING &&
|
||||
git update-index --add --remove path0/COPYING path1/COPYING
|
||||
|
|
|
@ -22,11 +22,11 @@ With -B, this should be detected as two complete rewrites.
|
|||
Further, with -B and -M together, these should turn into two renames.
|
||||
'
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
|
||||
. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash
|
||||
|
||||
test_expect_success setup '
|
||||
cat "$TEST_DIRECTORY"/diff-lib/README >file0 &&
|
||||
cat "$TEST_DIRECTORY"/diff-lib/COPYING >file1 &&
|
||||
cat "$TEST_DIRECTORY"/lib-diff/README >file0 &&
|
||||
cat "$TEST_DIRECTORY"/lib-diff/COPYING >file1 &&
|
||||
blob0_id=$(git hash-object file0) &&
|
||||
blob1_id=$(git hash-object file1) &&
|
||||
git update-index --add file0 file1 &&
|
||||
|
|
|
@ -7,11 +7,11 @@ test_description='Same rename detection as t4003 but testing diff-raw -z.
|
|||
|
||||
'
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
|
||||
. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash
|
||||
|
||||
test_expect_success \
|
||||
'prepare reference tree' \
|
||||
'cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
|
||||
'cat "$TEST_DIRECTORY"/lib-diff/COPYING >COPYING &&
|
||||
echo frotz >rezrov &&
|
||||
git update-index --add COPYING rezrov &&
|
||||
orig=$(git hash-object COPYING) &&
|
||||
|
@ -81,7 +81,7 @@ test_expect_success \
|
|||
|
||||
test_expect_success \
|
||||
'prepare work tree once again' \
|
||||
'cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
|
||||
'cat "$TEST_DIRECTORY"/lib-diff/COPYING >COPYING &&
|
||||
git update-index --add --remove COPYING COPYING.1'
|
||||
|
||||
git diff-index -z -C --find-copies-harder $tree >current
|
||||
|
|
|
@ -10,7 +10,7 @@ Prepare:
|
|||
path1/file1
|
||||
'
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
|
||||
. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash
|
||||
|
||||
test_expect_success \
|
||||
setup \
|
||||
|
|
|
@ -7,7 +7,7 @@ test_description='Test diff of symlinks.
|
|||
|
||||
'
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/diff-lib.sh
|
||||
. "$TEST_DIRECTORY"/lib-diff.sh
|
||||
|
||||
# Print the short OID of a symlink with the given name.
|
||||
symlink_oid () {
|
||||
|
|
|
@ -9,7 +9,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
|
|||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/diff-lib.sh
|
||||
. "$TEST_DIRECTORY"/lib-diff.sh
|
||||
|
||||
test_expect_success setup '
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ test_description='Test special whitespace in diff engine.
|
|||
|
||||
'
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/diff-lib.sh
|
||||
. "$TEST_DIRECTORY"/lib-diff.sh
|
||||
|
||||
test_expect_success "Ray Lehtiniemi's example" '
|
||||
cat <<-\EOF >x &&
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
test_description='difference in submodules'
|
||||
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/diff-lib.sh
|
||||
. "$TEST_DIRECTORY"/lib-diff.sh
|
||||
|
||||
test_expect_success setup '
|
||||
test_tick &&
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
test_description='word diff colors'
|
||||
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/diff-lib.sh
|
||||
. "$TEST_DIRECTORY"/lib-diff.sh
|
||||
|
||||
cat >pre.simple <<-\EOF
|
||||
h(4)
|
||||
|
|
|
@ -6,7 +6,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
|||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/diff-lib.sh
|
||||
. "$TEST_DIRECTORY"/lib-diff.sh
|
||||
|
||||
setup_helper () {
|
||||
one=$1 branch=$2 side=$3 &&
|
||||
|
|
|
@ -7,7 +7,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
|||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/diff-lib.sh
|
||||
. "$TEST_DIRECTORY"/lib-diff.sh
|
||||
|
||||
# Compare two diff outputs. Ignore "index" lines, because we don't
|
||||
# care about SHA-1s or file modes.
|
||||
|
|
|
@ -7,7 +7,7 @@ test_description='Test --follow should always find copies hard in git log.
|
|||
|
||||
'
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/diff-lib.sh
|
||||
. "$TEST_DIRECTORY"/lib-diff.sh
|
||||
|
||||
echo >path0 'Line 1
|
||||
Line 2
|
||||
|
|
|
@ -5,6 +5,8 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
|
|||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/lib-bundle.sh
|
||||
. "$TEST_DIRECTORY"/lib-bitmap.sh
|
||||
|
||||
objpath () {
|
||||
echo ".git/objects/$(echo "$1" | sed -e 's|\(..\)|\1/|')"
|
||||
|
|
|
@ -551,7 +551,7 @@ corrupt_graph_and_verify() {
|
|||
zero_pos=${4:-${orig_size}} &&
|
||||
printf "$data" | dd of="$objdir/info/commit-graph" bs=1 seek="$pos" conv=notrunc &&
|
||||
dd of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" if=/dev/null &&
|
||||
generate_zero_bytes $(($orig_size - $zero_pos)) >>"$objdir/info/commit-graph" &&
|
||||
test-tool genzeros $(($orig_size - $zero_pos)) >>"$objdir/info/commit-graph" &&
|
||||
corrupt_graph_verify "$grepstr"
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
|||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/test-bundle-functions.sh
|
||||
. "$TEST_DIRECTORY"/lib-bundle.sh
|
||||
|
||||
D=$(pwd)
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
|||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/test-bundle-functions.sh
|
||||
. "$TEST_DIRECTORY"/lib-bundle.sh
|
||||
|
||||
# Create a commit or tag and set the variable with the object ID.
|
||||
test_commit_setvar () {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
test_description='rev-list combining bitmaps and filters'
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/lib-bitmap.sh
|
||||
|
||||
test_expect_success 'set up bitmapped repo' '
|
||||
# one commit will have bitmaps, the other will not
|
||||
|
|
|
@ -492,7 +492,9 @@ test_expect_success '3a-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
|
|||
test_cmp expect actual &&
|
||||
|
||||
test_must_fail git rev-parse HEAD:bq HEAD:foo/bq &&
|
||||
test_path_is_missing bq foo/bq foo/whatever
|
||||
test_path_is_missing bq &&
|
||||
test_path_is_missing foo/bq &&
|
||||
test_path_is_missing foo/whatever
|
||||
)
|
||||
'
|
||||
|
||||
|
@ -522,7 +524,9 @@ test_expect_success '3a-R: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
|
|||
test_cmp expect actual &&
|
||||
|
||||
test_must_fail git rev-parse HEAD:bq HEAD:foo/bq &&
|
||||
test_path_is_missing bq foo/bq foo/whatever
|
||||
test_path_is_missing bq &&
|
||||
test_path_is_missing foo/bq &&
|
||||
test_path_is_missing foo/whatever
|
||||
)
|
||||
'
|
||||
|
||||
|
@ -588,7 +592,9 @@ test_expect_success '3b-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
|
|||
test_cmp expect actual &&
|
||||
|
||||
test_must_fail git rev-parse HEAD:bq HEAD:foo/bq &&
|
||||
test_path_is_missing bq foo/bq foo/whatever
|
||||
test_path_is_missing bq &&
|
||||
test_path_is_missing foo/bq &&
|
||||
test_path_is_missing foo/whatever
|
||||
)
|
||||
'
|
||||
|
||||
|
@ -618,7 +624,9 @@ test_expect_success '3b-R: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
|
|||
test_cmp expect actual &&
|
||||
|
||||
test_must_fail git rev-parse HEAD:bq HEAD:foo/bq &&
|
||||
test_path_is_missing bq foo/bq foo/whatever
|
||||
test_path_is_missing bq &&
|
||||
test_path_is_missing foo/bq &&
|
||||
test_path_is_missing foo/whatever
|
||||
)
|
||||
'
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ test_expect_success 'gc --keep-largest-pack' '
|
|||
git gc &&
|
||||
( cd .git/objects/pack && ls *.pack ) >pack-list &&
|
||||
test_line_count = 1 pack-list &&
|
||||
BASE_PACK=.git/objects/pack/pack-*.pack &&
|
||||
cp pack-list base-pack-list &&
|
||||
test_commit four &&
|
||||
git repack -d &&
|
||||
test_commit five &&
|
||||
|
@ -90,7 +90,7 @@ test_expect_success 'gc --keep-largest-pack' '
|
|||
test_line_count = 2 pack-list &&
|
||||
awk "/^P /{print \$2}" <.git/objects/info/packs >pack-info &&
|
||||
test_line_count = 2 pack-info &&
|
||||
test_path_is_file $BASE_PACK &&
|
||||
test_path_is_file .git/objects/pack/$(cat base-pack-list) &&
|
||||
git fsck
|
||||
)
|
||||
'
|
||||
|
|
|
@ -11,7 +11,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
|||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY/diff-lib.sh"
|
||||
. "$TEST_DIRECTORY/lib-diff.sh"
|
||||
|
||||
author='The Real Author <someguy@his.email.org>'
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
|||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
. ./test-lib.sh
|
||||
. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
|
||||
. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash
|
||||
|
||||
verify_packs () {
|
||||
for p in .git/objects/pack/*.pack
|
||||
|
|
|
@ -13,7 +13,7 @@ or warnings to log.'
|
|||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
||||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
. ./gitweb-lib.sh
|
||||
. ./lib-gitweb.sh
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# no commits (empty, just initialized repository)
|
||||
|
|
|
@ -13,7 +13,7 @@ code and message.'
|
|||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
||||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
. ./gitweb-lib.sh
|
||||
. ./lib-gitweb.sh
|
||||
|
||||
#
|
||||
# Gitweb only provides the functionality tested by the 'modification times'
|
||||
|
|
|
@ -13,7 +13,7 @@ in the HTTP header or the actual script output.'
|
|||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
||||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||
|
||||
. ./gitweb-lib.sh
|
||||
. ./lib-gitweb.sh
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# snapshot file name and prefix
|
||||
|
|
|
@ -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 ||
|
||||
|
|
|
@ -453,36 +453,6 @@ export GIT_DEFAULT_HASH
|
|||
GIT_TRACE_BARE=1
|
||||
export GIT_TRACE_BARE
|
||||
|
||||
check_var_migration () {
|
||||
# the warnings and hints given from this helper depends
|
||||
# on end-user settings, which will disrupt the self-test
|
||||
# done on the test framework itself.
|
||||
case "$GIT_TEST_FRAMEWORK_SELFTEST" in
|
||||
t) return ;;
|
||||
esac
|
||||
|
||||
old_name=$1 new_name=$2
|
||||
eval "old_isset=\${${old_name}:+isset}"
|
||||
eval "new_isset=\${${new_name}:+isset}"
|
||||
|
||||
case "$old_isset,$new_isset" in
|
||||
isset,)
|
||||
echo >&2 "warning: $old_name is now $new_name"
|
||||
echo >&2 "hint: set $new_name too during the transition period"
|
||||
eval "$new_name=\$$old_name"
|
||||
;;
|
||||
isset,isset)
|
||||
# do this later
|
||||
# echo >&2 "warning: $old_name is now $new_name"
|
||||
# echo >&2 "hint: remove $old_name"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
check_var_migration GIT_FSMONITOR_TEST GIT_TEST_FSMONITOR
|
||||
check_var_migration TEST_GIT_INDEX_VERSION GIT_TEST_INDEX_VERSION
|
||||
check_var_migration GIT_FORCE_PRELOAD_TEST GIT_TEST_PRELOAD_INDEX
|
||||
|
||||
# Use specific version of the index file format
|
||||
if test -n "${GIT_TEST_INDEX_VERSION:+isset}"
|
||||
then
|
||||
|
|
Loading…
Reference in a new issue