File: 01-syntax.t

package info (click to toggle)
qpsmtpd 0.94-8
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,340 kB
  • sloc: perl: 17,176; sh: 543; makefile: 186; sql: 100
file content (42 lines) | stat: -rw-r--r-- 1,058 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use Config qw/ myconfig /;
use Data::Dumper;
use English qw/ -no_match_vars /;
use File::Find;
use Test::More;

if (!$ENV{'QPSMTPD_DEVELOPER'}) {
    plan skip_all => "not a developer, skipping POD tests";
}

use lib 'lib';

my $this_perl = $Config{'perlpath'} || $EXECUTABLE_NAME;

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

sub test_syntax {
    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();