t5530: modernize tests
Refactor tests to follow modern best practices: - Merge together tests that set up and verify a single use case. - Drop empty newlines at the beginning and end of test bodies. - Don't change directories in the main test body. - Remove an unused `D` variable. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Sep 5, 2025 at 08:18 UTC
7a57fb1a597eb2fa281c00cac94863ad0d7d7f6c
1 file changed
+5
-28
t/t5530-upload-pack-error.sh
+5
-28
@@ -4,8 +4,6 @@ test_description='errors in upload-pack'
4
5
. ./test-lib.sh
6
7
-D=$(pwd)
8
-
7
corrupt_repo () {
8
object_sha1=$(git rev-parse "$1") &&
9
ob=$(expr "$object_sha1" : "\(..\)") &&
@@ -21,11 +19,7 @@ test_expect_success 'setup and corrupt repository' '
19
test_tick &&
20
echo changed >file &&
21
git commit -a -m changed &&
24
- corrupt_repo HEAD:file
25
-
26
-'
27
-
28
-test_expect_success 'fsck fails' '
22
+ corrupt_repo HEAD:file &&
23
test_must_fail git fsck
24
'
25
@@ -40,17 +34,12 @@ test_expect_success 'upload-pack fails due to error in pack-objects packing' '
34
'
35
36
test_expect_success 'corrupt repo differently' '
43
-
37
git hash-object -w file &&
45
- corrupt_repo HEAD^^{tree}
46
-
47
-'
48
-
49
-test_expect_success 'fsck fails' '
38
+ corrupt_repo HEAD^^{tree} &&
39
test_must_fail git fsck
40
'
52
-test_expect_success 'upload-pack fails due to error in rev-list' '
41
42
+test_expect_success 'upload-pack fails due to error in rev-list' '
43
printf "%04xwant %s\n%04xshallow %s00000009done\n0000" \
44
$(($hexsz + 10)) $(git rev-parse HEAD) \
45
$(($hexsz + 12)) $(git rev-parse HEAD^) >input &&
@@ -59,7 +48,6 @@ test_expect_success 'upload-pack fails due to error in rev-list' '
48
'
49
50
test_expect_success 'upload-pack fails due to bad want (no object)' '
62
-
51
printf "%04xwant %s multi_ack_detailed\n00000009done\n0000" \
52
$(($hexsz + 29)) $(test_oid deadbeef) >input &&
53
test_must_fail git upload-pack . <input >output 2>output.err &&
@@ -69,7 +57,6 @@ test_expect_success 'upload-pack fails due to bad want (no object)' '
57
'
58
59
test_expect_success 'upload-pack fails due to bad want (not tip)' '
72
-
60
oid=$(echo an object we have | git hash-object -w --stdin) &&
61
printf "%04xwant %s multi_ack_detailed\n00000009done\n0000" \
62
$(($hexsz + 29)) "$oid" >input &&
@@ -80,7 +67,6 @@ test_expect_success 'upload-pack fails due to bad want (not tip)' '
67
'
68
69
test_expect_success 'upload-pack fails due to error in pack-objects enumeration' '
83
-
70
printf "%04xwant %s\n00000009done\n0000" \
71
$((hexsz + 10)) $(git rev-parse HEAD) >input &&
72
test_must_fail git upload-pack . <input >/dev/null 2>output.err &&
@@ -105,18 +91,9 @@ test_expect_success 'upload-pack tolerates EOF just after stateless client wants
91
test_cmp expect actual
92
'
93
108
-test_expect_success 'create empty repository' '
109
-
110
- mkdir foo &&
111
- cd foo &&
112
- git init
113
-
114
-'
115
-
94
test_expect_success 'fetch fails' '
117
-
118
- test_must_fail git fetch .. main
119
-
95
+ git init foo &&
96
+ test_must_fail git -C foo fetch .. main
97
'
98
99
test_done