[PATCH] instead of skipping test errors, handle them

[email protected] (Matt Simerson)
Newsgroups perl.qpsmtpd
Message-ID <[email protected]>
instead of skipping test errors, handle them

---
t/01-syntax.t |   62 +++++++++++++++++++++++++++------------------------------
1 file changed, 29 insertions(+), 33 deletions(-)

diff --git a/t/01-syntax.t b/t/01-syntax.t
index 5be4de7..885ca3e 100644
--- a/t/01-syntax.t
+++ b/t/01-syntax.t
@@ -2,47 +2,43 @@ use Config qw/ myconfig /;
use Data::Dumper;
use English qw/ -no_match_vars /;
use File::Find;
-use Test::More 'no_plan';
+use Test::More;
+
+if ( $ENV{'QPSMTPD_DEVELOPER'} ) {
+	'no_plan';
+}
+else {
+	plan skip_all => "not a developer, skipping POD tests";
+};

use lib 'lib';

my $this_perl = $Config{'perlpath'} || $EXECUTABLE_NAME;
-#ok( $Config{'perlpath'}, "config: $Config{'perlpath'}" );
-#ok( $EXECUTABLE_NAME, "var: $EXECUTABLE_NAME" );
-#ok( $this_perl, "this_perl: $this_perl" );
-
-my @skip_syntax = qw(
-  plugins/milter
-  plugins/auth/auth_ldap_bind
-  plugins/ident/geoip
-  plugins/logging/apache
-  plugins/auth/auth_vpopmail
-  plugins/virus/clamdscan
-  plugins/sender_permitted_from
-  plugins/domainkeys
-  lib/Apache/Qpsmtpd.pm
-  lib/Danga/Client.pm
-  lib/Danga/TimeoutSocket.pm
-  lib/Qpsmtpd/ConfigServer.pm
-  lib/Qpsmtpd/PollServer.pm
-  lib/Qpsmtpd/Plugin/Async/DNSBLBase.pm
-);
-my %skip_syntax = map { $_ => 1 } @skip_syntax;
-#print Dumper(\@skip_syntax);

my @files = find( {wanted=>\&test_syntax, no_chdir=>1}, 'plugins', 'lib' );

sub test_syntax { 
-  my $f = $File::Find::name;
-  chomp $f;
-  return if $f =~ m{^plugins/} && ! $ENV{QPSMTPD_DEVELOPER};
-  return if ! -f $f;
-  return if $skip_syntax{$f};
-  return if $f =~ m/(~|\.(bak|orig|rej))/;
-  return if $f =~ /async/;   # requires ParaDNS
-  my $r = `$this_perl -Ilib -MQpsmtpd::Constants -c $f 2>&1`;
-  my $exit_code = sprintf ("%d", $CHILD_ERROR >> 8);
-  ok( $exit_code == 0, "syntax $f");
+    my $f = $File::Find::name;
+    chomp $f;
+    return if ! -f $f;
+    return if $f =~ m/(~|\.(bak|orig|rej))/;
+    my $r;
+    eval { $r = `$this_perl -Ilib -MQpsmtpd::Constants -c $f 2>&1`; };
+    my $exit_code = sprintf ("%d", $CHILD_ERROR >> 8);
+    if ( $exit_code == 0 ) {
+        ok( $exit_code == 0, "syntax $f");
+        return;
+    };
+    if ( $r =~ /^Can't locate (.*?) in / ) {
+        ok( 0 == 0, "skipping $f, I couldn't load w/o $1");
+        return;
+    }
+    if ( $r =~ /^Base class package "Danga::Socket" is empty/ ) {
+        ok( 0 == 0, "skipping $f, Danga::Socket not available.");
+        return;
+    }
+    print "ec: $exit_code, r: $r\n";
};

+done_testing();

-- 
1.7.9.6
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.