Skip to content

Commit 7a57fb1

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 16bd9f2 commit 7a57fb1

File tree

1 file changed

+5
-28
lines changed

1 file changed

+5
-28
lines changed

t/t5530-upload-pack-error.sh

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ test_description='errors in upload-pack'
44

55
. ./test-lib.sh
66

7-
D=$(pwd)
8-
97
corrupt_repo () {
108
object_sha1=$(git rev-parse "$1") &&
119
ob=$(expr "$object_sha1" : "\(..\)") &&
@@ -21,11 +19,7 @@ test_expect_success 'setup and corrupt repository' '
2119
test_tick &&
2220
echo changed >file &&
2321
git commit -a -m changed &&
24-
corrupt_repo HEAD:file
25-
26-
'
27-
28-
test_expect_success 'fsck fails' '
22+
corrupt_repo HEAD:file &&
2923
test_must_fail git fsck
3024
'
3125

@@ -40,17 +34,12 @@ test_expect_success 'upload-pack fails due to error in pack-objects packing' '
4034
'
4135

4236
test_expect_success 'corrupt repo differently' '
43-
4437
git hash-object -w file &&
45-
corrupt_repo HEAD^^{tree}
46-
47-
'
48-
49-
test_expect_success 'fsck fails' '
38+
corrupt_repo HEAD^^{tree} &&
5039
test_must_fail git fsck
5140
'
52-
test_expect_success 'upload-pack fails due to error in rev-list' '
5341

42+
test_expect_success 'upload-pack fails due to error in rev-list' '
5443
printf "%04xwant %s\n%04xshallow %s00000009done\n0000" \
5544
$(($hexsz + 10)) $(git rev-parse HEAD) \
5645
$(($hexsz + 12)) $(git rev-parse HEAD^) >input &&
@@ -59,7 +48,6 @@ test_expect_success 'upload-pack fails due to error in rev-list' '
5948
'
6049

6150
test_expect_success 'upload-pack fails due to bad want (no object)' '
62-
6351
printf "%04xwant %s multi_ack_detailed\n00000009done\n0000" \
6452
$(($hexsz + 29)) $(test_oid deadbeef) >input &&
6553
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)' '
6957
'
7058

7159
test_expect_success 'upload-pack fails due to bad want (not tip)' '
72-
7360
oid=$(echo an object we have | git hash-object -w --stdin) &&
7461
printf "%04xwant %s multi_ack_detailed\n00000009done\n0000" \
7562
$(($hexsz + 29)) "$oid" >input &&
@@ -80,7 +67,6 @@ test_expect_success 'upload-pack fails due to bad want (not tip)' '
8067
'
8168

8269
test_expect_success 'upload-pack fails due to error in pack-objects enumeration' '
83-
8470
printf "%04xwant %s\n00000009done\n0000" \
8571
$((hexsz + 10)) $(git rev-parse HEAD) >input &&
8672
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
10591
test_cmp expect actual
10692
'
10793

108-
test_expect_success 'create empty repository' '
109-
110-
mkdir foo &&
111-
cd foo &&
112-
git init
113-
114-
'
115-
11694
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
12097
'
12198

12299
test_done

0 commit comments

Comments
 (0)