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 <s-beyer@gmx.net> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stephan Beyer committed Sep 24, 2015 at 20:12 UTC 362d8b6e0d313e0e06553f5c390dc7f2172c0569
3 files changed +1 -23
t/t5560-http-backend-noserver.sh
-4
@@ -40,10 +40,6 @@ POST() {
40 test_cmp exp act
41 }
42
43 -log_div() {
44 - return 0
45 -}
46 -
43 . "$TEST_DIRECTORY"/t556x_common
44
45 expect_aliased() {
t/t5561-http-backend.sh
+1 -7
@@ -35,15 +35,9 @@ POST() {
35 test_cmp exp act
36 }
37
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 -
38 . "$TEST_DIRECTORY"/t556x_common
39
46 -cat >exp <<EOF
40 +grep '^[^#]' >exp <<EOF
41
42 ### refs/heads/master
43 ###
t/t556x_common
-12
@@ -52,21 +52,17 @@ get_static_files() {
52 SMART=smart
53 GIT_HTTP_EXPORT_ALL=1 && export GIT_HTTP_EXPORT_ALL
54 test_expect_success 'direct refs/heads/master not found' '
55 - log_div "refs/heads/master" &&
55 GET refs/heads/master "404 Not Found"
56 '
57 test_expect_success 'static file is ok' '
59 - log_div "getanyfile default" &&
58 get_static_files "200 OK"
59 '
60 SMART=smart_noexport
61 unset GIT_HTTP_EXPORT_ALL
62 test_expect_success 'no export by default' '
65 - log_div "no git-daemon-export-ok" &&
63 get_static_files "404 Not Found"
64 '
65 test_expect_success 'export if git-daemon-export-ok' '
69 - log_div "git-daemon-export-ok" &&
66 (cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
67 touch git-daemon-export-ok
68 ) &&
@@ -75,47 +71,39 @@ test_expect_success 'export if git-daemon-export-ok' '
71 SMART=smart
72 GIT_HTTP_EXPORT_ALL=1 && export GIT_HTTP_EXPORT_ALL
73 test_expect_success 'static file if http.getanyfile true is ok' '
78 - log_div "getanyfile true" &&
74 config http.getanyfile true &&
75 get_static_files "200 OK"
76 '
77 test_expect_success 'static file if http.getanyfile false fails' '
83 - log_div "getanyfile false" &&
78 config http.getanyfile false &&
79 get_static_files "403 Forbidden"
80 '
81
82 test_expect_success 'http.uploadpack default enabled' '
89 - log_div "uploadpack default" &&
83 GET info/refs?service=git-upload-pack "200 OK" &&
84 POST git-upload-pack 0000 "200 OK"
85 '
86 test_expect_success 'http.uploadpack true' '
94 - log_div "uploadpack true" &&
87 config http.uploadpack true &&
88 GET info/refs?service=git-upload-pack "200 OK" &&
89 POST git-upload-pack 0000 "200 OK"
90 '
91 test_expect_success 'http.uploadpack false' '
100 - log_div "uploadpack false" &&
92 config http.uploadpack false &&
93 GET info/refs?service=git-upload-pack "403 Forbidden" &&
94 POST git-upload-pack 0000 "403 Forbidden"
95 '
96
97 test_expect_success 'http.receivepack default disabled' '
107 - log_div "receivepack default" &&
98 GET info/refs?service=git-receive-pack "403 Forbidden" &&
99 POST git-receive-pack 0000 "403 Forbidden"
100 '
101 test_expect_success 'http.receivepack true' '
112 - log_div "receivepack true" &&
102 config http.receivepack true &&
103 GET info/refs?service=git-receive-pack "200 OK" &&
104 POST git-receive-pack 0000 "200 OK"
105 '
106 test_expect_success 'http.receivepack false' '
118 - log_div "receivepack false" &&
107 config http.receivepack false &&
108 GET info/refs?service=git-receive-pack "403 Forbidden" &&
109 POST git-receive-pack 0000 "403 Forbidden"