Skip to content

Commit d68fcce

Browse files
committed
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
2 parents 45df6c4 + e7884b3 commit d68fcce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+107
-124
lines changed

t/.gitattributes

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
t[0-9][0-9][0-9][0-9]/* -whitespace
22
/chainlint/*.expect eol=lf
3-
/diff-lib/* eol=lf
3+
/lib-diff/* eol=lf
44
/t0110/url-* binary
55
/t3206/* eol=lf
66
/t3900/*.txt eol=lf
77
/t3901/*.txt eol=lf
8-
/t4034/*/* eol=lf
98
/t4013/* eol=lf
109
/t4018/* eol=lf
10+
/t4034/*/* eol=lf
1111
/t4051/* eol=lf
1212
/t4100/* eol=lf
1313
/t4101/* eol=lf

t/README

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -917,13 +917,13 @@ library for your script to use.
917917

918918
Check whether a file has the length it is expected to.
919919

920-
- test_path_is_file <path> [<diagnosis>]
921-
test_path_is_dir <path> [<diagnosis>]
922-
test_path_is_missing <path> [<diagnosis>]
920+
- test_path_is_file <path>
921+
test_path_is_dir <path>
922+
test_path_is_missing <path>
923923

924924
Check if the named path is a file, if the named path is a
925925
directory, or if the named path does not exist, respectively,
926-
and fail otherwise, showing the <diagnosis> text.
926+
and fail otherwise.
927927

928928
- test_when_finished <script>
929929

t/lib-bitmap.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Compare a file containing rev-list bitmap traversal output to its non-bitmap
2+
# counterpart. You can't just use test_cmp for this, because the two produce
3+
# subtly different output:
4+
#
5+
# - regular output is in traversal order, whereas bitmap is split by type,
6+
# with non-packed objects at the end
7+
#
8+
# - regular output has a space and the pathname appended to non-commit
9+
# objects; bitmap output omits this
10+
#
11+
# This function normalizes and compares the two. The second file should
12+
# always be the bitmap output.
13+
test_bitmap_traversal () {
14+
if test "$1" = "--no-confirm-bitmaps"
15+
then
16+
shift
17+
elif cmp "$1" "$2"
18+
then
19+
echo >&2 "identical raw outputs; are you sure bitmaps were used?"
20+
return 1
21+
fi &&
22+
cut -d' ' -f1 "$1" | sort >"$1.normalized" &&
23+
sort "$2" >"$2.normalized" &&
24+
test_cmp "$1.normalized" "$2.normalized" &&
25+
rm -f "$1.normalized" "$2.normalized"
26+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ test_description='skip-worktree bit test'
99

1010
sane_unset GIT_TEST_SPLIT_INDEX
1111

12+
test_set_index_version () {
13+
GIT_INDEX_VERSION="$1"
14+
export GIT_INDEX_VERSION
15+
}
16+
1217
test_set_index_version 3
1318

1419
cat >expect.full <<EOF

t/t3404-rebase-interactive.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ test_expect_success 'rebase -i with the exec command' '
101101
) &&
102102
test_path_is_file touch-one &&
103103
test_path_is_file touch-two &&
104-
test_path_is_missing touch-three " (should have stopped before)" &&
104+
# Missing because we should have stopped by now.
105+
test_path_is_missing touch-three &&
105106
test_cmp_rev C HEAD &&
106107
git rebase --continue &&
107108
test_path_is_file touch-three &&

t/t4000-diff-format.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ test_description='Test built-in diff output engine.
77
88
'
99
. ./test-lib.sh
10-
. "$TEST_DIRECTORY"/diff-lib.sh
10+
. "$TEST_DIRECTORY"/lib-diff.sh
1111

1212
echo >path0 'Line 1
1313
Line 2

t/t4001-diff-rename.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ test_description='Test rename detection in diff engine.
77
88
'
99
. ./test-lib.sh
10-
. "$TEST_DIRECTORY"/diff-lib.sh
10+
. "$TEST_DIRECTORY"/lib-diff.sh
1111

1212
test_expect_success 'setup' '
1313
cat >path0 <<-\EOF &&

t/t4003-diff-rename-1.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ test_description='More rename detection
77
88
'
99
. ./test-lib.sh
10-
. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
10+
. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash
1111

1212
test_expect_success \
1313
'prepare reference tree' \
14-
'cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
14+
'cat "$TEST_DIRECTORY"/lib-diff/COPYING >COPYING &&
1515
echo frotz >rezrov &&
1616
git update-index --add COPYING rezrov &&
1717
tree=$(git write-tree) &&
@@ -99,7 +99,7 @@ test_expect_success \
9999

100100
test_expect_success \
101101
'prepare work tree once again' \
102-
'cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
102+
'cat "$TEST_DIRECTORY"/lib-diff/COPYING >COPYING &&
103103
git update-index --add --remove COPYING COPYING.1'
104104

105105
# tree has COPYING and rezrov. work tree has COPYING and COPYING.1,

t/t4004-diff-rename-symlink.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ copy of symbolic links, but should not produce rename/copy followed
1010
by an edit for them.
1111
'
1212
. ./test-lib.sh
13-
. "$TEST_DIRECTORY"/diff-lib.sh
13+
. "$TEST_DIRECTORY"/lib-diff.sh
1414

1515
test_expect_success SYMLINKS \
1616
'prepare reference tree' \

t/t4005-diff-rename-2.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
test_description='Same rename detection as t4003 but testing diff-raw.'
77

88
. ./test-lib.sh
9-
. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
9+
. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash
1010

1111
test_expect_success 'setup reference tree' '
12-
cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
12+
cat "$TEST_DIRECTORY"/lib-diff/COPYING >COPYING &&
1313
echo frotz >rezrov &&
1414
git update-index --add COPYING rezrov &&
1515
tree=$(git write-tree) &&
@@ -64,7 +64,7 @@ test_expect_success 'validate output from rename/copy detection (#2)' '
6464
# nows how to say Copy.
6565

6666
test_expect_success 'validate output from rename/copy detection (#3)' '
67-
cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
67+
cat "$TEST_DIRECTORY"/lib-diff/COPYING >COPYING &&
6868
git update-index --add --remove COPYING COPYING.1 &&
6969
7070
cat <<-EOF >expected &&

t/t4007-rename-3.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ test_description='Rename interaction with pathspec.
77
88
'
99
. ./test-lib.sh
10-
. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
10+
. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash
1111

1212
test_expect_success 'prepare reference tree' '
1313
mkdir path0 path1 &&
14-
cp "$TEST_DIRECTORY"/diff-lib/COPYING path0/COPYING &&
14+
cp "$TEST_DIRECTORY"/lib-diff/COPYING path0/COPYING &&
1515
git update-index --add path0/COPYING &&
1616
tree=$(git write-tree) &&
1717
echo $tree
1818
'
1919

20-
blob=$(git hash-object "$TEST_DIRECTORY/diff-lib/COPYING")
20+
blob=$(git hash-object "$TEST_DIRECTORY/lib-diff/COPYING")
2121
test_expect_success 'prepare work tree' '
2222
cp path0/COPYING path1/COPYING &&
2323
git update-index --add --remove path0/COPYING path1/COPYING

t/t4008-diff-break-rewrite.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ With -B, this should be detected as two complete rewrites.
2222
Further, with -B and -M together, these should turn into two renames.
2323
'
2424
. ./test-lib.sh
25-
. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
25+
. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash
2626

2727
test_expect_success setup '
28-
cat "$TEST_DIRECTORY"/diff-lib/README >file0 &&
29-
cat "$TEST_DIRECTORY"/diff-lib/COPYING >file1 &&
28+
cat "$TEST_DIRECTORY"/lib-diff/README >file0 &&
29+
cat "$TEST_DIRECTORY"/lib-diff/COPYING >file1 &&
3030
blob0_id=$(git hash-object file0) &&
3131
blob1_id=$(git hash-object file1) &&
3232
git update-index --add file0 file1 &&

t/t4009-diff-rename-4.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ test_description='Same rename detection as t4003 but testing diff-raw -z.
77
88
'
99
. ./test-lib.sh
10-
. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
10+
. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash
1111

1212
test_expect_success \
1313
'prepare reference tree' \
14-
'cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
14+
'cat "$TEST_DIRECTORY"/lib-diff/COPYING >COPYING &&
1515
echo frotz >rezrov &&
1616
git update-index --add COPYING rezrov &&
1717
orig=$(git hash-object COPYING) &&
@@ -81,7 +81,7 @@ test_expect_success \
8181

8282
test_expect_success \
8383
'prepare work tree once again' \
84-
'cat "$TEST_DIRECTORY"/diff-lib/COPYING >COPYING &&
84+
'cat "$TEST_DIRECTORY"/lib-diff/COPYING >COPYING &&
8585
git update-index --add --remove COPYING COPYING.1'
8686

8787
git diff-index -z -C --find-copies-harder $tree >current

t/t4010-diff-pathspec.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Prepare:
1010
path1/file1
1111
'
1212
. ./test-lib.sh
13-
. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
13+
. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash
1414

1515
test_expect_success \
1616
setup \

t/t4011-diff-symlink.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ test_description='Test diff of symlinks.
77
88
'
99
. ./test-lib.sh
10-
. "$TEST_DIRECTORY"/diff-lib.sh
10+
. "$TEST_DIRECTORY"/lib-diff.sh
1111

1212
# Print the short OID of a symlink with the given name.
1313
symlink_oid () {

t/t4013-diff-various.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
99
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
1010

1111
. ./test-lib.sh
12-
. "$TEST_DIRECTORY"/diff-lib.sh
12+
. "$TEST_DIRECTORY"/lib-diff.sh
1313

1414
test_expect_success setup '
1515

t/t4015-diff-whitespace.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ test_description='Test special whitespace in diff engine.
77
88
'
99
. ./test-lib.sh
10-
. "$TEST_DIRECTORY"/diff-lib.sh
10+
. "$TEST_DIRECTORY"/lib-diff.sh
1111

1212
test_expect_success "Ray Lehtiniemi's example" '
1313
cat <<-\EOF >x &&

t/t4027-diff-submodule.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
test_description='difference in submodules'
44

55
. ./test-lib.sh
6-
. "$TEST_DIRECTORY"/diff-lib.sh
6+
. "$TEST_DIRECTORY"/lib-diff.sh
77

88
test_expect_success setup '
99
test_tick &&

t/t4034-diff-words.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
test_description='word diff colors'
44

55
. ./test-lib.sh
6-
. "$TEST_DIRECTORY"/diff-lib.sh
6+
. "$TEST_DIRECTORY"/lib-diff.sh
77

88
cat >pre.simple <<-\EOF
99
h(4)

t/t4038-diff-combined.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
66
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
77

88
. ./test-lib.sh
9-
. "$TEST_DIRECTORY"/diff-lib.sh
9+
. "$TEST_DIRECTORY"/lib-diff.sh
1010

1111
setup_helper () {
1212
one=$1 branch=$2 side=$3 &&

t/t4061-diff-indent.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
77
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
88

99
. ./test-lib.sh
10-
. "$TEST_DIRECTORY"/diff-lib.sh
10+
. "$TEST_DIRECTORY"/lib-diff.sh
1111

1212
# Compare two diff outputs. Ignore "index" lines, because we don't
1313
# care about SHA-1s or file modes.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ test_description='Test --follow should always find copies hard in git log.
77
88
'
99
. ./test-lib.sh
10-
. "$TEST_DIRECTORY"/diff-lib.sh
10+
. "$TEST_DIRECTORY"/lib-diff.sh
1111

1212
echo >path0 'Line 1
1313
Line 2

t/t5310-pack-bitmaps.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
55
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
66

77
. ./test-lib.sh
8+
. "$TEST_DIRECTORY"/lib-bundle.sh
9+
. "$TEST_DIRECTORY"/lib-bitmap.sh
810

911
objpath () {
1012
echo ".git/objects/$(echo "$1" | sed -e 's|\(..\)|\1/|')"

t/t5318-commit-graph.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ corrupt_graph_and_verify() {
551551
zero_pos=${4:-${orig_size}} &&
552552
printf "$data" | dd of="$objdir/info/commit-graph" bs=1 seek="$pos" conv=notrunc &&
553553
dd of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" if=/dev/null &&
554-
generate_zero_bytes $(($orig_size - $zero_pos)) >>"$objdir/info/commit-graph" &&
554+
test-tool genzeros $(($orig_size - $zero_pos)) >>"$objdir/info/commit-graph" &&
555555
corrupt_graph_verify "$grepstr"
556556

557557
}

t/t5510-fetch.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
99
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
1010

1111
. ./test-lib.sh
12-
. "$TEST_DIRECTORY"/test-bundle-functions.sh
12+
. "$TEST_DIRECTORY"/lib-bundle.sh
1313

1414
D=$(pwd)
1515

t/t6020-bundle-misc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
99
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
1010

1111
. ./test-lib.sh
12-
. "$TEST_DIRECTORY"/test-bundle-functions.sh
12+
. "$TEST_DIRECTORY"/lib-bundle.sh
1313

1414
# Create a commit or tag and set the variable with the object ID.
1515
test_commit_setvar () {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
test_description='rev-list combining bitmaps and filters'
44
. ./test-lib.sh
5+
. "$TEST_DIRECTORY"/lib-bitmap.sh
56

67
test_expect_success 'set up bitmapped repo' '
78
# one commit will have bitmaps, the other will not

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,9 @@ test_expect_success '3a-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
492492
test_cmp expect actual &&
493493
494494
test_must_fail git rev-parse HEAD:bq HEAD:foo/bq &&
495-
test_path_is_missing bq foo/bq foo/whatever
495+
test_path_is_missing bq &&
496+
test_path_is_missing foo/bq &&
497+
test_path_is_missing foo/whatever
496498
)
497499
'
498500

@@ -522,7 +524,9 @@ test_expect_success '3a-R: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
522524
test_cmp expect actual &&
523525
524526
test_must_fail git rev-parse HEAD:bq HEAD:foo/bq &&
525-
test_path_is_missing bq foo/bq foo/whatever
527+
test_path_is_missing bq &&
528+
test_path_is_missing foo/bq &&
529+
test_path_is_missing foo/whatever
526530
)
527531
'
528532

@@ -588,7 +592,9 @@ test_expect_success '3b-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
588592
test_cmp expect actual &&
589593
590594
test_must_fail git rev-parse HEAD:bq HEAD:foo/bq &&
591-
test_path_is_missing bq foo/bq foo/whatever
595+
test_path_is_missing bq &&
596+
test_path_is_missing foo/bq &&
597+
test_path_is_missing foo/whatever
592598
)
593599
'
594600

@@ -618,7 +624,9 @@ test_expect_success '3b-R: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
618624
test_cmp expect actual &&
619625
620626
test_must_fail git rev-parse HEAD:bq HEAD:foo/bq &&
621-
test_path_is_missing bq foo/bq foo/whatever
627+
test_path_is_missing bq &&
628+
test_path_is_missing foo/bq &&
629+
test_path_is_missing foo/whatever
622630
)
623631
'
624632

0 commit comments

Comments
 (0)