python: Fix build issues when using "make build_cached"
[omd.git] / t / 20-package_perl-modules.t
blobb76905512406fa4de74c4e3402b668440a8e38f1
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 'Module::Install') { $mod = 'inc::'.$mod; }
43 if($mod eq 'File::ChangeNotify') { next; }
44 if($mod eq 'UNIVERSAL::isa') { next; }
45 if($mod eq 'Filter::exec') { next; } # broken version string
46 if($mod eq 'Sub::Exporter::Progressive') { next; }
47 if($mod eq 'DBD::Oracle') { next; }
48 if($mod eq 'IO') { $version .= " qw/File/"; } # Parameterless "use IO" deprecated at...
49 if($mod =~ m/curl/imx) { next; } # broken
50 if($mod eq 'Term::ReadLine::Gnu') { next; } # removed in ubuntu 10.04
51 if($mod eq 'LWP::Protocol::connect') { next; } # requires IO::Socket::SSL which cannot be included
52 if($mod eq 'Plack::Middleware::RemoveRedundantBody') { $version = ""; } # has broken version
53 if($mod eq 'YAML::LibYAML') { $mod = "YAML::XS"; $version = ""; }
55 my $check = "use $mod";
56 # Use with version doesnt work here, because of weird version numbers
57 $check .= " $version" unless $mod =~ /^(Math::BaseCnv|XML::Tidy)$/;
59 TestUtils::test_command({ cmd => "/bin/su - $site -c 'perl -e \"$check;\"'" });
62 ##################################################
63 for my $file (qw|/*/Class/MethodMaker/scalar.pm /*/Class/MethodMaker/hash.pm /*/Class/MethodMaker/array.pm|) {
64 my $pattern = "/omd/sites/$site/lib/perl5/lib/perl5".$file;
65 my @files = glob($pattern);
66 ok(scalar @files > 0, "found file(s) for pattern: ".$pattern);
67 ok(-s $files[0], $files[0]." must not be empty");
70 ##################################################
71 SKIP: {
72 skip('Author test. Set $ENV{TEST_AUTHOR} to a true value to run.', 4) unless $ENV{TEST_AUTHOR};
73 my $author_tests = [
74 { cmd => "/bin/su - $site -c '/usr/bin/env cpan'", stdin => "notest install Traceroute::Similar\n", like => '/install\s+\-\-\s+OK/' },
76 for my $author_test (@{$author_tests}) {
77 TestUtils::test_command($author_test);
81 ##################################################
82 # cleanup test site
83 TestUtils::remove_test_site($site);
85 done_testing();