Skip to content

Commit 6940a06

Browse files
szedergitster
authored andcommitted
t/lib-httpd: add the strip_access_log() helper function
Four tests in three httpd-related test scripts check the contents of Apache's 'access.log', and they all do so by running 'sed' with the exact same script consisting of four s/// commands to strip uninteresting log fields and to vertically align the requested URLs. Extract this into a common helper function 'strip_access_log' in 'lib-httpd.sh', and use it in all of those tests. Signed-off-by: SZEDER Gábor <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a704c64 commit 6940a06

File tree

4 files changed

+13
-24
lines changed

4 files changed

+13
-24
lines changed

t/lib-httpd.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,3 +287,12 @@ expect_askpass() {
287287
test_cmp "$TRASH_DIRECTORY/askpass-expect" \
288288
"$TRASH_DIRECTORY/askpass-query"
289289
}
290+
291+
strip_access_log() {
292+
sed -e "
293+
s/^.* \"//
294+
s/\"//
295+
s/ [1-9][0-9]*\$//
296+
s/^GET /GET /
297+
" "$HTTPD_ROOT_PATH"/access.log
298+
}

t/t5541-http-push-smart.sh

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,7 @@ test_expect_success 'no empty path components' '
4747
cd "$ROOT_PATH" &&
4848
git clone $HTTPD_URL/smart/test_repo.git/ test_repo_clone &&
4949
50-
sed -e "
51-
s/^.* \"//
52-
s/\"//
53-
s/ [1-9][0-9]*\$//
54-
s/^GET /GET /
55-
" >act <"$HTTPD_ROOT_PATH"/access.log &&
50+
strip_access_log >act &&
5651
test_cmp exp act
5752
'
5853

@@ -134,12 +129,7 @@ GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
134129
POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
135130
EOF
136131
test_expect_success 'used receive-pack service' '
137-
sed -e "
138-
s/^.* \"//
139-
s/\"//
140-
s/ [1-9][0-9]*\$//
141-
s/^GET /GET /
142-
" >act <"$HTTPD_ROOT_PATH"/access.log &&
132+
strip_access_log >act &&
143133
test_cmp exp act
144134
'
145135

t/t5551-http-fetch-smart.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,7 @@ GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
9898
POST /smart/repo.git/git-upload-pack HTTP/1.1 200
9999
EOF
100100
test_expect_success 'used upload-pack service' '
101-
sed -e "
102-
s/^.* \"//
103-
s/\"//
104-
s/ [1-9][0-9]*\$//
105-
s/^GET /GET /
106-
" >act <"$HTTPD_ROOT_PATH"/access.log &&
101+
strip_access_log >act &&
107102
test_cmp exp act
108103
'
109104

t/t5561-http-backend.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,7 @@ GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -
123123
POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -
124124
EOF
125125
test_expect_success 'server request log matches test results' '
126-
sed -e "
127-
s/^.* \"//
128-
s/\"//
129-
s/ [1-9][0-9]*\$//
130-
s/^GET /GET /
131-
" >act <"$HTTPD_ROOT_PATH"/access.log &&
126+
strip_access_log >act &&
132127
test_cmp exp act
133128
'
134129

0 commit comments

Comments
 (0)