????
Current Path : /bin/ |
Current File : //bin/perldepgentest |
#!/usr/bin/perl eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' if 0; # not running under some shell use strict; use warnings; use Test::More tests => 20; use File::Path (); use File::ShareDir (); use File::Spec (); use File::Temp (); use RPM2 (); my $datadir = $ARGV[0]; if (!defined $datadir) { $datadir = File::ShareDir::dist_dir('DepGen-Perl-Tests'); } $datadir = File::Spec->rel2abs($datadir); ok(-d $datadir, 'Directory with testing data found'); my $sources = 'package'; my $spec = File::Spec->catfile($datadir, 'package.spec'); my $dir = File::Temp::tempdir(CLEANUP => 1); ok(-d $dir, 'Temporary directory '. $dir .' created'); my $sourcetar = File::Spec->catfile($dir, 'package.tar'); ok(!system('tar', '-C', $datadir, '-cf', $sourcetar, $sources), 'Sources have been packed into a tar archive'); # XXX: rpmbuild checks for installed dependencies by default. Opening RPM # database is not reentrant. Disable it with --nodeps. my @command = ( 'rpmbuild', '--define', '_topdir ' . $dir, '--define', '_sourcedir ' . $dir, '--define', '_specdir ' . $dir, '--define', '_builddir ' . $dir, '--define', '_srcrpmdir ' . $dir, '--define', '_rpmdir ' . $dir, '-bb', '--nodeps', $spec); ok(!system(@command), 'Build a package'); # XXX: local rpmbuild puts packages into arch-specific subdirectory, koji does # not. I don't know where is the knob, so search bot of them. my @rpms = glob(File::Spec->catfile($dir, '*.rpm')); push @rpms, glob(File::Spec->catfile($dir, '*', '*.rpm')); ok(@rpms, 'Binary packages have been produced'); my @requires = (); my @provides = (); for (@rpms) { my $headers = RPM2->open_package($_); push @requires, $headers->tag('REQUIRENAME'); push @provides, $headers->tag('PROVIDENAME'); } ok(@requires, 'Requires symbols exist'); ok(@provides, 'Provides symbol exist'); ok(grep(/libc\.so/, @requires), 'System shared library is required'); SKIP: { skip('XS modules are linked against libperl.so since distributed perl 5.18', 1) unless $] >= 5.018; ok(grep(/libperl.so.\d.\d+/, @requires), 'libperl.so is required'); } ok(!grep(/VersionCompare\.so/, @requires), 'Private library is not provided'); ok(!grep(/perl\(VMS/, @requires), 'VMS modules are not required'); ok(!grep(/perl\(Win32/, @requires), 'Win32 modules are not required'); ok(grep(/perl\(Test\)/, @provides), 'Test is provided'); ok(!grep(/perl\(Test::Private\)/, @provides), 'Test::Private excluded from provides'); ok(!grep(/perl\(VMS/, @provides), 'VMS modules are not provided'); ok(!grep(/perl\(Win32/, @provides), 'Win32 modules are not provided'); ok(!grep(/perl\(DB\)/, @provides), 'DB module is not provided'); ok(!grep(/perl\(UNIVERSAL\)/, @provides), 'UNIVERSAL module is not provided'); ok(!grep(/perl\(Documentation/, @requires), 'Module from documentation is not required'); ok(!grep(/perl\(Documentation/, @provides), 'Module from documentation is not provided'); __END__ =encoding utf8 =head1 NAME perldepgentest - Check that rpmbuild generates dependencies correctly =head1 SYNOPSIS B<perldepgentest> [I<DIRECTORY>] =head1 DESCRIPTION This is a regression test suite for Perl RPM dependency generator. The only optional argument overrides directory with testing data. See L<http://permalink.gmane.org/gmane.linux.redhat.fedora.devel/187548> for discussion about rpmbuild reentrancy. =head1 AUTHOR Petr Písař <ppisar@redhat.com> =head1 COPYING Copyright © 2013 Petr Písař <ppisar@redhat.com> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. =cut