Package tests

This commit is contained in:
Michal Josef Špaček 2022-03-04 12:48:06 +01:00
parent 3f004bf7ff
commit eb605a445c
5 changed files with 44 additions and 0 deletions

1
.fmf/version Normal file
View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,2 @@
from Config import *
addFilter("-tests.noarch: W: no-documentation");

View File

@ -8,7 +8,9 @@ Source0: https://cpan.metacpan.org/authors/id/O/OA/OALDERS/HTTP-Daemon-%{
# Use Makefile.PL without unneeded dependencies
Patch0: HTTP-Daemon-6.04-EU-MM-is-not-deprecated.patch
BuildArch: noarch
BuildRequires: coreutils
BuildRequires: make
BuildRequires: findutils
BuildRequires: perl-generators
BuildRequires: perl-interpreter
BuildRequires: perl(:VERSION) >= 5.6
@ -56,9 +58,27 @@ Instances of the HTTP::Daemon class are HTTP/1.1 servers that listen on a
socket for incoming requests. The HTTP::Daemon is a subclass of
IO::Socket::IP, so you can perform socket operations directly on it too.
%package tests
Summary: Tests for %{name}
Requires: %{name} = %{?epoch:%{epoch}:}%{version}-%{release}
Requires: perl-Test-Harness
# perl-generators doesn't detect 'use Test::Needs 'LWP::RobotUA';'
Requires: perl(LWP::RobotUA)
# perl-generators doesn't detect 'use Test::Needs 'LWP::UserAgent';'
Requires: perl(LWP::UserAgent)
%description tests
Tests from %{name}. Execute them
with "%{_libexecdir}/%{name}/test".
%prep
%setup -q -n HTTP-Daemon-%{version}
%patch0 -p1
# Help generators to recognize Perl scripts
for F in $(find t/ -name '*.t'); do
perl -i -MConfig -ple 'print $Config{startperl} if $. == 1 && !s{\A#!\s*perl}{$Config{startperl}}' "$F"
chmod +x "$F"
done
%build
perl Makefile.PL INSTALLDIRS=vendor NO_PACKLIST=1 NO_PERLLOCAL=1
@ -66,6 +86,14 @@ perl Makefile.PL INSTALLDIRS=vendor NO_PACKLIST=1 NO_PERLLOCAL=1
%install
%{make_install}
# Install tests
mkdir -p %{buildroot}%{_libexecdir}/%{name}
cp -a t %{buildroot}%{_libexecdir}/%{name}
cat > %{buildroot}%{_libexecdir}/%{name}/test << 'EOF'
#!/bin/sh
cd %{_libexecdir}/%{name} && exec prove -I . -j "$(getconf _NPROCESSORS_ONLN)" -r
EOF
chmod +x %{buildroot}%{_libexecdir}/%{name}/test
%{_fixperms} %{buildroot}/*
%check
@ -77,9 +105,13 @@ make test
%{perl_vendorlib}/*
%{_mandir}/man3/*
%files tests
%{_libexecdir}/%{name}
%changelog
* Fri Mar 04 2022 Michal Josef Špaček <mspacek@redhat.com> - 6.14-1
- 6.14 bump
- Package unit tests
* Thu Feb 10 2022 Michal Josef Špaček <mspacek@redhat.com> - 6.13-1
- 6.13 bump

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-HTTP-Daemon
require: perl-HTTP-Daemon-tests
test: /usr/libexec/perl-HTTP-Daemon/test