From be843d10180f284bc33c5f79fa4809eeb8e04c0d Mon Sep 17 00:00:00 2001 From: Jitka Plesnikova Date: Wed, 21 Jun 2023 15:57:50 +0200 Subject: [PATCH] Package tests --- .fmf/version | 1 + gating.yaml | 7 +++++ perl-Devel-CheckLib.spec | 63 +++++++++++++++++++++++++++++++++++----- plans/sanity.fmf | 5 ++++ tests/upstream-tests.fmf | 4 +++ 5 files changed, 72 insertions(+), 8 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-Devel-CheckLib.spec b/perl-Devel-CheckLib.spec index 9483ba5..a18fbe8 100644 --- a/perl-Devel-CheckLib.spec +++ b/perl-Devel-CheckLib.spec @@ -7,7 +7,7 @@ Name: perl-Devel-CheckLib Version: 1.16 -Release: 6%{?dist} +Release: 7%{?dist} Summary: Check that a library is available License: GPL-1.0-or-later OR Artistic-1.0-Perl @@ -20,6 +20,7 @@ BuildRequires: coreutils BuildRequires: make BuildRequires: perl-interpreter BuildRequires: perl-generators +BuildRequires: perl(Config) BuildRequires: perl(ExtUtils::MakeMaker) # Run-time: BuildRequires: perl(Exporter) @@ -40,34 +41,80 @@ BuildRequires: perl(Test::More) >= 0.88 BuildRequires: perl(Mock::Config) %endif +# Filter modules bundled for tests +%global __provides_exclude_from %{?__provides_exclude_from:%__provides_exclude_from|}^%{_libexecdir} %description Devel::CheckLib is a perl module that checks whether a particular C library and its headers are available. +%package tests +Summary: Tests for %{name} +Requires: %{name} = %{?epoch:%{epoch}:}%{version}-%{release} +Requires: perl-Test-Harness +Requires: gcc +# Optional tests +%if %{with perl_Devel_CheckLib_enables_optional_test} +Requires: perl(Mock::Config) +%endif + +%description tests +Tests from %{name}. Execute them +with "%{_libexecdir}/%{name}/test". + %prep %setup -q -n Devel-CheckLib-%{version} +# 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 -make %{?_smp_mflags} +perl Makefile.PL INSTALLDIRS=vendor NO_PACKLIST=1 NO_PERLLOCAL=1 +%{make_build} %install -make pure_install DESTDIR=$RPM_BUILD_ROOT -%{_fixperms} $RPM_BUILD_ROOT/* +%{make_install} +%{_fixperms} %{buildroot}/* + +# Install tests +mkdir -p %{buildroot}%{_libexecdir}/%{name} +cp -a t %{buildroot}%{_libexecdir}/%{name} +perl -i -ne 'print $_ unless m{\Q'-Mblib'\E}' %{buildroot}%{_libexecdir}/%{name}/t/cmdline-LIBS-INC.t +cat > %{buildroot}%{_libexecdir}/%{name}/test << 'EOF' +#!/bin/bash +set -e +# Some tests need to write into temporary files/directories. +# 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 +export HARNESS_OPTIONS=j$(perl -e 'if ($ARGV[0] =~ /.*-j([0-9][0-9]*).*/) {print $1} else {print 1}' -- '%{?_smp_mflags}') make test %files %doc CHANGES README TODO -%{_bindir}/* +%{_bindir}/use-devel-checklib %{perl_vendorlib}/Devel* -%{_mandir}/man1/*.1* -%{_mandir}/man3/*.3* +%{_mandir}/man1/use-devel-checklib.1* +%{_mandir}/man3/Devel::CheckLib.3* +%files tests +%{_libexecdir}/%{name} %changelog +* Wed Jun 21 2023 Jitka Plesnikova - 1.16-7 +- Package tests + * Wed Jun 21 2023 Jitka Plesnikova - 1.16-6 - Add test BR gcc to not skip the tests 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..ad00d5c --- /dev/null +++ b/tests/upstream-tests.fmf @@ -0,0 +1,4 @@ +summary: Upstream tests +component: perl-Devel-CheckLib +require: perl-Devel-CheckLib-tests +test: /usr/libexec/perl-Devel-CheckLib/test