From 4b0f0c6d85a90b493e6decd9941699849df7e2ef Mon Sep 17 00:00:00 2001 From: Jitka Plesnikova Date: Mon, 1 Mar 2021 16:15:35 +0100 Subject: [PATCH] Package tests --- .fmf/version | 1 + gating.yaml | 7 ++++ perl-IO-Compress.spec | 74 ++++++++++++++++++++++++++++++++++++++-- plans/sanity.fmf | 5 +++ tests/upstream-tests.fmf | 4 +++ 5 files changed, 89 insertions(+), 2 deletions(-) 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..282e16b --- /dev/null +++ b/gating.yaml @@ -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} diff --git a/perl-IO-Compress.spec b/perl-IO-Compress.spec index edbf75f..b34e804 100644 --- a/perl-IO-Compress.spec +++ b/perl-IO-Compress.spec @@ -14,7 +14,7 @@ Name: perl-IO-Compress Version: 2.102 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Read and write compressed data License: GPL+ or Artistic URL: https://metacpan.org/release/IO-Compress @@ -54,6 +54,9 @@ BuildRequires: perl(warnings) BuildRequires: perl(File::Path) BuildRequires: perl(lib) BuildRequires: perl(threads::shared) +%if !%{defined perl_bootstrap} +BuildRequires: perl(Test::More) +%endif %if %{with perl_IO_Compress_enables_optional_test} # Optional Tests BuildRequires: perl(bytes) @@ -63,7 +66,6 @@ BuildRequires: perl(overload) # Dual-lived module needs building early in the boot process %if !%{defined perl_bootstrap} BuildRequires: perl(Test::NoWarnings) -BuildRequires: perl(Test::Pod) >= 1.00 %endif %endif # Runtime @@ -80,6 +82,16 @@ Provides: perl-IO-Compress-Bzip2 = %{version}-%{release} Obsoletes: perl-IO-Compress-Zlib < %{version}-%{release} Provides: perl-IO-Compress-Zlib = %{version}-%{release} +# Filter modules bundled for tests +%global __requires_exclude %{?__requires_exclude:%__requires_exclude|}perl\\(CompTestUtils\\) +%global __requires_exclude %{__requires_exclude}|^perl\\(.*\.pl)\s*$ +%if %{defined perl_bootstrap} +%global __requires_exclude %{__requires_exclude}|^perl\\(Test::Builder)\s*$ +%global __requires_exclude %{__requires_exclude}|^perl\\(Test::More)\s*$ +%global __requires_exclude %{__requires_exclude}|^perl\\(Test::Simple)\s*$ +%endif +%global __provides_exclude_from %{?__provides_exclude_from:%__provides_exclude_from|}^%{_libexecdir} + %description This distribution provides a Perl interface to allow reading and writing of compressed data created with the zlib and bzip2 libraries. @@ -94,6 +106,15 @@ included with the IO-Compress distribution: * IO-Compress-Bzip2 * IO-Compress-Base +%package tests +Summary: Tests for %{name} +Requires: %{name} = %{?epoch:%{epoch}:}%{version}-%{release} +Requires: perl-Test-Harness + +%description tests +Tests from %{name}-%{version}. Execute them +with "%{_libexecdir}/%{name}/test". + %prep %setup -q -n IO-Compress-%{version} @@ -101,19 +122,62 @@ included with the IO-Compress distribution: chmod -c -x lib/IO/Uncompress/{Adapter/Identity,RawInflate}.pm find examples -type f -exec chmod -c -x {} \; +%if ! %{defined perl_bootstrap} +# Remove bundled Test::* modules +rm -rf t/Test +perl -i -ne 'print $_ unless m{^t/Test/}' MANIFEST +%endif + # Fix shellbangs in examples perl -MConfig -pi -e 's|^#!/usr/local/bin/perl\b|$Config{startperl}|' examples/io/anycat \ examples/io/bzip2/* examples/io/gzip/* examples/compress-zlib/* +# Help file to recognise the Perl scripts and normalize shebangs +for F in `find t -name *.t` `find t -name *.pl`; do + if head -1 "$F" | grep -q -e '^#!.*perl' ; then + perl -MConfig -pi -e 's|^#!.*perl\b|$Config{startperl}|' "$F" + else + perl -i -MConfig -ple 'print $Config{startperl} if $. == 1' "$F" + fi + chmod +x "$F" +done + +# Remove release tests +rm t/999pod.t t/999meta-*.t +perl -i -ne 'print $_ unless m{^t/999pod\.t}' MANIFEST +perl -i -ne 'print $_ unless m{^t/999meta-.*\.t}' MANIFEST + %build perl Makefile.PL NO_PACKLIST=1 NO_PERLLOCAL=1 %{make_build} %install %{make_install} INSTALLDIRS=perl + +# Install tests +mkdir -p %{buildroot}/%{_libexecdir}/%{name} +cp -a examples t %{buildroot}/%{_libexecdir}/%{name} +perl -i -pe "s{\"./bin/\"}{\"%{_bindir}\"}" %{buildroot}/%{_libexecdir}/%{name}/t/011-streamzip.t +cat > %{buildroot}/%{_libexecdir}/%{name}/test << 'EOF' +#!/bin/sh +set -e +# Lots of 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}/* ./ +unset PERL_CORE +prove -I . -j "$(getconf _NPROCESSORS_ONLN)" +popd +rm -rf "$DIR" +EOF +chmod +x %{buildroot}/%{_libexecdir}/%{name}/test + %{_fixperms} -c %{buildroot} %check +unset PERL_CORE +export HARNESS_OPTIONS=j$(perl -e 'if ($ARGV[0] =~ /.*-j([0-9][0-9]*).*/) {print $1} else {print 1}' -- '%{?_smp_mflags}') # Build using "--without long_tests" to avoid very long tests # (full suite can take nearly an hour on an i7 920) make test COMPRESS_ZLIB_RUN_%{?with_long_tests:ALL}%{!?with_long_tests:MOST}=1 @@ -146,7 +210,13 @@ make test COMPRESS_ZLIB_RUN_%{?with_long_tests:ALL}%{!?with_long_tests:MOST}=1 %{_mandir}/man3/IO::Compress::*.3* %{_mandir}/man3/IO::Uncompress::*.3* +%files tests +%{_libexecdir}/%{name} + %changelog +* Mon Mar 01 2021 Jitka Plesnikova - 2.102-2 +- Package tests + * Sun Feb 28 2021 Paul Howarth - 2.102-1 - 2.102 bump 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..74b0b1d --- /dev/null +++ b/tests/upstream-tests.fmf @@ -0,0 +1,4 @@ +summary: Upstream tests +component: perl-IO-Compress +require: perl-IO-Compress-tests +test: /usr/libexec/perl-IO-Compress/test