Skip to content

Commit 362d8b6

Browse files
sbeyergitster
authored andcommitted
t5561: get rid of racy appending to logfile
The definition of log_div() appended information to the web server's logfile to make the test more readable. However, log_div() was called right after a request is served (which is done by git-http-backend); the web server waits for the git-http-backend process to exit before it writes to the log file. When the duration between serving a request and exiting was long, the log_div() output was written before the last request's log, and the test failed. (This duration could become especially long for PROFILE=GEN builds.) To get rid of this behavior, we should not change the logfile at all. This commit removes log_div() and its calls. The additional information is kept in the test (for readability reasons) but filtered out before comparing it to the actual logfile. Signed-off-by: Stephan Beyer <[email protected]> Reviewed-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e156455 commit 362d8b6

File tree

3 files changed

+1
-23
lines changed

3 files changed

+1
-23
lines changed

t/t5560-http-backend-noserver.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ POST() {
4040
test_cmp exp act
4141
}
4242

43-
log_div() {
44-
return 0
45-
}
46-
4743
. "$TEST_DIRECTORY"/t556x_common
4844

4945
expect_aliased() {

t/t5561-http-backend.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,9 @@ POST() {
3535
test_cmp exp act
3636
}
3737

38-
log_div() {
39-
echo >>"$HTTPD_ROOT_PATH"/access.log
40-
echo "### $1" >>"$HTTPD_ROOT_PATH"/access.log
41-
echo "###" >>"$HTTPD_ROOT_PATH"/access.log
42-
}
43-
4438
. "$TEST_DIRECTORY"/t556x_common
4539

46-
cat >exp <<EOF
40+
grep '^[^#]' >exp <<EOF
4741
4842
### refs/heads/master
4943
###

t/t556x_common

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,17 @@ get_static_files() {
5252
SMART=smart
5353
GIT_HTTP_EXPORT_ALL=1 && export GIT_HTTP_EXPORT_ALL
5454
test_expect_success 'direct refs/heads/master not found' '
55-
log_div "refs/heads/master" &&
5655
GET refs/heads/master "404 Not Found"
5756
'
5857
test_expect_success 'static file is ok' '
59-
log_div "getanyfile default" &&
6058
get_static_files "200 OK"
6159
'
6260
SMART=smart_noexport
6361
unset GIT_HTTP_EXPORT_ALL
6462
test_expect_success 'no export by default' '
65-
log_div "no git-daemon-export-ok" &&
6663
get_static_files "404 Not Found"
6764
'
6865
test_expect_success 'export if git-daemon-export-ok' '
69-
log_div "git-daemon-export-ok" &&
7066
(cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
7167
touch git-daemon-export-ok
7268
) &&
@@ -75,47 +71,39 @@ test_expect_success 'export if git-daemon-export-ok' '
7571
SMART=smart
7672
GIT_HTTP_EXPORT_ALL=1 && export GIT_HTTP_EXPORT_ALL
7773
test_expect_success 'static file if http.getanyfile true is ok' '
78-
log_div "getanyfile true" &&
7974
config http.getanyfile true &&
8075
get_static_files "200 OK"
8176
'
8277
test_expect_success 'static file if http.getanyfile false fails' '
83-
log_div "getanyfile false" &&
8478
config http.getanyfile false &&
8579
get_static_files "403 Forbidden"
8680
'
8781

8882
test_expect_success 'http.uploadpack default enabled' '
89-
log_div "uploadpack default" &&
9083
GET info/refs?service=git-upload-pack "200 OK" &&
9184
POST git-upload-pack 0000 "200 OK"
9285
'
9386
test_expect_success 'http.uploadpack true' '
94-
log_div "uploadpack true" &&
9587
config http.uploadpack true &&
9688
GET info/refs?service=git-upload-pack "200 OK" &&
9789
POST git-upload-pack 0000 "200 OK"
9890
'
9991
test_expect_success 'http.uploadpack false' '
100-
log_div "uploadpack false" &&
10192
config http.uploadpack false &&
10293
GET info/refs?service=git-upload-pack "403 Forbidden" &&
10394
POST git-upload-pack 0000 "403 Forbidden"
10495
'
10596

10697
test_expect_success 'http.receivepack default disabled' '
107-
log_div "receivepack default" &&
10898
GET info/refs?service=git-receive-pack "403 Forbidden" &&
10999
POST git-receive-pack 0000 "403 Forbidden"
110100
'
111101
test_expect_success 'http.receivepack true' '
112-
log_div "receivepack true" &&
113102
config http.receivepack true &&
114103
GET info/refs?service=git-receive-pack "200 OK" &&
115104
POST git-receive-pack 0000 "200 OK"
116105
'
117106
test_expect_success 'http.receivepack false' '
118-
log_div "receivepack false" &&
119107
config http.receivepack false &&
120108
GET info/refs?service=git-receive-pack "403 Forbidden" &&
121109
POST git-receive-pack 0000 "403 Forbidden"

0 commit comments

Comments
 (0)