All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org, Lea Wiemann <lewiemann@gmail.com>
Subject: [RFC/PATCH (WIP)] gitweb: Check that RSS, Atom and OPML output is well formed XML
Date: Tue, 17 Jun 2008 09:22:04 +0200	[thread overview]
Message-ID: <200806170922.05348.jnareb@gmail.com> (raw)

NOTE: This does not check that RSS and Atom feeds (and OPML outline)
conform to the specification (which might be given as DTD, XSD = XML
Schema, Relax-NG schema,...), only that it parses without errors.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
To check Atom and RSS feeds against specification we could use script
version of W3C Feed Validator (http://validator.w3.org/feed/), or
try to validate against XML Schema (XSD) which is default schema
language for RSS, or against Relax-NG schema which is default schema
language for Atom.

 t/t9503/test.pl             |   75 ++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 72 insertions(+), 5 deletions(-)

diff --git a/t/t9503/test.pl b/t/t9503/test.pl
index 7d081b9..df981c5 100755
--- a/t/t9503/test.pl
+++ b/t/t9503/test.pl
@@ -7,14 +7,21 @@ use strict;
 
 use Cwd qw(abs_path);
 use File::Spec;
+use XML::Parser;
 use Test::More qw(no_plan);
 use Test::WWW::Mechanize::CGI;
 
-eval { require HTML::Lint };
+eval { require HTML::Lint; };
 my $lint_installed = !$@;
 diag('HTML::Lint is not installed; no HTML validation tests')
 	unless $lint_installed;
 
+eval { require XML::Parser; };
+my $xml_parser_installed = !$@;
+diag('XML::Parser is not installed; no tests for well-formed XML')
+	unless $xml_parser_installed;
+
+
 my $gitweb = File::Spec->catfile('..','..','gitweb','gitweb.perl');
 # the followin two lines of code are workaround for bug in
 # Test::WWW::Mechanize::CGI::cgi_application version up to 0.3
@@ -24,10 +31,17 @@ $gitweb = File::Spec->rel2abs($gitweb);
 $gitweb = Cwd::abs_path($gitweb);
 
 my $mech = new Test::WWW::Mechanize::CGI;
+$mech->env(
+	GITWEB_CONFIG => $ENV{'GITWEB_CONFIG'},
+);
 $mech->cgi_application($gitweb);
-$mech->env(GITWEB_CONFIG => $ENV{'GITWEB_CONFIG'});
 
-# import config, pedeclaring config variables
+my $xml_parser;
+if ($xml_parser_installed) {
+	$xml_parser = new XML::Parser;
+}
+
+# import config, predeclaring config variables
 our $site_name = '';
 require_ok($ENV{'GITWEB_CONFIG'})
 	or diag('Could not load gitweb config; some tests would fail');
@@ -40,7 +54,7 @@ SKIP: {
 		unless $mech->get_ok('http://localhost/', "GET $pagename");
 	$mech->html_lint_ok('page validates') if $lint_installed;
 	$mech->title_like(qr!$site_name!,
-		'title contains $site_name');
+		"title contains $site_name");
 	$mech->content_contains('./t9503-gitweb-Mechanize.sh test repository', 
 		'lists test repository (by description)');
 }
@@ -87,5 +101,58 @@ $mech->get('http://localhost/?p=.git;a=commit;h=non-existent');
 like($mech->status, qr/40[0-9]/, "40x status response for $pagename");
 $mech->html_lint_ok('page validates') if $lint_installed;
 
+$pagename = 'HEAD commit in non existent repository';
+$mech->get('http://localhost/?p=non-existent.git;a=commit;h=HEAD');
+like($mech->status, qr/40[0-9]/, "40x status response for $pagename");
+$mech->html_lint_ok('page validates') if $lint_installed;
+
+SKIP: {
+	$pagename = 'test repository RSS feed (default)';
+	$get_ok = $mech->get_ok('http://localhost/?p=.git;a=rss',
+		"GET $pagename");
+	skip "Could not get $pagename", 0 + $xml_parser_installed
+		unless $get_ok;
+
+	if ($xml_parser_installed) {
+		eval {
+			$xml_parser->parse($mech->content());
+		};
+		ok(! $@, "$pagename is well formed XML")
+			or diag($@);
+	}
+}
+
+SKIP: {
+	$pagename = 'test repository Atom feed (default)';
+	$get_ok = $mech->get_ok('http://localhost/?p=.git;a=atom',
+		"GET $pagename");
+	skip "Could not get $pagename", 0 + $xml_parser_installed
+		unless $get_ok;
+
+	if ($xml_parser_installed) {
+		eval {
+			$xml_parser->parse($mech->content());
+		};
+		ok(! $@, "$pagename is well formed XML")
+			or diag($@);
+	}
+}
+
+SKIP: {
+	$pagename = 'list of repositories in OPML format';
+	$get_ok = $mech->get_ok('http://localhost/?a=opml',
+		"GET $pagename");
+	skip "Could not get $pagename", 0 + $xml_parser_installed
+		unless $get_ok;
+
+	if ($xml_parser_installed) {
+		eval {
+			$xml_parser->parse($mech->content());
+		};
+		ok(! $@, "$pagename is well formed XML")
+			or diag($@);
+	}
+}
+
 1;
 __END__
-- 
1.5.5.3

                 reply	other threads:[~2008-06-17  7:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200806170922.05348.jnareb@gmail.com \
    --to=jnareb@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=lewiemann@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.