Package tests manually

%{perl_default_subpackage_tests} macro blows when executing
"rpmbuild --rebuild perl-JSON...src.rpm --nocheck". Also the
autogeneted pacakges was missing dependencies and not some of the
tests did not pass for other reasons (writing to a working directory,
searching PODs in ./lib).
This commit is contained in:
Petr Písař 2021-02-22 18:09:59 +01:00
parent e0161eb426
commit 7060636048

View File

@ -1,7 +1,7 @@
Name: perl-JSON
Summary: Parse and convert to JSON (JavaScript Object Notation)
Version: 4.03
Release: 2%{?dist}
Release: 3%{?dist}
License: GPL+ or Artistic
URL: https://metacpan.org/release/JSON
@ -25,6 +25,7 @@ BuildRequires: perl(:VERSION) >= 5.5.30
BuildRequires: perl(base)
BuildRequires: perl(bytes)
BuildRequires: perl(Carp)
BuildRequires: perl(Config)
BuildRequires: perl(constant)
BuildRequires: perl(Data::Dumper)
BuildRequires: perl(Encode)
@ -50,19 +51,32 @@ BuildRequires: perl(warnings)
%global __provides_exclude %{?__provides_exclude:%__provides_exclude|}perl\\(JSON::(Backend::PP|backportPP::Boolean|Boolean|PP|PP::IncrParser)\\)
%global __requires_exclude %{?__requires_exclude:%__requires_exclude|}perl\\(JSON::(backportPP|backportPP::Boolean)\\)
%{?perl_default_subpackage_tests}
%description
This module converts between JSON (JavaScript Object Notation) and Perl
data structure into each other. For JSON, see http://www.crockford.com/JSON/.
%package tests
Summary: Tests for %{name}
Requires: %{name} = %{?epoch:%{epoch}:}%{version}-%{release}
Requires: coreutils
Requires: perl-Test-Harness
Requires: perl(Tie::IxHash)
%description tests
Tests from %{name}. Execute them
with "%{_libexecdir}/%{name}/test".
%prep
%setup -q -n JSON-%{version}
# make rpmlint happy...
find . -type f -exec chmod -c -x {} +
find t/ -type f -exec perl -pi -e 's|^#! perl|#!/usr/bin/perl|' {} +
sed -i 's/\r//' README t/*
# Help generators to recognize Perl scripts
for F in t/*.t; do
perl -i -MConfig -ple 'print $Config{startperl} if $. == 1' "$F"
chmod +x "$F"
done
%build
/usr/bin/perl Makefile.PL INSTALLDIRS=vendor NO_PACKLIST=1 NO_PERLLOCAL=1
@ -70,10 +84,28 @@ sed -i 's/\r//' README t/*
%install
%{make_install}
# Install tests
mkdir -p %{buildroot}%{_libexecdir}/%{name}
cp -a t %{buildroot}%{_libexecdir}/%{name}
rm %{buildroot}%{_libexecdir}/%{name}/t/00_pod.t
cat > %{buildroot}%{_libexecdir}/%{name}/test << 'EOF'
#!/bin/bash
# t/20_unknown.t writes to CWD
DIR=$(mktemp -d)
cp -a %{_libexecdir}/%{name}/t "$DIR"
unset PERL_JSON_BACKEND PERL_JSON_DEBUG PERL_JSON_PP_USE_B
pushd "$DIR"
prove -I . -j "$(getconf _NPROCESSORS_ONLN)"
popd
rm -r "$DIR"
EOF
chmod +x %{buildroot}%{_libexecdir}/%{name}/test
# Correct permissions
%{_fixperms} -c %{buildroot}
%check
unset PERL_JSON_BACKEND PERL_JSON_DEBUG PERL_JSON_PP_USE_B
export HARNESS_OPTIONS=j$(perl -e 'if ($ARGV[0] =~ /.*-j([0-9][0-9]*).*/) {print $1} else {print 1}' -- '%{?_smp_mflags}')
%{make_build} test
%files
@ -81,7 +113,13 @@ unset PERL_JSON_BACKEND PERL_JSON_DEBUG PERL_JSON_PP_USE_B
%{perl_vendorlib}/*
%{_mandir}/man3/*
%files tests
%{_libexecdir}/%{name}
%changelog
* Mon Feb 22 2021 Petr Pisar <ppisar@redhat.com> - 4.03-3
- Package tests manually
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 4.03-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild