On Wed, Jan 09, 2008 at 08:04:38PM +0100, Simon Bertrang wrote:
> On Sat, Oct 06, 2007 at 06:02:59PM +0200, Simon Bertrang wrote:
> > On Sat, Oct 06, 2007 at 05:36:25PM +0200, Marc Espie wrote:
> > > On Sat, Oct 06, 2007 at 02:01:18PM +0200, Simon Bertrang wrote:
> > > > This hasn't changed but i added a new variable CPAN_REPORT_FROM to set
> > > > the report sender address.  Defaults to ${MAINTAINER}.
> > > > Further i changed the report file name from ${DISTNAME} to ${PKGNAME}.
> > > 
> > > I disagree about this. CPAN_REPORT_FROM should not default. In fact, it
> > > should error out if it's not set.
> > > 
> > > You should have to set it to whomever is running the tests. Anything else
> > > is totally bogus.
> > 
> > Agreed.  Updated diffs attached.
> > 
> 
> With feedback from [EMAIL PROTECTED]
> 

Here's a new diff incorporating some feedback from merdely@ who pointed
out to me that we create PLIST_DB already in a similar way.
I like it as it saves another bit of time.

More feedback and/or can i commit it like this?

Regards,
Simon


Index: build/cpanreport
===================================================================
RCS file: build/cpanreport
diff -N build/cpanreport
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ build/cpanreport    15 Jan 2008 21:35:41 -0000
@@ -0,0 +1,81 @@
+#!/usr/bin/perl
+# $OpenBSD$
+# Copyright (c) 2007, 2008 Simon Bertrang <[EMAIL PROTECTED]>
+# 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 strict;
+use Getopt::Std qw(getopts);
+use Test::Reporter;
+
+my $distname;
+my $log;
+my %opts = (
+       'f'     => $ENV{'REGRESS_LOGFILE'} || '-',
+       'g'     => '',
+       's'     => $ENV{'CPAN_REPORT_FROM'} || '',
+);
+my $reporter;
+
+sub usage {
+       die("usage: $0 [-f regress.log] -s address" .
+           " -g fail|pass|na|unknown distname\n");
+}
+
+unless (getopts('f:g:s:', \%opts)) {
+       usage();
+}
+
+unless ($opts{'g'} && $opts{'g'} =~ m/^(?:pass|fail|na|unknown)$/o) {
+       usage();
+}
+
+unless ($distname = shift(@ARGV)) {
+       usage();
+}
+
+unless ($opts{'g'} eq 'pass') {
+       my $fh;
+
+       unless (open($fh, $opts{'f'})) {
+               die("$0: $!: $opts{'f'}\n");
+       }
+
+       {
+               local($/) = undef;
+               $log = <$fh>;
+       }
+
+       close($fh);
+}
+
+$reporter = Test::Reporter->new();
+
+$reporter->from($opts{'s'});
+$reporter->grade($opts{'g'});
+$reporter->distribution($distname);
+
+if ($log) {
+       $reporter->comments($log);
+}
+
+$reporter->write(\*STDOUT);
+
Index: mk/cpan.port.mk
===================================================================
RCS file: /cvs/ports/infrastructure/mk/cpan.port.mk,v
retrieving revision 1.4
diff -u -p -r1.4 cpan.port.mk
--- mk/cpan.port.mk     25 Nov 2006 13:14:40 -0000      1.4
+++ mk/cpan.port.mk     15 Jan 2008 21:35:41 -0000
@@ -21,3 +21,30 @@ PKG_ARCH?=   * 
 REGRESS_DEPENDS+=::devel/p5-Test-Pod \
                 ::devel/p5-Test-Pod-Coverage
 .endif
+
+CPAN_REPORT?=  No
+
+.if ${CPAN_REPORT:L} == "yes"
+REGRESS_DEPENDS+=::devel/p5-Test-Reporter
+REGRESS_FLAGS+=        TEST_VERBOSE=1
+.  if !defined(CPAN_REPORT_DB)
+ERRORS+=       "Fatal: CPAN_REPORT_DB must point to a directory"
+.  endif
+.  if !defined(CPAN_REPORT_FROM) || empty(CPAN_REPORT_FROM)
+ERRORS+=       "Fatal: CPAN_REPORT_FROM needs an email address"
+.  endif
+
+CPANTEST=      ${PORTSDIR}/infrastructure/build/cpanreport
+CPANTEST_FLAGS=        -f ${REGRESS_LOGFILE} -s ${CPAN_REPORT_FROM:Q} 
${DISTNAME} \
+                       > ${CPAN_REPORT_DB}/${PKGNAME}
+CPANTEST_PASS= -g pass ${CPANTEST_FLAGS}
+CPANTEST_FAIL= -g fail ${CPANTEST_FLAGS}
+
+post-regress:
+       @mkdir -p ${CPAN_REPORT_DB}
+       @if grep -q FAILED ${REGRESS_LOGFILE}; then \
+               ${CPANTEST} ${CPANTEST_FAIL}; \
+               exit 1; \
+       else ${CPANTEST} ${CPANTEST_PASS}; fi
+
+.endif

Reply via email to