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/perl-HTTP-Daemon.rpmlintrc b/perl-HTTP-Daemon.rpmlintrc new file mode 100644 index 0000000..3c67f8c --- /dev/null +++ b/perl-HTTP-Daemon.rpmlintrc @@ -0,0 +1,2 @@ +from Config import * +addFilter("-tests.noarch: W: no-documentation"); diff --git a/perl-HTTP-Daemon.spec b/perl-HTTP-Daemon.spec index a98b451..73939e4 100644 --- a/perl-HTTP-Daemon.spec +++ b/perl-HTTP-Daemon.spec @@ -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 - 6.14-1 - 6.14 bump +- Package unit tests * Thu Feb 10 2022 Michal Josef Špaček - 6.13-1 - 6.13 bump 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..6149e87 --- /dev/null +++ b/tests/upstream-tests.fmf @@ -0,0 +1,4 @@ +summary: Upstream tests +component: perl-HTTP-Daemon +require: perl-HTTP-Daemon-tests +test: /usr/libexec/perl-HTTP-Daemon/test