From d269c753a1ddd393eac6cd59b538165ad3570a3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= Date: Fri, 19 Mar 2021 09:00:35 +0100 Subject: [PATCH] Package tests --- perl-Net-HTTP.rpmlintrc | 2 ++ perl-Net-HTTP.spec | 40 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 perl-Net-HTTP.rpmlintrc diff --git a/perl-Net-HTTP.rpmlintrc b/perl-Net-HTTP.rpmlintrc new file mode 100644 index 0000000..9ea2894 --- /dev/null +++ b/perl-Net-HTTP.rpmlintrc @@ -0,0 +1,2 @@ +from Config import * +addFilter("-tests\.noarch: W: no-documentatio"); diff --git a/perl-Net-HTTP.spec b/perl-Net-HTTP.spec index 28f1d09..a007e40 100644 --- a/perl-Net-HTTP.spec +++ b/perl-Net-HTTP.spec @@ -18,6 +18,7 @@ BuildRequires: make BuildRequires: perl-generators BuildRequires: perl-interpreter BuildRequires: perl(:VERSION) >= 5.6.2 +BuildRequires: perl(Config) BuildRequires: perl(ExtUtils::MakeMaker) >= 6.76 BuildRequires: perl(Getopt::Long) BuildRequires: perl(strict) @@ -32,6 +33,7 @@ BuildRequires: perl(IO::Socket::IP) BuildRequires: perl(IO::Socket) %endif %if %{with perl_Net_HTTP_enables_ssl} +# IO::Socket::SSL or Net::SSL BuildRequires: perl(IO::Socket::SSL) >= 2.012 %endif BuildRequires: perl(IO::Uncompress::Gunzip) @@ -66,8 +68,31 @@ Net::HTTP class represents a connection to an HTTP server. The HTTP protocol is described in RFC 2616. The Net::HTTP class supports HTTP/1.0 and HTTP/1.1. +%package tests +Summary: Tests for %{name} +Requires: %{name} = %{?epoch:%{epoch}:}%{version}-%{release} +Requires: perl-Test-Harness +%if %{with perl_Net_HTTP_enables_network_test} +%if %{with perl_Net_HTTP_enables_ssl} +Requires: perl(IO::Socket::SSL) >= 2.012 +%endif +%endif + +%description tests +Tests from %{name}. Execute them +with "%{_libexecdir}/%{name}/test". + %prep %setup -q -n Net-HTTP-%{version} +%if %{without perl_Net_HTTP_enables_network_test} +rm t/live*.t +perl -i -ne 'print $_ unless m{^t/live.*\.t}' MANIFEST +%endif +# Help generators to recognize a Perl code +for F in t/*.t; do + perl -i -MConfig -pe 'print qq{$Config{startperl}\n} if $. == 1 && !s{\A#!.*\bperl}{$Config{startperl}}' "$F" + chmod +x "$F" +done %build perl Makefile.PL INSTALLDIRS=vendor NO_PACKLIST=1 NO_PERLLOCAL=1 @@ -76,9 +101,18 @@ perl Makefile.PL INSTALLDIRS=vendor NO_PACKLIST=1 NO_PERLLOCAL=1 %install %{make_install} %{_fixperms} $RPM_BUILD_ROOT/* +# Install tests +mkdir -p %{buildroot}%{_libexecdir}/%{name} +cp -a t %{buildroot}%{_libexecdir}/%{name} +cat > %{buildroot}%{_libexecdir}/%{name}/test << 'EOF' +#!/bin/sh +set -e +cd %{_libexecdir}/%{name} && exec prove -I . -j "$(getconf _NPROCESSORS_ONLN)" +EOF +chmod +x %{buildroot}%{_libexecdir}/%{name}/test %check -export NO_NETWORK_TESTING=%{without perl_Net_HTTP_enables_network_test} +export HARNESS_OPTIONS=j$(perl -e 'if ($ARGV[0] =~ /.*-j([0-9][0-9]*).*/) {print $1} else {print 1}' -- '%{?_smp_mflags}') make test %files @@ -87,9 +121,13 @@ make test %{perl_vendorlib}/* %{_mandir}/man3/* +%files tests +%{_libexecdir}/%{name} + %changelog * Fri Mar 19 2021 Petr Pisar - 6.21-1 - 6.21 bump +- Package tests * Wed Jan 27 2021 Fedora Release Engineering - 6.20-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild