Package tests

This commit is contained in:
Jitka Plesnikova 2022-02-09 14:10:44 +01:00
parent fece4ec2c0
commit 6f7ffb24ee
7 changed files with 137 additions and 2 deletions

1
.fmf/version Normal file
View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,26 @@
From 89b13baf1d46e4fb10023af30ef305efec4fd603 Mon Sep 17 00:00:00 2001
From: Andreas Koenig <andk@cpan.org>
Date: Wed, 12 Jan 2022 21:53:35 +0100
Subject: [PATCH 2/2] s,/dev/null,$devnull,
- another thanks to Tomas Hoger for spotting that
---
lib/CPAN/Distribution.pm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/CPAN/Distribution.pm b/lib/CPAN/Distribution.pm
index d837b8ad..6ca1b434 100644
--- a/lib/CPAN/Distribution.pm
+++ b/lib/CPAN/Distribution.pm
@@ -1554,7 +1554,7 @@ sub CHECKSUM_check_file {
my $devnull = File::Spec->devnull;
my $gpg = $CPAN::Config->{gpg} or
$CPAN::Frontend->mydie("Your configuration suggests that you do not have 'gpg' installed. This is needed to verify checksums with the config variable 'check_sigs' on. Please configure it with 'o conf init gpg'");
- my $system = qq{"$gpg" --verify --batch --no-tty --output "$tempfile" "$chk_file" 2> "/dev/null"};
+ my $system = qq{"$gpg" --verify --batch --no-tty --output "$tempfile" "$chk_file" 2> "$devnull"};
0 == system $system or $CPAN::Frontend->mydie("gpg run was failing, cannot continue: $system");
open $fh, $tempfile or $CPAN::Frontend->mydie("Could not open $tempfile: $!");
local $/;
--
2.34.1

View File

@ -0,0 +1,29 @@
From 7d4d5e32bcd9b75f7bf70a395938a48ca4a06d25 Mon Sep 17 00:00:00 2001
From: Andreas Koenig <andk@cpan.org>
Date: Mon, 10 Jan 2022 21:47:30 +0100
Subject: [PATCH 1/2] s/gpg/$gpg/ in system, add quotes where needed
- thanks to Tomas Hoger for spotting the missing sigil
---
lib/CPAN/Distribution.pm | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/CPAN/Distribution.pm b/lib/CPAN/Distribution.pm
index b262b6f6..d837b8ad 100644
--- a/lib/CPAN/Distribution.pm
+++ b/lib/CPAN/Distribution.pm
@@ -1551,9 +1551,10 @@ sub CHECKSUM_check_file {
}
my $tempfile = File::Spec->catfile($tempdir, "CHECKSUMS.$$");
unlink $tempfile; # ignore missing file
+ my $devnull = File::Spec->devnull;
my $gpg = $CPAN::Config->{gpg} or
$CPAN::Frontend->mydie("Your configuration suggests that you do not have 'gpg' installed. This is needed to verify checksums with the config variable 'check_sigs' on. Please configure it with 'o conf init gpg'");
- my $system = "gpg --verify --batch --no-tty --output $tempfile $chk_file 2> /dev/null";
+ my $system = qq{"$gpg" --verify --batch --no-tty --output "$tempfile" "$chk_file" 2> "/dev/null"};
0 == system $system or $CPAN::Frontend->mydie("gpg run was failing, cannot continue: $system");
open $fh, $tempfile or $CPAN::Frontend->mydie("Could not open $tempfile: $!");
local $/;
--
2.34.1

7
gating.yaml Normal file
View File

@ -0,0 +1,7 @@
--- !Policy
product_versions:
- fedora-*
decision_context: bodhi_update_push_stable
subject_type: koji_build
rules:
- !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional}

View File

