Skip to content

Commit f7ae8e6

Browse files
bk2204gitster
authored andcommitted
t5515: make test hash independent
This test contains a large number of data files, mostly using the same object ID values for refs. Instead of producing two separate sets of test files, keep the test files using SHA-1 and translate them on the fly by replacing the SHA-1 values with the values for the current hash algorithm in use. Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e70649b commit f7ae8e6

File tree

1 file changed

+54
-5
lines changed

1 file changed

+54
-5
lines changed

t/t5515-fetch-merge-logic.sh

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,55 @@ GIT_TEST_PROTOCOL_VERSION=
1212

1313
. ./test-lib.sh
1414

15+
build_script () {
16+
script="$1" &&
17+
for i in one three_file master master2 one_tree three two two2 three2
18+
do
19+
echo "s/$(test_oid --hash=sha1 "$i")/$(test_oid "$i")/g" >>"$script"
20+
done
21+
}
22+
23+
convert_expected () {
24+
file="$1" &&
25+
script="$2" &&
26+
sed -f "$script" "$file" >"$file.tmp" &&
27+
mv "$file.tmp" "$file"
28+
}
29+
1530
test_expect_success setup '
1631
GIT_AUTHOR_DATE="2006-06-26 00:00:00 +0000" &&
1732
GIT_COMMITTER_DATE="2006-06-26 00:00:00 +0000" &&
1833
export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
1934
35+
test_oid_cache <<-EOF &&
36+
one sha1:8e32a6d901327a23ef831511badce7bf3bf46689
37+
one sha256:8739546433ab1ac72ee93088dce611210effee072b2b586ceac6dde43ebec9ce
38+
39+
three_file sha1:0e3b14047d3ee365f4f2a1b673db059c3972589c
40+
three_file sha256:bc4447d50c07497a8bfe6eef817f2364ecca9d471452e43b52756cc1a908bd32
41+
42+
master sha1:6c9dec2b923228c9ff994c6cfe4ae16c12408dc5
43+
master sha256:8521c3072461fcfe8f32d67f95cc6e6b832a2db2fa29769ffc788bce85ebcd75
44+
45+
one_tree sha1:22feea448b023a2d864ef94b013735af34d238ba
46+
one_tree sha256:6e4743f4ef2356b881dda5e91f5c7cdffe870faf350bf7b312f80a20935f5d83
47+
48+
three sha1:c61a82b60967180544e3c19f819ddbd0c9f89899
49+
three sha256:0cc6d1eda617ded715170786e31ba4e2d0185404ec5a3508dd0d73b324860c6a
50+
51+
two sha1:525b7fb068d59950d185a8779dc957c77eed73ba
52+
two sha256:3b21de3440cd38c2a9e9b464adb923f7054949ed4c918e1a0ac4c95cd52774db
53+
54+
master2 sha1:754b754407bf032e9a2f9d5a9ad05ca79a6b228f
55+
master2 sha256:6c7abaea8a6d8ef4d89877e68462758dc6774690fbbbb0e6d7dd57415c9abde0
56+
57+
two2 sha1:6134ee8f857693b96ff1cc98d3e2fd62b199e5a8
58+
two2 sha256:87a2d3ee29c83a3dc7afd41c0606b11f67603120b910a7be7840accdc18344d4
59+
60+
three2 sha1:0567da4d5edd2ff4bb292a465ba9e64dcad9536b
61+
three2 sha256:cceb3e8eca364fa9a0a39a1efbebecacc664af86cbbd8070571f5faeb5f0e8c3
62+
EOF
63+
2064
echo >file original &&
2165
git add file &&
2266
git commit -a -m One &&
@@ -86,7 +130,8 @@ test_expect_success setup '
86130
git config branch.br-$remote-octopus.remote $remote &&
87131
git config branch.br-$remote-octopus.merge refs/heads/one &&
88132
git config --add branch.br-$remote-octopus.merge two
89-
done
133+
done &&
134+
build_script sed_script
90135
'
91136

92137
# Merge logic depends on branch properties and Pull: or .fetch lines
@@ -137,6 +182,10 @@ do
137182
actual_r="$pfx-refs.$test"
138183

139184
test_expect_success "$cmd" '
185+
cp "$expect_f" expect_f &&
186+
convert_expected expect_f sed_script &&
187+
cp "$expect_r" expect_r &&
188+
convert_expected expect_r sed_script &&
140189
{
141190
echo "# $cmd"
142191
set x $cmd; shift
@@ -152,18 +201,18 @@ do
152201
cat .git/FETCH_HEAD
153202
} >"$actual_f" &&
154203
git show-ref >"$actual_r" &&
155-
if test -f "$expect_f"
204+
if test -f "expect_f"
156205
then
157-
test_cmp "$expect_f" "$actual_f" &&
206+
test_cmp "expect_f" "$actual_f" &&
158207
rm -f "$actual_f"
159208
else
160209
# this is to help developing new tests.
161210
cp "$actual_f" "$expect_f"
162211
false
163212
fi &&
164-
if test -f "$expect_r"
213+
if test -f "expect_r"
165214
then
166-
test_cmp "$expect_r" "$actual_r" &&
215+
test_cmp "expect_r" "$actual_r" &&
167216
rm -f "$actual_r"
168217
else
169218
# this is to help developing new tests.

0 commit comments

Comments
 (0)