File: 00compile.t

package info (click to toggle)
libtest-simple-perl 1.302211-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,972 kB
  • sloc: perl: 19,894; makefile: 7
file content (48 lines) | stat: -rw-r--r-- 1,118 bytes parent folder | download | duplicates (6)
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
43
44
45
46
47
48
#!/usr/bin/perl -w

BEGIN {
    if( $ENV{PERL_CORE} ) {
        @INC = ('../lib', 'lib');
    }
    else {
        unshift @INC, 't/lib';
    }
}
chdir 't';

use Test::More;

my $Has_Test_Pod;
BEGIN {
    $Has_Test_Pod = eval 'use Test::Pod 0.95; 1';
}

chdir "..";
my $manifest = "MANIFEST";
open(my $manifest_fh, "<", $manifest) or plan(skip_all => "Can't open $manifest: $!");
my @modules = map  { m{^lib/(\S+)}; $1 } 
              grep { m{^lib/Test/\S*\.pm} } 
              grep { !m{/t/} } <$manifest_fh>;

chomp @modules;
close $manifest_fh;

chdir 'lib';
plan tests => scalar @modules * 2;
foreach my $file (@modules) {
    # Make sure we look at the local files and do not reload them if
    # they're already loaded.  This avoids recompilation warnings.
    local @INC = @INC;
    unshift @INC, ".";
    my @warnings;
    ok eval {
        local $SIG{__WARN__} = sub { push @warnings => @_ };
        require($file);
        1
    } or diag "require $file failed.", "\n", @warnings, "\n", $@;

    SKIP: {
        skip "Test::Pod not installed", 1 unless $Has_Test_Pod;
        pod_file_ok($file);
    }
}