Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

test single-entry feed

  • Loading branch information...
commit dbf0f7876be991674290f5503ea1dc6148520938 1 parent 053db1b
Jozef Kutej authored
1  Build.PL
View
@@ -24,6 +24,7 @@ my $builder = Module::Build::SysPath->new(
'TAP::Harness' => 0,
'Getopt::Long' => 0,
'Pod::Usage' => 0,
+ 'YAML::Syck' => 0,
},
configure_requires => {
'Module::Build::SysPath' => 0.08,
3  conf/test-daily/test-daily.conf
View
@@ -1,5 +1,6 @@
[main]
-static_prefix=/test-daily/
+site_prefix=/test-daily/
+site_hostname=localhost
#[tt]
#INCLUDE_PATH=/usr/share/test-daily/tt-lib
64 lib/Test/Daily.pm
View
@@ -53,6 +53,7 @@ use Template::Constants qw( :debug );
use TAP::Formatter::HTML '0.08';
use TAP::Harness;
use JSON::Util;
+use YAML::Syck ();
our $VERSION = '0.02';
@@ -98,10 +99,22 @@ has 'ttdir' => (
default => sub { dir($_[0]->datadir, 'tt') },
lazy => 1,
);
-has 'static_prefix' => (
+has 'ttlibdir' => (
+ is => 'rw',
+ isa => 'Path::Class::Dir',
+ default => sub { dir($_[0]->datadir, 'tt-lib') },
+ lazy => 1,
+);
+has 'site_prefix' => (
+ is => 'rw',
+ isa => 'Str',
+ default => sub { $_[0]->config->{'main'}->{'site_prefix'} || '/test-server' },
+ lazy => 1,
+);
+has 'site_hostname' => (
is => 'rw',
isa => 'Str',
- default => sub { $_[0]->config->{'main'}->{'static_prefix'} || '/test-server' },
+ default => sub { $_[0]->config->{'main'}->{'site_hostname'} || 'localhost' },
lazy => 1,
);
has 'tt' => (
@@ -189,15 +202,18 @@ sub _process {
my $self = shift;
my $template = shift or die 'set template parameter';
my $out_filename = shift or die 'set out_filename parameter';
+ my $more_tt_args = shift || {};
my $tt = $self->tt;
$self->tt->process(
$template,
{
- 'folders' => [ $self->_all_folders ],
- 'ttdir' => $self->ttdir,
- 'json' => JSON::Util->new(),
+ 'folders' => [ $self->_all_folders ],
+ 'ttdir' => $self->ttdir,
+ 'ttlibdir' => $self->ttlibdir,
+ 'json' => JSON::Util->new(),
+ %{$more_tt_args},
},
$out_filename,
) || die $self->tt->error(), "\n";;
@@ -238,7 +254,7 @@ sub update_project_makefile {
my $self = shift;
my $folder = shift or die 'pass folder argument';
chdir($folder);
- $self->_process('Makefile-project.tt2', 'Makefile');
+ $self->_process('Makefile-project.tt2', 'Makefile', { 'curfolder' => $folder });
}
=head2 update_test_makefile($folder)
@@ -246,10 +262,11 @@ sub update_project_makefile {
=cut
sub update_test_makefile {
- my $self = shift;
- my $folder = shift or die 'pass folder argument';
+ my $self = shift;
+ my $folder = shift or die 'pass folder argument';
+ my $project = shift or die 'pass project name';
chdir($folder);
- $self->_process('Makefile-test.tt2', 'Makefile', @_);
+ $self->_process('Makefile-test.tt2', 'Makefile', { 'curfolder' => $folder, 'project' => $project });
}
=head2 update_test_summary
@@ -262,8 +279,8 @@ sub update_test_summary {
my @tests = glob( 't/*.t' );
my $fmt = TAP::Formatter::HTML->new;
$fmt
- ->js_uris([$self->config->{'main'}->{'static_prefix'}.'_td/jquery-1.3.2.js', $self->config->{'main'}->{'static_prefix'}.'_td/default_report.js' ])
- ->css_uris([$self->config->{'main'}->{'static_prefix'}.'_td/default_page.css', $self->config->{'main'}->{'static_prefix'}.'_td/default_report.css'])
+ ->js_uris([$self->config->{'main'}->{'site_prefix'}.'_td/jquery-1.3.2.js', $self->config->{'main'}->{'site_prefix'}.'_td/default_report.js' ])
+ ->css_uris([$self->config->{'main'}->{'site_prefix'}.'_td/default_page.css', $self->config->{'main'}->{'site_prefix'}.'_td/default_report.css'])
->inline_css('')
->force_inline_css(0)
->inline_js('');
@@ -281,7 +298,10 @@ sub update_test_summary {
# write test summary
JSON::Util->encode(
- { map { $_ => [ $aggregate->$_ ] } @aggregate_methods },
+ {
+ (map { $_ => [ $aggregate->$_ ] } @aggregate_methods),
+ 'meta' => YAML::Syck::LoadFile('meta.yml'),
+ },
'summary.json'
);
@@ -319,6 +339,26 @@ sub run_make {
system('cd '.$self->webdir->stringify.'; make'.($what ? ' '.$what : '')) and die $!;
}
+=head2 summary2rssfeed
+
+=cut
+
+sub summary2rssfeed {
+ my $self = shift;
+ my $path = shift;
+ my $title = $path;
+ $title =~ s{/}{_};
+
+ $self->_process(
+ 'summary2rssfeed.tt2',
+ 'rss.xml',
+ {
+ 'title' => $title,
+ 'link' => 'http://'.$self->site_hostname.$self->site_prefix.$path.'/',
+ }
+ );
+}
+
'hu?';
3  script/test-daily
View
@@ -52,11 +52,12 @@ sub main {
when ('tarball') { $td->extract_tarball($what); }
when ('site-makefile') { $td->update_site_makefile; }
when ('project-makefile') { $td->update_project_makefile($what); }
- when ('test-makefile') { $td->update_test_makefile($what); }
+ when ('test-makefile') { $td->update_test_makefile($what, @ARGV); }
when ('test-summary') { $td->update_test_summary($what); }
when ('project-summary') { $td->update_project_summary(); }
when ('site-summary') { $td->update_site_summary(); }
when ('make') { $td->run_make($what); }
+ when ('summary2rssfeed') { $td->summary2rssfeed($what); }
default { pod2usage; }
}
25 share/test-daily/tt-lib/atom.tt2
View
@@ -0,0 +1,25 @@
+[% USE date -%]
+<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+ <title>[% title %]</title>
+ <link href="[% link %]"/>
+ <updated>[% date.format(date.now, '%Y-%m-%dT%H:%M:%S') %]</updated>
+ <author>
+ <name>Test::Daily</name>
+ </author>
+
+[% FOREACH id IN ids -%]
+ <id>[% id %]</id>
+[% END -%]
+
+[% FOREACH entry IN entries -%]
+ <entry>
+ <title>[% entry.title %]</title>
+ <link href="[% entry.link %]"/>
+ <id>[% entry.id %]</id>
+ <updated>[% entry.update %]</updated>
+ <summary>[% entry.summary %]</summary>
+ </entry>
+[% END -%]
+
+</feed>
2  share/test-daily/tt/Makefile-project.tt2
View
@@ -7,7 +7,7 @@ index.html: [% ttdir %]/project.tt2 [% FOREACH test IN folders; "$test/index.htm
[% FOREACH test IN folders; %]
# make Makefile for test
[% test %]/Makefile: [% ttdir %]/Makefile-test.tt2
- test-daily test-makefile [% test %]
+ test-daily test-makefile [% test %] [% curfolder %]
# make index.html
[% test %]/index.html: [% test %]/Makefile
8 share/test-daily/tt/Makefile-test.tt2
View
@@ -1,9 +1,15 @@
all: index.html
# index file
-index.html: meta.yml
+index.html: summary.json rss.xml
+ touch index.html # index.html is created together with summary.json
+
+summary.json: meta.yml
test-daily test-summary
+rss.xml: summary.json [% ttdir %]/summary2rssfeed.tt2 [% ttlibdir %]/atom.tt2
+ test-daily summary2rssfeed [% "${project}/${curfolder}" %]
+
# clean up the mess
clean:
rm -f index.html index.html-new summary.json
11 share/test-daily/tt/summary2rssfeed.tt2
View
@@ -0,0 +1,11 @@
+[% USE date -%]
+[% summary = json.decode("summary.json") -%]
+[% ids = [ title ] -%]
+[% entries = [{
+ 'title' => "${summary.get_status.0} ${title}",
+ 'link' => link,
+ 'id' => title,
+ 'update' => date.format(summary.meta.stop_time, '%Y-%m-%dT%H:%M:%S'),
+ 'summary' => title,
+}] -%]
+[% INCLUDE atom.tt2 -%]
Please sign in to comment.
Something went wrong with that request. Please try again.