Merge branch 'master' of mathias-kettner.de:omd
[omd.git] / t / 20-package_perl-modules.t
blob34277717a627df320b2de0252a9d624160ab4992
1 #!/usr/bin/env perl
3 use warnings;
4 use strict;
5 use Test::More;
7 BEGIN {
8 use lib('t');
9 require TestUtils;
10 import TestUtils;
11 use FindBin;
12 use lib "$FindBin::Bin/lib/lib/perl5";
13 use BuildHelper;
16 ##################################################
17 # create our test site
18 my $omd_bin = TestUtils::get_omd_bin();
19 my $site = TestUtils::create_test_site() or TestUtils::bail_out_clean("no further testing without site");
21 ##################################################
22 # execute some checks
23 my $tests = [
24 { cmd => "/bin/su - $site -c '/usr/bin/env cpan.wrapper'", stdin => "yes\n", like => '/cpan\[1\]>/' },
25 { cmd => "/bin/su - $site -c '/usr/bin/env cpan'", stdin => "yes\n", like => '/cpan\[1\]>/' },
27 for my $test (@{$tests}) {
28 TestUtils::test_command($test);
31 ##################################################
32 TestUtils::test_command({ cmd => "/bin/su - $site -c 'perl -e \"use RRDs 1.4004;\"'" });
34 ##################################################
35 for my $tarball (glob("packages/perl-modules/src/*.gz packages/perl-modules/src/*.zip")) {
36 $tarball =~ s/^.*\///mx;
37 my($mod, $version) = BuildHelper::file_to_module($tarball);
38 $mod =~ s/\.pm$//mx;
40 if($mod eq 'Package::DeprecationManager') { $version .= ' -deprecations => { blah => foo }'; }
41 if($mod eq 'Filter::exec') { $version .= " 'test'"; }
42 if($mod eq 'Term::ReadLine::Gnu') { $mod = 'Term::ReadLine; use Term::ReadLine::Gnu' }
43 if($mod eq 'Module::Install') { $mod = 'inc::'.$mod; }
44 if($mod eq 'File::ChangeNotify') { next; }
45 if($mod eq 'UNIVERSAL::isa') { next; }
46 if($mod eq 'Filter::exec') { next; } # broken version string
47 if($mod eq 'Sub::Exporter::Progressive') { next; }
48 if($mod eq 'DBD::Oracle') { next; }
49 if($mod eq 'IO') { $version .= " qw/File/"; } # Parameterless "use IO" deprecated at...
50 if($mod =~ m/curl/imx) { next; } # broken
52 my $check = "use $mod";
53 # Use with version doesnt work here, because of weird version numbers
54 $check .= " $version" unless $mod =~ /^(Math::BaseCnv|XML::Tidy)$/;
56 TestUtils::test_command({ cmd => "/bin/su - $site -c 'perl -e \"$check;\"'" });
59 ##################################################
60 SKIP: {
61 skip('Author test. Set $ENV{TEST_AUTHOR} to a true value to run.', 4) unless $ENV{TEST_AUTHOR};
62 my $author_tests = [
63 { cmd => "/bin/su - $site -c '/usr/bin/env cpan'", stdin => "notest install Traceroute::Similar\n", like => '/install\s+\-\-\s+OK/' },
65 for my $author_test (@{$author_tests}) {
66 TestUtils::test_command($author_test);
70 ##################################################
71 # cleanup test site
72 TestUtils::remove_test_site($site);
74 done_testing();