{"thread":{"id":"20728","subject":"[PATCH v2 2/3] gitweb: split test suite into library and tests","startedAt":"2009-08-25T05:00:16Z","lastAt":"2009-08-25T05:00:16Z","messageCount":1,"participants":["Mark Rada"],"isPatch":true,"patchVersion":2,"patchTotal":3},"messages":[{"id":"121707","messageId":"4A936FE0.2070208@mailservices.uwaterloo.ca","threadId":"20728","inReplyTo":null,"subject":"[PATCH v2 2/3] gitweb: split test suite into library and tests","fromName":"Mark Rada","fromEmail":"marada@uwaterloo.ca","sentAt":"2009-08-25T05:00:16Z","receivedAt":"2009-08-25T05:00:16Z","isPatch":true,"sender":{"key":"marada@uwaterloo.ca","avatar":"https://avatars.githubusercontent.com/u/38430?v=4"},"body":"Change the subject from saying 'break' to 'split', because break\nmay have given people the wrong idea about what the commit is doing.\n\nI also put the test_description back into t9500, having it in\ngitweb-lib.sh was a mistake.\n\n-- \nMark A Rada (ferrous26)\nmarada@uwaterloo.ca\n\n\n--->8---\nTo accommodate additions to the tests cases for gitweb, the preamble\nfrom t9500 is now in its own library so that new sets of tests for\ngitweb can use the same setup without copying the code.\n\nSigned-off-by: Mark Rada <marada@uwaterloo.ca>\n---\n t/gitweb-lib.sh                        |   73 ++++++++++++++++++++++++++++++++\n t/t9500-gitweb-standalone-no-errors.sh |   67 +----------------------------\n 2 files changed, 74 insertions(+), 66 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..8452532\n--- /dev/null\n+++ b/t/gitweb-lib.sh\n@@ -0,0 +1,73 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2007 Jakub Narebski\n+#\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..2fc7fdb 100755\n--- a/t/t9500-gitweb-standalone-no-errors.sh\n+++ b/t/t9500-gitweb-standalone-no-errors.sh\n@@ -9,73 +9,8 @@ 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"}]}