From 752cb14316786b07f4d6029840939edf4efe2698 Mon Sep 17 00:00:00 2001 From: Jitka Plesnikova Date: Mon, 22 Jan 2024 17:03:32 +0100 Subject: [PATCH] Resolves: RHEL-9468 - Add tests --- .fmf/version | 1 + gating.yaml | 7 +++++ perl-CPAN.spec | 68 +++++++++++++++++++++++++++++++++++++++- plans/sanity.fmf | 5 +++ tests/upstream-tests.fmf | 7 +++++ 5 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 .fmf/version create mode 100644 gating.yaml create mode 100644 plans/sanity.fmf create mode 100644 tests/upstream-tests.fmf diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/gating.yaml b/gating.yaml new file mode 100644 index 0000000..b4cb4d8 --- /dev/null +++ b/gating.yaml @@ -0,0 +1,7 @@ +--- !Policy +product_versions: + - rhel-8 +decision_context: osci_compose_gate +rules: + - !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional} + - !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tier2.functional} diff --git a/perl-CPAN.spec b/perl-CPAN.spec index 3827eca..78f5979 100644 --- a/perl-CPAN.spec +++ b/perl-CPAN.spec @@ -112,6 +112,7 @@ BuildRequires: perl(Module::Build) %endif # Tests: +BuildRequires: perl(blib) # CPAN::Checksums not used BuildRequires: perl(FindBin) BuildRequires: perl(Pod::Usage) @@ -150,6 +151,14 @@ BuildRequires: perl(YAML) >= 0.60 Requires: make Requires: perl(:MODULE_COMPAT_%(eval "`perl -V:version`"; echo $version)) +# Some subpackages modules are not dual-lived. E.g. "open". If a distribution +# on CPAN declares a dependency on such a module, CPAN client will fail +# because the only provider is perl distribution. +# Another issue is with dual-lived modules whose distribution actually does +# not declare all needed core dependencies and the installation would also +# fail. +# As a result, any CPAN client must run-require the complete perl. +Requires: perl Requires: perl(Archive::Tar) >= 1.50 Requires: perl(CPAN::Meta::Requirements) >= 2.121 Requires: perl(Data::Dumper) @@ -206,7 +215,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 @@ -214,6 +226,16 @@ 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 +Requires: tar + +%description tests +Tests from %{name}. Execute them +with "%{_libexecdir}/%{name}/test". + %prep %setup -q -n CPAN-%{cpan_version} %patch -P0 -p1 @@ -227,6 +249,12 @@ find -type f -exec sed -i -e 's/XCPANCONFIGNAMEX/cpan/g' {} \; rm -r ./inc/* sed -i -e '/inc\//d' 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 make %{?_smp_mflags} @@ -236,7 +264,41 @@ make pure_install DESTDIR=$RPM_BUILD_ROOT find $RPM_BUILD_ROOT -type f -name .packlist -delete %{_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/5*pod*.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-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 make test %files @@ -246,9 +308,13 @@ make test %{_mandir}/man1/* %{_mandir}/man3/* +%files tests +%{_libexecdir}/%{name} + %changelog * Thu Jan 18 2024 Jitka Plesnikova - 2.18-397 - Fix CVE-2023-31484 +- Package tests * Thu Feb 08 2018 Fedora Release Engineering - 2.18-397 - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild diff --git a/plans/sanity.fmf b/plans/sanity.fmf new file mode 100644 index 0000000..a72ded4 --- /dev/null +++ b/plans/sanity.fmf @@ -0,0 +1,5 @@ +summary: Sanity tests +discover: + how: fmf +execute: + how: tmt diff --git a/tests/upstream-tests.fmf b/tests/upstream-tests.fmf new file mode 100644 index 0000000..2cfe89c --- /dev/null +++ b/tests/upstream-tests.fmf @@ -0,0 +1,7 @@ +summary: Upstream tests +component: perl-CPAN +require: perl-CPAN-tests +test: /usr/libexec/perl-CPAN/test +tag: + - Tier2 + - rhel-buildroot