Browse Source

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
maint
Junio C Hamano 4 years ago
parent
commit
d68fccef86
  1. 4
      t/.gitattributes
  2. 8
      t/README
  3. 26
      t/lib-bitmap.sh
  4. 0
      t/lib-bundle.sh
  5. 0
      t/lib-diff.sh
  6. 0
      t/lib-diff/COPYING
  7. 0
      t/lib-diff/README
  8. 0
      t/lib-gitweb.sh
  9. 5
      t/t2104-update-index-skip-worktree.sh
  10. 3
      t/t3404-rebase-interactive.sh
  11. 2
      t/t4000-diff-format.sh
  12. 2
      t/t4001-diff-rename.sh
  13. 6
      t/t4003-diff-rename-1.sh
  14. 2
      t/t4004-diff-rename-symlink.sh
  15. 6
      t/t4005-diff-rename-2.sh
  16. 6
      t/t4007-rename-3.sh
  17. 6
      t/t4008-diff-break-rewrite.sh
  18. 6
      t/t4009-diff-rename-4.sh
  19. 2
      t/t4010-diff-pathspec.sh
  20. 2
      t/t4011-diff-symlink.sh
  21. 2
      t/t4013-diff-various.sh
  22. 2
      t/t4015-diff-whitespace.sh
  23. 2
      t/t4027-diff-submodule.sh
  24. 2
      t/t4034-diff-words.sh
  25. 2
      t/t4038-diff-combined.sh
  26. 2
      t/t4061-diff-indent.sh
  27. 2
      t/t4206-log-follow-harder-copies.sh
  28. 2
      t/t5310-pack-bitmaps.sh
  29. 2
      t/t5318-commit-graph.sh
  30. 2
      t/t5510-fetch.sh
  31. 2
      t/t6020-bundle-misc.sh
  32. 1
      t/t6113-rev-list-bitmap-filters.sh
  33. 16
      t/t6426-merge-skip-unneeded-updates.sh
  34. 4
      t/t6500-gc.sh
  35. 2
      t/t7501-commit-basic-functionality.sh
  36. 2
      t/t9300-fast-import.sh
  37. 2
      t/t9500-gitweb-standalone-no-errors.sh
  38. 2
      t/t9501-gitweb-standalone-http-status.sh
  39. 2
      t/t9502-gitweb-standalone-parse-output.sh
  40. 62
      t/test-lib-functions.sh
  41. 30
      t/test-lib.sh

4
t/.gitattributes vendored

@ -1,13 +1,13 @@ @@ -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

@ -917,13 +917,13 @@ library for your script to use. @@ -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

@ -0,0 +1,26 @@ @@ -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"
}

0
t/test-bundle-functions.sh → t/lib-bundle.sh

0
t/diff-lib.sh → t/lib-diff.sh

0
t/diff-lib/COPYING → t/lib-diff/COPYING

0
t/diff-lib/README → t/lib-diff/README

0
t/gitweb-lib.sh → t/lib-gitweb.sh

5
t/t2104-update-index-skip-worktree.sh

@ -9,6 +9,11 @@ test_description='skip-worktree bit test' @@ -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

3
t/t3404-rebase-interactive.sh

@ -101,7 +101,8 @@ test_expect_success 'rebase -i with the exec command' ' @@ -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 &&

2
t/t4000-diff-format.sh

@ -7,7 +7,7 @@ test_description='Test built-in diff output engine. @@ -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

2
t/t4001-diff-rename.sh

@ -7,7 +7,7 @@ test_description='Test rename detection in diff engine. @@ -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 &&

6
t/t4003-diff-rename-1.sh

@ -7,11 +7,11 @@ test_description='More rename detection @@ -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 \ @@ -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,

2
t/t4004-diff-rename-symlink.sh

@ -10,7 +10,7 @@ copy of symbolic links, but should not produce rename/copy followed @@ -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
t/t4005-diff-rename-2.sh

@ -6,10 +6,10 @@ @@ -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)' ' @@ -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 &&

6
t/t4007-rename-3.sh

@ -7,17 +7,17 @@ test_description='Rename interaction with pathspec. @@ -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

6
t/t4008-diff-break-rewrite.sh

@ -22,11 +22,11 @@ With -B, this should be detected as two complete rewrites. @@ -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 &&

6
t/t4009-diff-rename-4.sh

@ -7,11 +7,11 @@ test_description='Same rename detection as t4003 but testing diff-raw -z. @@ -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 \ @@ -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

2
t/t4010-diff-pathspec.sh

@ -10,7 +10,7 @@ Prepare: @@ -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 \

2
t/t4011-diff-symlink.sh

@ -7,7 +7,7 @@ test_description='Test diff of symlinks. @@ -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 () {

2
t/t4013-diff-various.sh

@ -9,7 +9,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master @@ -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 '


2
t/t4015-diff-whitespace.sh

@ -7,7 +7,7 @@ test_description='Test special whitespace in diff engine. @@ -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 &&

2
t/t4027-diff-submodule.sh

@ -3,7 +3,7 @@ @@ -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 &&

2
t/t4034-diff-words.sh

@ -3,7 +3,7 @@ @@ -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)

2
t/t4038-diff-combined.sh

@ -6,7 +6,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main @@ -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 &&

2
t/t4061-diff-indent.sh

@ -7,7 +7,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main @@ -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.

2
t/t4206-log-follow-harder-copies.sh

@ -7,7 +7,7 @@ test_description='Test --follow should always find copies hard in git log. @@ -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

2
t/t5310-pack-bitmaps.sh

@ -5,6 +5,8 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master @@ -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/|')"

2
t/t5318-commit-graph.sh

@ -551,7 +551,7 @@ corrupt_graph_and_verify() { @@ -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"

}

2
t/t5510-fetch.sh

@ -9,7 +9,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main @@ -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)


2
t/t6020-bundle-misc.sh

@ -9,7 +9,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main @@ -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 () {

1
t/t6113-rev-list-bitmap-filters.sh

@ -2,6 +2,7 @@ @@ -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

16
t/t6426-merge-skip-unneeded-updates.sh

@ -492,7 +492,9 @@ test_expect_success '3a-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' ' @@ -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' ' @@ -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' ' @@ -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' ' @@ -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
)
'


4
t/t6500-gc.sh

@ -78,7 +78,7 @@ test_expect_success 'gc --keep-largest-pack' ' @@ -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' ' @@ -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
)
'

2
t/t7501-commit-basic-functionality.sh

@ -11,7 +11,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main @@ -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>'


2
t/t9300-fast-import.sh

@ -8,7 +8,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main @@ -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

2
t/t9500-gitweb-standalone-no-errors.sh

@ -13,7 +13,7 @@ or warnings to log.' @@ -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)

2
t/t9501-gitweb-standalone-http-status.sh

@ -13,7 +13,7 @@ code and message.' @@ -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'

2
t/t9502-gitweb-standalone-parse-output.sh

@ -13,7 +13,7 @@ in the HTTP header or the actual script output.' @@ -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

62
t/test-lib-functions.sh

@ -32,11 +32,6 @@ test_set_editor () { @@ -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 () { @@ -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 () { @@ -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 () { @@ -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 () { @@ -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 () { @@ -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 () { @@ -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 () { @@ -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 () { @@ -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 () { @@ -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 () { @@ -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 () { @@ -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 ||

30
t/test-lib.sh

@ -453,36 +453,6 @@ export GIT_DEFAULT_HASH @@ -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…
Cancel
Save