@ -10,7 +10,7 @@
Name: perl-CPAN
Version: 2.29
Release: 2%{?dist}
Release: 3%{?dist}
Summary: Query, download and build perl modules from CPAN sites
License: GPL+ or Artistic
URL: https://metacpan.org/release/CPAN
@ -19,6 +19,9 @@ Source0: https://cpan.metacpan.org/authors/id/A/AN/ANDK/CPAN-%{version}.t
Patch0: CPAN-2.18-Attemp-to-create-site-library-directories-on-first-t.patch
# Change configuration directory name
Patch1: CPAN-2.18-Replace-configuration-directory-string-with-a-marke.patch
# Some syntax fixes
Patch2: CPAN-2.32-s-gpg-gpg-in-system-add-quotes-where-needed.patch
Patch3: CPAN-2.32-s-dev-null-devnull.patch
BuildArch: noarch
BuildRequires: coreutils
BuildRequires: findutils
@ -209,6 +212,7 @@ Requires: perl(ExtUtils::CBuilder)
%if ! %{defined perl_bootstrap}
Requires: perl(IO::Socket::SSL) >= 1.56
Requires: perl(Net::SSLeay) >= 1.49
Requires: perl(Module::Signature)
%endif
%if ! %{defined perl_bootstrap}
# Avoid circular deps local::lib -> Module::Install -> CPAN when bootstraping
@ -234,7 +238,10 @@ Provides: cpan = %{version}
%global __requires_exclude %{?__requires_exclude:%__requires_exclude|}^perl\\(Mac::BuildTools\\)
# Filter under-specified dependencies
%global __requires_exclude %{?__requires_exclude:%__requires_exclude|}^perl\\(CPAN::Meta::Requirements\\)
# Filter modules bundled for tests
%global __provides_exclude_from %{?__provides_exclude_from:%__provides_exclude_from|}^%{_libexecdir}
%global __requires_exclude %{__requires_exclude}|^perl\\(CPAN::MyConfig\\)
%global __requires_exclude %{__requires_exclude}|^perl\\(local_utils\\)
%description
The CPAN module automates or at least simplifies the make and install of
@ -242,16 +249,33 @@ perl modules and extensions. It includes some primitive searching
capabilities and knows how to use LWP, HTTP::Tiny, Net::FTP and certain
external download clients to fetch distributions from the net.
%package tests
Summary: Tests for %{name}
Requires: %{name} = %{?epoch:%{epoch}:}%{version}-%{release}
Requires: perl-Test-Harness
%description tests
Tests from %{name}. Execute them
with "%{_libexecdir}/%{name}/test".
%prep
%setup -q -n CPAN-%{version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
# Change configuration name
find -type f -exec perl -i -pe 's/XCPANCONFIGNAMEX/cpan/g' {} \;
# Remove bundled modules
rm -r ./inc/*
perl -i -ne 'print $_ unless m{^inc/}' MANIFEST
# Help generators to recognize Perl scripts
for F in t/*.t; do
perl -i -MConfig -ple 'print $Config{startperl} if $. == 1 && !s{\A#!.*perl\b}{$Config{startperl}}' "$F"
chmod +x "$F"
done
%build
perl Makefile.PL INSTALLDIRS=vendor NO_PACKLIST=1 NO_PERLLOCAL=1
%{make_build}
@ -260,10 +284,43 @@ perl Makefile.PL INSTALLDIRS=vendor NO_PACKLIST=1 NO_PERLLOCAL=1
%{make_install}
%{_fixperms} $RPM_BUILD_ROOT/*
# Install tests
mkdir -p %{buildroot}%{_libexecdir}/%{name}
cp -a t distroprefs %{buildroot}%{_libexecdir}/%{name}
# Does not work with system module
rm %{buildroot}%{_libexecdir}/%{name}/t/51pod.t
# Remove the tests which need ./lib and ./blib
rm %{buildroot}%{_libexecdir}/%{name}/t/03pkgs.t
rm %{buildroot}%{_libexecdir}/%{name}/t/04clean_load.t
# Needed internet connection
rm %{buildroot}%{_libexecdir}/%{name}/t/31sessions.t
# Use system modules for tests
perl -i -ple 's{-Mblib}{}' %{buildroot}%{_libexecdir}/%{name}/t/97-run.t
perl -i -ple 's{-Mblib}{}' %{buildroot}%{_libexecdir}/%{name}/t/97-return_values.t
mkdir -p %{buildroot}%{_libexecdir}/%{name}/blib/script
ln -s %{_bindir}/cpan %{buildroot}%{_libexecdir}/%{name}/blib/script
cat > %{buildroot}%{_libexecdir}/%{name}/test << 'EOF'
#!/bin/sh
set -e
unset AUTHOR_TEST CPAN_EXPECT_TIMEOUT CPAN_RUN_SHELL_TEST_WITHOUT_EXPECT \
ftp_proxy http_proxy no_proxy \
PERL5_CPAN_IS_RUNNING PERL5_CPAN_IS_RUNNING_IN_RECURSION PERL_CORE VERBOSE
# Some tests write into temporary files/directories. The easiest solution
# is to copy the tests into a writable directory and execute them from there.
DIR=$(mktemp -d)
pushd "$DIR"
cp -a %{_libexecdir}/%{name}/* ./
prove -I . -j "$(getconf _NPROCESSORS_ONLN)"
popd
rm -rf "$DIR"
EOF
chmod +x %{buildroot}%{_libexecdir}/%{name}/test
%check
unset AUTHOR_TEST CPAN_EXPECT_TIMEOUT CPAN_RUN_SHELL_TEST_WITHOUT_EXPECT \
ftp_proxy http_proxy no_proxy \
PERL5_CPAN_IS_RUNNING PERL5_CPAN_IS_RUNNING_IN_RECURSION PERL_CORE VERBOSE
export HARNESS_OPTIONS=j$(perl -e 'if ($ARGV[0] =~ /.*-j([0-9][0-9]*).*/) {print $1} else {print 1}' -- '%{?_smp_mflags}')
make test
%files
@ -273,7 +330,13 @@ make test
%{_mandir}/man1/*
%{_mandir}/man3/*
%files tests
%{_libexecdir}/%{name}
%changelog
* Wed Feb 09 2022 Jitka Plesnikova <jplesnik@redhat.com> - 2.29-3
- Package tests
* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 2.29-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

5
plans/sanity.fmf Normal file
View File

@ -0,0 +1,5 @@
summary: Sanity tests
discover:
how: fmf
execute:
how: tmt

4
tests/upstream-tests.fmf Normal file
View File

@ -0,0 +1,4 @@
summary: Upstream tests
component: perl-CPAN
require: perl-CPAN-tests
test: /usr/libexec/perl-CPAN/test