Package tests

epel9
Petr Písař 4 years ago
parent 355eaf48a6
commit e60fc1d181

@ -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")

@ -51,19 +51,41 @@ Requires: perl(PPI::Document) >= 1.117
Requires: perl(PPI::Dumper) >= 1.117 Requires: perl(PPI::Dumper) >= 1.117
Requires: perl(Task::Weaken) 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 %description
The purpose of the PPIx-Regexp package is to parse regular expressions in a 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 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. 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 %prep
%setup -q -n PPIx-Regexp-%{version} %setup -q -n PPIx-Regexp-%{version}
chmod -x eg/* chmod -x eg/*
perl -MConfig -i -p \ perl -MConfig -i -p \
-e 's{^#!/usr/(?:local/bin/|bin/env )perl\b}{$Config{startperl}}' \ -e 's{^#!/usr/(?:local/bin/|bin/env )perl\b}{$Config{startperl}}' \
eg/* 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 %build
unset MAKING_MODULE_DISTRIBUTION unset MAKING_MODULE_DISTRIBUTION
@ -73,9 +95,23 @@ perl Makefile.PL INSTALLDIRS=vendor NO_PACKLIST=1 NO_PERLLOCAL=1
%install %install
%{make_install} %{make_install}
%{_fixperms} $RPM_BUILD_ROOT/* %{_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 %check
unset AUTHOR_TESTING PPIX_REGEXP_TOKENIZER_TRACE 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 make test
%files %files
@ -84,9 +120,13 @@ make test
%{perl_vendorlib}/* %{perl_vendorlib}/*
%{_mandir}/man3/* %{_mandir}/man3/*
%files tests
%{_libexecdir}/%{name}
%changelog %changelog
* Fri Mar 26 2021 Petr Pisar <ppisar@redhat.com> - 0.079-1 * Fri Mar 26 2021 Petr Pisar <ppisar@redhat.com> - 0.079-1
- 0.079 bump - 0.079 bump
- Package tests
* Fri Jan 29 2021 Petr Pisar <ppisar@redhat.com> - 0.078-1 * Fri Jan 29 2021 Petr Pisar <ppisar@redhat.com> - 0.078-1
- 0.078 bump - 0.078 bump

Loading…
Cancel
Save