{"thread":{"id":"13996","subject":"[RFC/PATCH (WIP)] gitweb: Check that RSS, Atom and OPML output is well formed XML","startedAt":"2008-06-17T07:22:04Z","lastAt":"2008-06-17T07:22:04Z","messageCount":1,"participants":["Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"80112","messageId":"200806170922.05348.jnareb@gmail.com","threadId":"13996","inReplyTo":null,"subject":"[RFC/PATCH (WIP)] gitweb: Check that RSS, Atom and OPML output is well formed XML","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-06-17T07:22:04Z","receivedAt":"2008-06-17T07:22:04Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"NOTE: This does not check that RSS and Atom feeds (and OPML outline)\nconform to the specification (which might be given as DTD, XSD = XML\nSchema, Relax-NG schema,...), only that it parses without errors.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nTo check Atom and RSS feeds against specification we could use script\nversion of W3C Feed Validator (http://validator.w3.org/feed/), or\ntry to validate against XML Schema (XSD) which is default schema\nlanguage for RSS, or against Relax-NG schema which is default schema\nlanguage for Atom.\n\n t/t9503/test.pl             |   75 ++++++++++++++++++++++++++++++++++++++++--\n 2 files changed, 72 insertions(+), 5 deletions(-)\n\ndiff --git a/t/t9503/test.pl b/t/t9503/test.pl\nindex 7d081b9..df981c5 100755\n--- a/t/t9503/test.pl\n+++ b/t/t9503/test.pl\n@@ -7,14 +7,21 @@ use strict;\n \n use Cwd qw(abs_path);\n use File::Spec;\n+use XML::Parser;\n use Test::More qw(no_plan);\n use Test::WWW::Mechanize::CGI;\n \n-eval { require HTML::Lint };\n+eval { require HTML::Lint; };\n my $lint_installed = !$@;\n diag('HTML::Lint is not installed; no HTML validation tests')\n \tunless $lint_installed;\n \n+eval { require XML::Parser; };\n+my $xml_parser_installed = !$@;\n+diag('XML::Parser is not installed; no tests for well-formed XML')\n+\tunless $xml_parser_installed;\n+\n+\n my $gitweb = File::Spec->catfile('..','..','gitweb','gitweb.perl');\n # the followin two lines of code are workaround for bug in\n # Test::WWW::Mechanize::CGI::cgi_application version up to 0.3\n@@ -24,10 +31,17 @@ $gitweb = File::Spec->rel2abs($gitweb);\n $gitweb = Cwd::abs_path($gitweb);\n \n my $mech = new Test::WWW::Mechanize::CGI;\n+$mech->env(\n+\tGITWEB_CONFIG => $ENV{'GITWEB_CONFIG'},\n+);\n $mech->cgi_application($gitweb);\n-$mech->env(GITWEB_CONFIG => $ENV{'GITWEB_CONFIG'});\n \n-# import config, pedeclaring config variables\n+my $xml_parser;\n+if ($xml_parser_installed) {\n+\t$xml_parser = new XML::Parser;\n+}\n+\n+# import config, predeclaring config variables\n our $site_name = '';\n require_ok($ENV{'GITWEB_CONFIG'})\n \tor diag('Could not load gitweb config; some tests would fail');\n@@ -40,7 +54,7 @@ SKIP: {\n \t\tunless $mech->get_ok('http://localhost/', \"GET $pagename\");\n \t$mech->html_lint_ok('page validates') if $lint_installed;\n \t$mech->title_like(qr!$site_name!,\n-\t\t'title contains $site_name');\n+\t\t\"title contains $site_name\");\n \t$mech->content_contains('./t9503-gitweb-Mechanize.sh test repository', \n \t\t'lists test repository (by description)');\n }\n@@ -87,5 +101,58 @@ $mech->get('http://localhost/?p=.git;a=commit;h=non-existent');\n like($mech->status, qr/40[0-9]/, \"40x status response for $pagename\");\n $mech->html_lint_ok('page validates') if $lint_installed;\n \n+$pagename = 'HEAD commit in non existent repository';\n+$mech->get('http://localhost/?p=non-existent.git;a=commit;h=HEAD');\n+like($mech->status, qr/40[0-9]/, \"40x status response for $pagename\");\n+$mech->html_lint_ok('page validates') if $lint_installed;\n+\n+SKIP: {\n+\t$pagename = 'test repository RSS feed (default)';\n+\t$get_ok = $mech->get_ok('http://localhost/?p=.git;a=rss',\n+\t\t\"GET $pagename\");\n+\tskip \"Could not get $pagename\", 0 + $xml_parser_installed\n+\t\tunless $get_ok;\n+\n+\tif ($xml_parser_installed) {\n+\t\teval {\n+\t\t\t$xml_parser->parse($mech->content());\n+\t\t};\n+\t\tok(! $@, \"$pagename is well formed XML\")\n+\t\t\tor diag($@);\n+\t}\n+}\n+\n+SKIP: {\n+\t$pagename = 'test repository Atom feed (default)';\n+\t$get_ok = $mech->get_ok('http://localhost/?p=.git;a=atom',\n+\t\t\"GET $pagename\");\n+\tskip \"Could not get $pagename\", 0 + $xml_parser_installed\n+\t\tunless $get_ok;\n+\n+\tif ($xml_parser_installed) {\n+\t\teval {\n+\t\t\t$xml_parser->parse($mech->content());\n+\t\t};\n+\t\tok(! $@, \"$pagename is well formed XML\")\n+\t\t\tor diag($@);\n+\t}\n+}\n+\n+SKIP: {\n+\t$pagename = 'list of repositories in OPML format';\n+\t$get_ok = $mech->get_ok('http://localhost/?a=opml',\n+\t\t\"GET $pagename\");\n+\tskip \"Could not get $pagename\", 0 + $xml_parser_installed\n+\t\tunless $get_ok;\n+\n+\tif ($xml_parser_installed) {\n+\t\teval {\n+\t\t\t$xml_parser->parse($mech->content());\n+\t\t};\n+\t\tok(! $@, \"$pagename is well formed XML\")\n+\t\t\tor diag($@);\n+\t}\n+}\n+\n 1;\n __END__\n-- \n1.5.5.3\n"}]}