{"thread":{"id":"26129","subject":"[PATCH] lib-git-svn.sh: Move web-server handling code into separate function","startedAt":"2010-12-23T19:03:47Z","lastAt":"2010-12-23T19:03:47Z","messageCount":1,"participants":["Ramsay Jones"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"158535","messageId":"4D139D13.1030900@ramsay1.demon.co.uk","threadId":"26129","inReplyTo":null,"subject":"[PATCH] lib-git-svn.sh: Move web-server handling code into separate function","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2010-12-23T19:03:47Z","receivedAt":"2010-12-23T19:03:47Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nThis library file is currently sourced by 57 test files, of which\nonly four may (optionally) start a web-server in order to access\nthe svn repo via an http url, rather than a file url.\n\nIn addition to isolating the current web-server handling code from\nthe majority of tests, in a new prepare_httpd function, we also\nadd some error checking and reporting code to validate the apache\ninstallation. Only those tests which attempt to start the web-\nserver, by calling start_httpd, will execute this code.\n\nNote that it is important for start_httpd to return an error\nindication, if prepare_httpd fails, so that the failure to use\nthe web-server, as requested by the user, should not go unnoticed.\n(Unless the svnrepo variable is set to an http url at the end of\nstart_httpd, the remaining tests will use file urls, without\ncomment.)\n\nSigned-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n---\n\nHi Junio,\n\nSorry for taking so long on this, I've been somewhat busy this week.\n\nThis is the patch I promised, except that I decided not to squash\nall of the previous lib-git-svn.sh patches. This replaces the\n\"lib-git-svn.sh: Add check for mis-configured web server variables\"\npatch in the rj/maint-test-fixes branch. (ie. patches #4 and #5, but\nnot #3, from the original series)\n\nHope that makes sense! :-P\n\nATB,\nRamsay Jones\n\n t/lib-git-svn.sh |   36 +++++++++++++++++++++++++-----------\n 1 files changed, 25 insertions(+), 11 deletions(-)\n\ndiff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh\nindex 919d45a..199f22c 100644\n--- a/t/lib-git-svn.sh\n+++ b/t/lib-git-svn.sh\n@@ -68,8 +68,7 @@ svn_cmd () {\n \tsvn \"$orig_svncmd\" --config-dir \"$svnconf\" \"$@\"\n }\n \n-if test -n \"$SVN_HTTPD_PORT\"\n-then\n+prepare_httpd () {\n \tfor d in \\\n \t\t\"$SVN_HTTPD_PATH\" \\\n \t\t/usr/sbin/apache2 \\\n@@ -81,6 +80,11 @@ then\n \t\t\tbreak\n \t\tfi\n \tdone\n+\tif test -z \"$SVN_HTTPD_PATH\"\n+\tthen\n+\t\techo >&2 '*** error: Apache not found'\n+\t\treturn 1\n+\tfi\n \tfor d in \\\n \t\t\"$SVN_HTTPD_MODULE_PATH\" \\\n \t\t/usr/lib/apache2/modules \\\n@@ -92,20 +96,18 @@ then\n \t\t\tbreak\n \t\tfi\n \tdone\n-fi\n-\n-start_httpd () {\n-\trepo_base_path=\"$1\"\n-\tif test -z \"$SVN_HTTPD_PORT\"\n+\tif test -z \"$SVN_HTTPD_MODULE_PATH\"\n \tthen\n-\t\techo >&2 'SVN_HTTPD_PORT is not defined!'\n-\t\treturn\n+\t\techo >&2 '*** error: Apache module dir not found'\n+\t\treturn 1\n \tfi\n-\tif test -z \"$repo_base_path\"\n+\tif test ! -f \"$SVN_HTTPD_MODULE_PATH/mod_dav_svn.so\"\n \tthen\n-\t\trepo_base_path=svn\n+\t\techo >&2 '*** error: Apache module \"mod_dav_svn\" not found'\n+\t\treturn 1\n \tfi\n \n+\trepo_base_path=\"${1-svn}\"\n \tmkdir \"$GIT_DIR\"/logs\n \n \tcat > \"$GIT_DIR/httpd.conf\" <<EOF\n@@ -122,12 +124,24 @@ LoadModule dav_svn_module $SVN_HTTPD_MODULE_PATH/mod_dav_svn.so\n \tSVNPath \"$rawsvnrepo\"\n </Location>\n EOF\n+}\n+\n+start_httpd () {\n+\tif test -z \"$SVN_HTTPD_PORT\"\n+\tthen\n+\t\techo >&2 'SVN_HTTPD_PORT is not defined!'\n+\t\treturn\n+\tfi\n+\n+\tprepare_httpd \"$1\" || return 1\n+\n \t\"$SVN_HTTPD_PATH\" -f \"$GIT_DIR\"/httpd.conf -k start\n \tsvnrepo=\"http://127.0.0.1:$SVN_HTTPD_PORT/$repo_base_path\"\n }\n \n stop_httpd () {\n \ttest -z \"$SVN_HTTPD_PORT\" && return\n+\ttest ! -f \"$GIT_DIR/httpd.conf\" && return\n \t\"$SVN_HTTPD_PATH\" -f \"$GIT_DIR\"/httpd.conf -k stop\n }\n \n-- \n1.7.3\n"}]}