{"thread":{"id":"20711","subject":"[RFC/PATCH 2/3] gitweb: break test suite into library and tests","startedAt":"2009-08-23T21:52:08Z","lastAt":"2009-08-23T21:52:08Z","messageCount":1,"participants":["Mark Rada"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"121592","messageId":"4A91BA08.2010003@mailservices.uwaterloo.ca","threadId":"20711","inReplyTo":null,"subject":"[RFC/PATCH 2/3] gitweb: break test suite into library and tests","fromName":"Mark Rada","fromEmail":"marada@uwaterloo.ca","sentAt":"2009-08-23T21:52:08Z","receivedAt":"2009-08-23T21:52:08Z","isPatch":true,"sender":{"key":"marada@uwaterloo.ca","avatar":"https://avatars.githubusercontent.com/u/38430?v=4"},"body":"To accommodate additions to the tests cases for gitweb, the preamble\nfrom t9500 is now in its library so that new sets of tests for gitweb\ncan use the same setup without copying the same code.\n\nSigned-off-by: Mark Rada <marada@uwaterloo.ca>\n---\n t/gitweb-lib.sh                        |   79 ++++++++++++++++++++++++++++++++\n t/t9500-gitweb-standalone-no-errors.sh |   74 +-----------------------------\n 2 files changed, 80 insertions(+), 73 deletions(-)\n create mode 100644 t/gitweb-lib.sh\n\ndiff --git a/t/gitweb-lib.sh b/t/gitweb-lib.sh\nnew file mode 100644\nindex 0000000..3a60fa5\n--- /dev/null\n+++ b/t/gitweb-lib.sh\n@@ -0,0 +1,79 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2007 Jakub Narebski\n+#\n+\n+test_description='gitweb as standalone script (basic tests).\n+\n+This test runs gitweb (git web interface) as CGI script from\n+commandline, and checks that it would not write any errors\n+or warnings to log.'\n+\n+gitweb_init () {\n+\tsafe_pwd=\"$(perl -MPOSIX=getcwd -e 'print quotemeta(getcwd)')\"\n+\tcat >gitweb_config.perl <<EOF\n+#!/usr/bin/perl\n+\n+# gitweb configuration for tests\n+\n+our \\$version = 'current';\n+our \\$GIT = 'git';\n+our \\$projectroot = \"$safe_pwd\";\n+our \\$project_maxdepth = 8;\n+our \\$home_link_str = 'projects';\n+our \\$site_name = '[localhost]';\n+our \\$site_header = '';\n+our \\$site_footer = '';\n+our \\$home_text = 'indextext.html';\n+our @stylesheets = ('file:///$TEST_DIRECTORY/../gitweb/gitweb.css');\n+our \\$logo = 'file:///$TEST_DIRECTORY/../gitweb/git-logo.png';\n+our \\$favicon = 'file:///$TEST_DIRECTORY/../gitweb/git-favicon.png';\n+our \\$projects_list = '';\n+our \\$export_ok = '';\n+our \\$strict_export = '';\n+\n+EOF\n+\n+\tcat >.git/description <<EOF\n+$0 test repository\n+EOF\n+}\n+\n+gitweb_run () {\n+\tGATEWAY_INTERFACE='CGI/1.1'\n+\tHTTP_ACCEPT='*/*'\n+\tREQUEST_METHOD='GET'\n+\tSCRIPT_NAME=\"$TEST_DIRECTORY/../gitweb/gitweb.perl\"\n+\tQUERY_STRING=\"\"$1\"\"\n+\tPATH_INFO=\"\"$2\"\"\n+\texport GATEWAY_INTERFACE HTTP_ACCEPT REQUEST_METHOD \\\n+\t\tSCRIPT_NAME QUERY_STRING PATH_INFO\n+\n+\tGITWEB_CONFIG=$(pwd)/gitweb_config.perl\n+\texport GITWEB_CONFIG\n+\n+\t# some of git commands write to STDERR on error, but this is not\n+\t# written to web server logs, so we are not interested in that:\n+\t# we are interested only in properly formatted errors/warnings\n+\trm -f gitweb.log &&\n+\tperl -- \"$SCRIPT_NAME\" \\\n+\t\t>gitweb.output 2>gitweb.log &&\n+\tif grep '^[[]' gitweb.log >/dev/null 2>&1; then false; else true; fi\n+\n+\t# gitweb.log is left for debugging\n+\t# gitweb.output is used to parse http output\n+}\n+\n+. ./test-lib.sh\n+\n+if ! test_have_prereq PERL; then\n+\tsay 'skipping gitweb tests, perl not available'\n+\ttest_done\n+fi\n+\n+perl -MEncode -e 'decode_utf8(\"\", Encode::FB_CROAK)' >/dev/null 2>&1 || {\n+    say 'skipping gitweb tests, perl version is too old'\n+    test_done\n+}\n+\n+gitweb_init\ndiff --git a/t/t9500-gitweb-standalone-no-errors.sh b/t/t9500-gitweb-standalone-no-errors.sh\nindex 6275181..a5b5b26 100755\n--- a/t/t9500-gitweb-standalone-no-errors.sh\n+++ b/t/t9500-gitweb-standalone-no-errors.sh\n@@ -3,79 +3,7 @@\n # Copyright (c) 2007 Jakub Narebski\n #\n \n-test_description='gitweb as standalone script (basic tests).\n-\n-This test runs gitweb (git web interface) as CGI script from\n-commandline, and checks that it would not write any errors\n-or warnings to log.'\n-\n-gitweb_init () {\n-\tsafe_pwd=\"$(perl -MPOSIX=getcwd -e 'print quotemeta(getcwd)')\"\n-\tcat >gitweb_config.perl <<EOF\n-#!/usr/bin/perl\n-\n-# gitweb configuration for tests\n-\n-our \\$version = \"current\";\n-our \\$GIT = \"git\";\n-our \\$projectroot = \"$safe_pwd\";\n-our \\$project_maxdepth = 8;\n-our \\$home_link_str = \"projects\";\n-our \\$site_name = \"[localhost]\";\n-our \\$site_header = \"\";\n-our \\$site_footer = \"\";\n-our \\$home_text = \"indextext.html\";\n-our @stylesheets = (\"file:///$TEST_DIRECTORY/../gitweb/gitweb.css\");\n-our \\$logo = \"file:///$TEST_DIRECTORY/../gitweb/git-logo.png\";\n-our \\$favicon = \"file:///$TEST_DIRECTORY/../gitweb/git-favicon.png\";\n-our \\$projects_list = \"\";\n-our \\$export_ok = \"\";\n-our \\$strict_export = \"\";\n-\n-EOF\n-\n-\tcat >.git/description <<EOF\n-$0 test repository\n-EOF\n-}\n-\n-gitweb_run () {\n-\tGATEWAY_INTERFACE=\"CGI/1.1\"\n-\tHTTP_ACCEPT=\"*/*\"\n-\tREQUEST_METHOD=\"GET\"\n-\tSCRIPT_NAME=\"$TEST_DIRECTORY/../gitweb/gitweb.perl\"\n-\tQUERY_STRING=\"\"$1\"\"\n-\tPATH_INFO=\"\"$2\"\"\n-\texport GATEWAY_INTERFACE HTTP_ACCEPT REQUEST_METHOD \\\n-\t\tSCRIPT_NAME QUERY_STRING PATH_INFO\n-\n-\tGITWEB_CONFIG=$(pwd)/gitweb_config.perl\n-\texport GITWEB_CONFIG\n-\n-\t# some of git commands write to STDERR on error, but this is not\n-\t# written to web server logs, so we are not interested in that:\n-\t# we are interested only in properly formatted errors/warnings\n-\trm -f gitweb.log &&\n-\tperl -- \"$SCRIPT_NAME\" \\\n-\t\t>/dev/null 2>gitweb.log &&\n-\tif grep \"^[[]\" gitweb.log >/dev/null 2>&1; then false; else true; fi\n-\n-\t# gitweb.log is left for debugging\n-}\n-\n-. ./test-lib.sh\n-\n-if ! test_have_prereq PERL; then\n-\tsay 'skipping gitweb tests, perl not available'\n-\ttest_done\n-fi\n-\n-perl -MEncode -e 'decode_utf8(\"\", Encode::FB_CROAK)' >/dev/null 2>&1 || {\n-    say 'skipping gitweb tests, perl version is too old'\n-    test_done\n-}\n-\n-gitweb_init\n+. ./gitweb-lib.sh\n \n # ----------------------------------------------------------------------\n # no commits (empty, just initialized repository)\n-- \n1.6.4\n"}]}