Package tests

This commit is contained in:
Jitka Plesnikova 2023-09-20 14:18:38 +02:00
parent 7816a32901
commit 66888a97be
5 changed files with 59 additions and 2 deletions

1
.fmf/version Normal file
View File

@ -0,0 +1 @@
1

7
gating.yaml Normal file
View File

@ -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}

View File

@ -1,6 +1,6 @@
Name: perl-XML-Parser
Version: 2.46
Release: 15%{?dist}
Release: 16%{?dist}
Summary: Perl module for parsing XML documents
License: GPL-1.0-or-later OR Artistic-1.0-Perl
@ -43,7 +43,9 @@ BuildRequires: perl(Test::More)
BuildRequires: perl(warnings)
Requires: perl(IO::File)
Requires: perl(IO::Handle)
Requires: perl(LWP::UserAgent)
Requires: perl(URI)
Requires: perl(URI::file)
%{?perl_default_filter}
%global __provides_exclude %{?__provides_exclude:%__provides_exclude|}perl\\(XML::Parser\\)$
@ -59,6 +61,15 @@ parse call. They can also be given as extra arguments to the parse
methods, in which case they override options given at XML::Parser
creation time.
%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-Parser-%{version}
chmod 644 samples/{canonical,xml*}
@ -68,6 +79,12 @@ perl -MConfig -pi -e 's|^#!/usr/local/bin/perl\b|$Config{startperl}|' samples/{c
rm -r inc
perl -i -ne 'print $_ unless m{^inc/}' MANIFEST
# 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 NO_PERLLOCAL=1 OPTIMIZE="$RPM_OPT_FLAGS"
%{make_build}
@ -83,7 +100,25 @@ for file in samples/REC-xml-19980210.xml; do
perl -i -pe "s/encoding='ISO-8859-1'/encoding='UTF-8'/" "$file"
done
# Install tests
mkdir -p %{buildroot}%{_libexecdir}/%{name}
cp -a t samples %{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
export HARNESS_OPTIONS=j$(perl -e 'if ($ARGV[0] =~ /.*-j([0-9][0-9]*).*/) {print $1} else {print 1}' -- '%{?_smp_mflags}')
make test
%files
@ -92,8 +127,13 @@ make test
%{perl_vendorarch}/auto/XML/
%{_mandir}/man3/*.3*
%files tests
%{_libexecdir}/%{name}
%changelog
* Wed Sep 20 2023 Jitka Plesnikova <jplesnik@redhat.com> - 2.46-16
- Package tests
* Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 2.46-15
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

5
plans/sanity.fmf Normal file
View File

@ -0,0 +1,5 @@
summary: Sanity tests
discover:
how: fmf
execute:
how: tmt

4
tests/upstream-tests.fmf Normal file
View File

@ -0,0 +1,4 @@
summary: Upstream tests
component: perl-XML-Parser
require: perl-XML-Parser-tests
test: /usr/libexec/perl-XML-Parser/test