I like this.

On Sat, Jul 21, 2007 at 04:52:08PM +0200, Simon Bertrang wrote:
> Hi porters,
> a few weeks ago steven@ sent a diff for cpan.port.mk that provides
> regress reporting functionality via p5-Test-Reporter.  When i saw that
> the cpantest script directly sends out emails i stepped in and changed
> a few bits to write the report mail into a file.
> Unfortunately the output was not correct and additionally the existing
> code of cpantest made my eys bleed, so i wrote build/cpanreport.
> It's very simple, still depends on p5-Test-Reporter but does the job.
> I've got a bit feedback already but i want more solid replies before i
> commit this.
> 
> To use it, apply the diff, set CPAN_REPORT=Yes, create a directory for
> the reports (i.e. /usr/ports/mystuff/reports) and set CPAN_REPORT_DB to
> point to it.
> With this all perl ports using the cpan.port.mk will write files you can
> email to [EMAIL PROTECTED] after you `make regress'.
> 
> This way we can dispatch build testing reports to prove problems and
> have a better ground to submit upstream patches.
> 
> Please let me hear your oppinions and/or {,dis}agreements.
> 
> Regards,
> Simon

> diff -urNx CVS -x .#* -x *.orig ./build/cpanreport 
> /usr/ports/infrastructure/build/cpanreport
> --- ./build/cpanreport        Thu Jan  1 01:00:00 1970
> +++ /usr/ports/infrastructure/build/cpanreport        Thu Jul  5 20:18:04 2007
> @@ -0,0 +1,84 @@
> +#!/usr/bin/perl
> +# $OpenBSD$
> +# Copyright (c) 2007 Simon Bertrang.  All rights reserved.
> +# Redistribution and use in source and binary forms, with or without
> +# modification, are permitted provided that the following conditions
> +# are met:
> +# 1. Redistributions of code must retain the above copyright
> +#    notice, this list of conditions and the following disclaimer.
> +# 2. Neither the name of OpenBSD nor the names of its contributors
> +#    may be used to endorse or promote products derived from this software
> +#    without specific prior written permission.
> +#
> +# THIS SOFTWARE IS PROVIDED BY ITS AUTHOR AND THE OpenBSD project ``AS IS'' 
> AND
> +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> +# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
> +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
> +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
> +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
> +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
> +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
> +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> +# SUCH DAMAGE.
> +
> +use Getopt::Std qw(getopts);
> +use Test::Reporter;
> +
> +my $distname;
> +my $fh;
> +my $log;
> +my %opts = (
> +     'd'     => $ENV{'CPAN_REPORT_DB'} || '.',
> +     'f'     => $ENV{'REGRESS_LOGFILE'} || '',
> +     'g'     => '',
> +);
> +my $reporter;
> +
> +sub usage {
> +     die("usage: $0 [-d logdir]" .
> +         " [-f regress.log]" .
> +         " -g fail|pass|na|unknown distname\n");
> +}
> +
> +unless (getopts('d:f:g:', \%opts)) {
> +     usage();
> +}
> +
> +unless ($opts{'g'} && $opts{'g'} =~ m/^(?:pass|fail|na|unknown)$/o) {
> +     usage();
> +}
> +
> +unless ($distname = shift(@ARGV)) {
> +     usage();
> +}
> +
> +if ($opts{'f'}) {
> +     unless (open($fh, '<', $opts{'f'})) {
> +             die("$0: $!: $opts{'f'}\n");
> +     }
> +     close(STDIN);
> +}
> +else {
> +     $fh = \*STDIN;
> +}
> +
> +{
> +     local($/) = undef;
> +     $log = <$fh>;
> +}
> +close($fh);
> +
> +unless (open($fh, '>', $opts{'d'} . "/$distname")) {
> +     die("$0: $!: ", $opts{'d'}, "/$distname\n");
> +}
> +
> +$reporter = Test::Reporter->new();
> +
> +$reporter->grade($opts{'g'});
> +$reporter->distribution($distname);
> +$reporter->comments($log);
> +
> +$reporter->write($fh);
> +
> +close($fh);
> Binary files ./mk/.cpan.port.mk.swp and 
> /usr/ports/infrastructure/mk/.cpan.port.mk.swp differ
> diff -urNx CVS -x .#* -x *.orig ./mk/cpan.port.mk 
> /usr/ports/infrastructure/mk/cpan.port.mk
> --- ./mk/cpan.port.mk Sat Nov 25 14:14:40 2006
> +++ /usr/ports/infrastructure/mk/cpan.port.mk Thu Jul  5 20:41:33 2007
> @@ -21,3 +21,20 @@
>  REGRESS_DEPENDS+=::devel/p5-Test-Pod \
>                ::devel/p5-Test-Pod-Coverage
>  .endif
> +
> +.if defined(CPAN_REPORT)
> +REGRESS_DEPENDS+=::devel/p5-Test-Reporter
> +REGRESS_FLAGS+=      TEST_VERBOSE=1
> +.  if empty(CPAN_REPORT_DB) || !exists(${CPAN_REPORT_DB})
> +ERRORS+=     "Fatal: CPAN_REPORT_DB must point to a directory"
> +.  endif
> +CPAN_REPORTER=               ${PORTSDIR}/infrastructure/build/cpanreport
> +CPAN_REPORTER_FLAGS= -d ${CPAN_REPORT_DB} -f ${REGRESS_LOGFILE} ${DISTNAME}
> +CPAN_REPORTER_PASS=  -g pass ${CPAN_REPORTER_FLAGS}
> +CPAN_REPORTER_FAIL=  -g fail ${CPAN_REPORTER_FLAGS}
> +
> +post-regress:
> +     @if grep 'All tests successful' ${REGRESS_LOGFILE}; then \
> +             ${CPAN_REPORTER} ${CPAN_REPORTER_PASS}; \
> +     else ${CPAN_REPORTER} ${CPAN_REPORTER_FAIL}; fi
> +.endif

Reply via email to