From e96bca52cf54a63595a3dc5350c286ba6fb6147b Mon Sep 17 00:00:00 2001 From: Jitka Plesnikova Date: Tue, 19 Sep 2023 17:26:06 +0200 Subject: [PATCH] Package tests --- .fmf/version | 1 + gating.yaml | 7 +++++ perl-DBI.spec | 60 +++++++++++++++++++++++++++++++++++++++- plans/sanity.fmf | 5 ++++ tests/upstream-tests.fmf | 4 +++ 5 files changed, 76 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..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-DBI.spec b/perl-DBI.spec index 0e21d63..b1dd4a0 100644 --- a/perl-DBI.spec +++ b/perl-DBI.spec @@ -34,7 +34,7 @@ Name: perl-DBI Version: 1.643 -Release: 18%{?dist} +Release: 19%{?dist} Summary: A database access API for perl License: GPL-1.0-or-later OR Artistic-1.0-Perl URL: http://dbi.perl.org/ @@ -133,6 +133,8 @@ Suggests: perl(SQL::Statement) >= 1.402 # Filter unwanted dependencies %{?perl_default_filter} %global __requires_exclude %{?__requires_exclude:%{__requires_exclude}|}^perl\\(RPC::\\) +%global __requires_exclude %{__requires_exclude}|^perl\\(DBI::db\\) +%global __requires_exclude %{__requires_exclude}|^perl\\(DBI::st\\) %description DBI is a database access Application Programming Interface (API) for @@ -150,6 +152,29 @@ implemented on top of Coro. The BIG WIN from using Coro is that it enables the use of existing DBI frameworks like DBIx::Class. %endif +%package tests +Summary: Tests for %{name} +Requires: %{name} = %{?epoch:%{epoch}:}%{version}-%{release} +Requires: perl-Test-Harness +# Optional run-time: +%if %{with perl_DBI_enables_Clone} +Requires: perl(Clone) >= 0.34 +%endif +%if %{with perl_DBI_enables_DB_File} +Requires: perl(DB_File) +%endif +%if %{with perl_DBI_enables_MLDBM} +Requires: perl(MLDBM) +%endif +# Do not build-require optional Params::Util to test the fall-back code +%if %{with perl_DBI_enables_SQL_Statement} +Requires: perl(SQL::Statement) >= 1.402 +%endif + +%description tests +Tests from %{name}. Execute them +with "%{_libexecdir}/%{name}/test". + %prep %setup -q -n DBI-%{version} for F in lib/DBD/Gofer.pm; do @@ -181,6 +206,12 @@ for F in lib/DBI/W32ODBC.pm lib/Win32/DBIODBC.pm; do sed -i -e '\|^'"$F"'|d' MANIFEST done +# Help generators to recognize Perl scripts +for F in t/*.t t/*.pl; 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 OPTIMIZE="%{optflags}" \ NO_PACKLIST=1 NO_PERLLOCAL=1 @@ -191,6 +222,27 @@ perl Makefile.PL INSTALLDIRS=vendor OPTIMIZE="%{optflags}" \ find %{buildroot} -type f -name '*.bs' -empty -delete %{_fixperms} '%{buildroot}'/* +# Install tests +mkdir -p %{buildroot}%{_libexecdir}/%{name} +cp -a t %{buildroot}%{_libexecdir}/%{name} +rm %{buildroot}%{_libexecdir}/%{name}/t/pod*.t +# Remove using of blib +sed -i -e '/^use.*blib/d' %{buildroot}%{_libexecdir}/%{name}/t/1*.t +sed -i -e 's/\-Mblib=\$getcwd\/blib//' %{buildroot}%{_libexecdir}/%{name}/t/85gofer.t +cat > %{buildroot}%{_libexecdir}/%{name}/test << 'EOF' +#!/bin/bash +set -e +# 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 make test @@ -215,7 +267,13 @@ make test %{perl_vendorarch}/DBD/Gofer/Transport/corostream.pm %endif +%files tests +%{_libexecdir}/%{name} + %changelog +* Tue Sep 19 2023 Jitka Plesnikova -1.643-19 +- Package tests + * Thu Jul 20 2023 Fedora Release Engineering - 1.643-18 - Rebuilt for https://fedoraproject.org/wiki/Fedora_39_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..b65ade6 --- /dev/null +++ b/tests/upstream-tests.fmf @@ -0,0 +1,4 @@ +summary: Upstream tests +component: perl-DBI +require: perl-DBI-tests +test: /usr/libexec/perl-DBI/test