From 5638e354efec5ff6a75c2ae171f8427ff1a8fd48 Mon Sep 17 00:00:00 2001 From: Jitka Plesnikova Date: Wed, 4 Aug 2021 16:17:30 +0200 Subject: [PATCH] Package tests --- .fmf/version | 1 + gating.yaml | 7 +++++ perl-XML-Simple.spec | 60 ++++++++++++++++++++++++++++++++++++---- plans/sanity.fmf | 5 ++++ tests/upstream-tests.fmf | 4 +++ 5 files changed, 72 insertions(+), 5 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-XML-Simple.spec b/perl-XML-Simple.spec index 49b018b..2def840 100644 --- a/perl-XML-Simple.spec +++ b/perl-XML-Simple.spec @@ -7,16 +7,18 @@ Name: perl-XML-Simple Version: 2.25 -Release: 12%{?dist} +Release: 13%{?dist} Summary: Easy API to maintain XML in Perl License: GPL+ or Artistic URL: https://metacpan.org/release/XML-Simple Source0: https://cpan.metacpan.org/authors/id/G/GR/GRANTM/XML-Simple-%{version}.tar.gz BuildArch: noarch # Build +BuildRequires: coreutils BuildRequires: make BuildRequires: perl-interpreter BuildRequires: perl-generators +BuildRequires: perl(Config) BuildRequires: perl(ExtUtils::MakeMaker) >= 6.76 BuildRequires: perl(strict) BuildRequires: perl(warnings) @@ -53,21 +55,63 @@ Requires: perl(XML::NamespaceSupport) >= 1.04 Requires: perl(XML::Parser) Requires: perl(XML::SAX) >= 0.15 +# Filter modules bundled for tests +%global __provides_exclude_from %{?__provides_exclude_from:%__provides_exclude_from|}^%{_libexecdir} +%global __requires_exclude %{?__requires_exclude:%__requires_exclude|}^perl\\(TagsToUpper\\) + %description The XML::Simple module provides a simple API layer on top of an underlying XML parsing module (either XML::Parser or one of the SAX2 parser modules). +%package tests +Summary: Tests for %{name} +Requires: %{name} = %{?epoch:%{epoch}:}%{version}-%{release} +Requires: perl-Test-Harness + +%description tests +Tests from %{name}. Execute them +with "%{_libexecdir}/%{name}/test". + %prep %setup -q -n XML-Simple-%{version} +# Remove author tests +for F in t/author-pod-syntax.t; do + rm "$F" + perl -i -ne 'print $_ unless m{^\Q'"$F"'\E}' MANIFEST +done + +# 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=%{buildroot} -chmod -R u+w %{buildroot}/* +%{make_install} +%{_fixperms} %{buildroot}/* + +# Install tests +mkdir -p %{buildroot}/%{_libexecdir}/%{name} +cp -a t %{buildroot}/%{_libexecdir}/%{name} +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 @@ -78,7 +122,13 @@ make test %{perl_vendorlib}/* %{_mandir}/man3/* +%files tests +%{_libexecdir}/%{name} + %changelog +* Wed Aug 04 2021 Jitka Plesnikova - 2.25-13 +- Package tests + * Fri Jul 23 2021 Fedora Release Engineering - 2.25-12 - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_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..c3d96c7 --- /dev/null +++ b/tests/upstream-tests.fmf @@ -0,0 +1,4 @@ +summary: Upstream tests +component: perl-XML-Simple +require: perl-XML-Simple-tests +test: /usr/libexec/perl-XML-Simple/test