From e60fc1d181efb950437b4aa78ebdc132a9a668fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= Date: Fri, 26 Mar 2021 18:08:41 +0100 Subject: [PATCH] Package tests --- perl-PPIx-Regexp.rpmlintrc | 4 ++++ perl-PPIx-Regexp.spec | 42 +++++++++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 perl-PPIx-Regexp.rpmlintrc diff --git a/perl-PPIx-Regexp.rpmlintrc b/perl-PPIx-Regexp.rpmlintrc new file mode 100644 index 0000000..825c2e3 --- /dev/null +++ b/perl-PPIx-Regexp.rpmlintrc @@ -0,0 +1,4 @@ +from Config import * +addFilter("-tests\.noarch: W: no-documentation") +# This is a document, not a code +addFilter("-tests\.noarch: E: non-executable-script .*/eg/predump") diff --git a/perl-PPIx-Regexp.spec b/perl-PPIx-Regexp.spec index a5e4113..559d280 100644 --- a/perl-PPIx-Regexp.spec +++ b/perl-PPIx-Regexp.spec @@ -51,19 +51,41 @@ Requires: perl(PPI::Document) >= 1.117 Requires: perl(PPI::Dumper) >= 1.117 Requires: perl(Task::Weaken) -%global __requires_exclude %{?__requires_exclude:%__requires_exclude|}perl\\(PPI::Document\\)$ +%global __requires_exclude %{?__requires_exclude:%__requires_exclude|}^perl\\(PPI::Document\\)$ +# Filter private modules +%global __requires_exclude %{__requires_exclude}|^perl\\(My::Module:: +%global __provides_exclude %{?__provides_exclude:%__provides_exclude|}^perl\\(My::Module:: %description The purpose of the PPIx-Regexp package is to parse regular expressions in a manner similar to the way the PPI package parses Perl. This class forms the root of the parse tree, playing a role similar to PPI::Document. +%package tests +Summary: Tests for %{name} +Requires: %{name} = %{?epoch:%{epoch}:}%{version}-%{release} +Requires: perl-Test-Harness +Requires: perl(open) +Requires: perl(PPI::Document) >= 1.117 +%if %{with perl_PPIx_Regexp_enables_optional_test} +Requires: perl(Time::HiRes) +%endif + +%description tests +Tests from %{name}. Execute them +with "%{_libexecdir}/%{name}/test". + %prep %setup -q -n PPIx-Regexp-%{version} chmod -x eg/* perl -MConfig -i -p \ -e 's{^#!/usr/(?:local/bin/|bin/env )perl\b}{$Config{startperl}}' \ eg/* +# Help generators to recognize Perl scripts +for F in t/*.t; do + perl -i -MConfig -ple 'print $Config{startperl} if $. == 1 && !s{\A#!\s*perl}{$Config{startperl}}' "$F" + chmod +x "$F" +done %build unset MAKING_MODULE_DISTRIBUTION @@ -73,9 +95,23 @@ 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} +mkdir -p %{buildroot}%{_libexecdir}/%{name}/inc/My/Module +cp -a inc/My/Module/{Mock_Tokenizer,Test}.pm %{buildroot}%{_libexecdir}/%{name}/inc/My/Module +mkdir -p %{buildroot}%{_libexecdir}/%{name}/eg +cp -a eg/predump %{buildroot}%{_libexecdir}/%{name}/eg +cat > %{buildroot}%{_libexecdir}/%{name}/test << 'EOF' +#!/bin/sh +unset AUTHOR_TESTING PPIX_REGEXP_TOKENIZER_TRACE +cd %{_libexecdir}/%{name} && exec prove -I . -j "$(getconf _NPROCESSORS_ONLN)" +EOF +chmod +x %{buildroot}%{_libexecdir}/%{name}/test %check unset AUTHOR_TESTING PPIX_REGEXP_TOKENIZER_TRACE +export HARNESS_OPTIONS=j$(perl -e 'if ($ARGV[0] =~ /.*-j([0-9][0-9]*).*/) {print $1} else {print 1}' -- '%{?_smp_mflags}') make test %files @@ -84,9 +120,13 @@ make test %{perl_vendorlib}/* %{_mandir}/man3/* +%files tests +%{_libexecdir}/%{name} + %changelog * Fri Mar 26 2021 Petr Pisar - 0.079-1 - 0.079 bump +- Package tests * Fri Jan 29 2021 Petr Pisar - 0.078-1 - 0.078 bump