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-Sys-Virt.spec b/perl-Sys-Virt.spec index 3f2dc02..485c573 100644 --- a/perl-Sys-Virt.spec +++ b/perl-Sys-Virt.spec @@ -1,6 +1,6 @@ Name: perl-Sys-Virt Version: 7.0.0 -Release: 2%{?dist} +Release: 3%{?dist} Summary: Represent and manage a libvirt hypervisor connection License: GPLv2+ or Artistic URL: https://metacpan.org/release/Sys-Virt @@ -9,6 +9,7 @@ Source0: https://cpan.metacpan.org/authors/id/D/DA/DANBERR/Sys-Virt-v%{ve BuildRequires: coreutils BuildRequires: findutils BuildRequires: gcc +BuildRequires: git BuildRequires: libvirt-devel >= %{version} BuildRequires: perl-devel %if 0%{?fedora} || 0%{?rhel} > 7 @@ -30,11 +31,10 @@ BuildRequires: perl(Test::More) BuildRequires: perl(Time::HiRes) BuildRequires: perl(XML::XPath) BuildRequires: perl(XML::XPath::XMLParser) -# Optional tests only -BuildRequires: perl(Test::CPAN::Changes) -BuildRequires: perl(Test::Pod) >= 1.00 -BuildRequires: perl(Test::Pod::Coverage) >= 1.00 -BuildRequires: git +# Optional tests are not executed +#BuildRequires: perl(Test::CPAN::Changes) +#BuildRequires: perl(Test::Pod) >= 1.00 +#BuildRequires: perl(Test::Pod::Coverage) >= 1.00 Requires: perl(:MODULE_COMPAT_%(eval "$(perl -V:version)"; echo $version)) %description @@ -42,9 +42,33 @@ The Sys::Virt module provides a Perl XS binding to the libvirt virtual machine management APIs. This allows machines running within arbitrary virtualization containers to be managed with a consistent API. +%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 %autosetup -S git -n Sys-Virt-v%{version} +# Help file to recognise the Perl scripts and normalize shebangs +for F in t/*.t; 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 +for F in t/005-pod.t t/010-pod-coverage.t t/015-changes.t; do + rm "$F" + perl -i -ne 'print $_ unless m{^\Q'"$F"'\E}' MANIFEST +done %build perl Build.PL installdirs=vendor @@ -53,9 +77,20 @@ perl Build.PL installdirs=vendor %install ./Build install destdir=$RPM_BUILD_ROOT create_packlist=0 find $RPM_BUILD_ROOT -type f -name '*.bs' -size 0 -delete + +# Install tests +mkdir -p %{buildroot}/%{_libexecdir}/%{name} +cp -a t %{buildroot}/%{_libexecdir}/%{name} +cat > %{buildroot}/%{_libexecdir}/%{name}/test << 'EOF' +#!/bin/sh +cd %{_libexecdir}/%{name} && exec prove -I . -j "$(getconf _NPROCESSORS_ONLN)" +EOF +chmod +x %{buildroot}/%{_libexecdir}/%{name}/test + %{_fixperms} $RPM_BUILD_ROOT/* %check +export HARNESS_OPTIONS=j$(perl -e 'if ($ARGV[0] =~ /.*-j([0-9][0-9]*).*/) {print $1} else {print 1}' -- '%{?_smp_mflags}') ./Build test %files @@ -65,8 +100,13 @@ find $RPM_BUILD_ROOT -type f -name '*.bs' -size 0 -delete %{perl_vendorarch}/Sys* %{_mandir}/man3/* +%files tests +%{_libexecdir}/%{name} %changelog +* Tue Mar 02 2021 Jitka Plesnikova - 7.0.0-3 +- Package tests + * Wed Jan 27 2021 Fedora Release Engineering - 7.0.0-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_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..b2a67a8 --- /dev/null +++ b/tests/upstream-tests.fmf @@ -0,0 +1,4 @@ +summary: Upstream tests +component: perl-Sys-Virt +require: perl-Sys-Virt-tests +test: /usr/libexec/perl-Sys-Virt/test