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 <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
SZEDER Gábor committed
Jul 12, 2018 at 14:22 UTC
6940a0602267a4b9ce328bc0f29784253b3df58d
4 files changed
+13
-24
t/lib-httpd.sh
+9
@@ -287,3 +287,12 @@ expect_askpass() {
287
test_cmp "$TRASH_DIRECTORY/askpass-expect" \
288
"$TRASH_DIRECTORY/askpass-query"
289
}
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
+2
-12
@@ -47,12 +47,7 @@ test_expect_success 'no empty path components' '
47
cd "$ROOT_PATH" &&
48
git clone $HTTPD_URL/smart/test_repo.git/ test_repo_clone &&
49
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 &&
51
test_cmp exp act
52
'
53
@@ -134,12 +129,7 @@ GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
129
POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
130
EOF
131
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 &&
133
test_cmp exp act
134
'
135
t/t5551-http-fetch-smart.sh
+1
-6
@@ -98,12 +98,7 @@ GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
98
POST /smart/repo.git/git-upload-pack HTTP/1.1 200
99
EOF
100
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 &&
102
test_cmp exp act
103
'
104
t/t5561-http-backend.sh
+1
-6
@@ -123,12 +123,7 @@ GET /smart/repo.git/info/refs?service=git-receive-pack HTTP/1.1 403 -
123
POST /smart/repo.git/git-receive-pack HTTP/1.1 403 -
124
EOF
125
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 &&
127
test_cmp exp act
128
'
129