File: 00-all-usable.t

package info (click to toggle)
libpdf-builder-perl 3.027-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,992 kB
  • sloc: perl: 107,532; makefile: 10
file content (118 lines) | stat: -rw-r--r-- 3,359 bytes parent folder | download
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/usr/bin/perl
use warnings;
use strict;

use Test::More;
use File::Find;
use version;

# minimum versions, **if used**
my $GrTFversion  = 19;       # minimum version of Graphics::TIFF
my $HBShaperVer  = 0.024;    # minimum version of HarfBuzz::Shaper
my $LpngVersion  = 0.57;     # minimum version of Image::PNG::Libpng
my $TextMarkdown = 1.000031; # minimum version of Text::Markdown
my $HTMLTreeBldr = 5.07;     # minimum version of HTML::TreeBuilder
my $PodSimpleXHTML = 3.45;   # minimum version of Pod::Simple::XHTML
my $SVGPDFver    = 0.087;    # minimum version of SVGPDF

# Test all of the modules to make sure that a simple "use Module"
# won't result in a crash.

# first, build files list of all .pm under lib/
my @files;
find(\&add_to_files, 'lib');

sub add_to_files {
    return unless -f $_;
    return unless $_ =~ /\.pm$/;
    ### 3 currently disabled
    return if ($_ =~ m/CCITTFaxDecode\.pm$/);
    return if ($_ =~ m/Reader\.pm$/);
    return if ($_ =~ m/Writer\.pm$/);
    ###
    push @files, $File::Find::name;
    return;
}

plan tests => scalar @files;

# test each one, skipping over certain name patterns
my @opt_modules;

my $has_GT = 1;
my $has_IPL = 1;
my $rc;

# check for Graphics::TIFF installed, and if so, run use test
$rc = eval {
    require Graphics::TIFF;
    1;
};
if (!defined $rc) { $rc = 0; }  # else is 1
if ($rc) {
    # installed but not up to date?
    if (version::parse($Graphics::TIFF::VERSION) <
        version::parse($GrTFversion)) { $rc = 0; }
}
$has_GT = $rc;
my $dummy = $has_GT;

# check for Image::PNG::Libpng installed, and if so, run use test
$rc = eval {
    require Image::PNG::Libpng;
    1;
};
if (!defined $rc) { $rc = 0; }  # else is 1
if ($rc) {
    # installed but not up to date?
    if (version::parse($Image::PNG::Libpng::VERSION) <
        version::parse($LpngVersion)) { $rc = 0; }
}
$has_IPL = $rc;
$dummy = $has_IPL;

foreach my $file (@files) {
    ($file) = $file =~ m|^lib/(.*)\.pm$|;
    $file =~ s|/|::|g;
    if ($file =~ /Win32/) {  # require Windows system to run
	                     # not currently under lib/ anyway
#	"SKIP Windows module(s) not currently used"
#       next;
    }
    if ($file =~ /_GT$/) {   # require Graphics::TIFF be installed
	                     # but rarely is on test platforms
	# check for Graphics::TIFF installed, and if so, run use test
       	if (!$has_GT) {
print "$file failed\n";
		push @opt_modules, $file;
 		next;
	}
	# else fall through to use test
    }
    if ($file =~ /_IPL$/) {  # require Image::PNG::Libpng be installed
	                     # but rarely is on test platforms
	# check for Image::PNG::Libpng installed, and if so, run use test
       	if (!$has_IPL) {
		push @opt_modules, $file;
 		next;
	}
	# else fall through to use test
    }
    # HarfBuzz::Shaper is built into Content.pm, doesn't have its own module
    # Text::Markdown is built into Content/Text.pm, doesn't have its own module
    # HTML::TreeBuilder is built into Content/Text.pm, doesn't have its own module
    # Pod::Simple::XHTML is built into buildDoc.pl, doesn't have its own module
    use_ok($file);
}

# special message and automatic pass for skipped-over modules
TODO: {
    local $TODO = q{skipped due to optional library not installed};

    foreach my $file (@opt_modules) {
print "skipped: $file\n";
	    ok(1, $file);
    }
}

1;