Package tests

epel9
Petr Písař 3 years ago
parent 1645853ad3
commit 2ab8df0b83

@ -0,0 +1,54 @@
From 606062e885f6ad39b50d300b1b0f4ddbbeebdbc0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Wed, 15 Dec 2021 15:41:08 +0100
Subject: [PATCH] Allow tests to run from a read-only location
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The tests creatd ./dist directory and later a temporary directetory
inside. This broken when running from a read-only location:
t/02_assert.t ... Error in tempdir() using dist/XXXXXXXXXX: Parent directory (dist) does not exist at t/02_assert.t line 11.
# Looks like your test exited with 2 before it could output anything.
t/02_assert.t ... Dubious, test returned 2 (wstat 512, 0x200)
This patch fixes it. It also fixes the strayed ./dist directory.
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
t/01_dist.t | 3 +--
t/02_assert.t | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/t/01_dist.t b/t/01_dist.t
index f22a91b..3968140 100644
--- a/t/01_dist.t
+++ b/t/01_dist.t
@@ -6,8 +6,7 @@ use File::Path qw[rmtree];
use Capture::Tiny qw[capture_merged];
{
-mkdir 'dist';
-my $tmpdir = tempdir( DIR => 'dist', CLEANUP => 1 );
+my $tmpdir = tempdir( CLEANUP => 1 );
chdir $tmpdir or die "$!\n";
open MFPL, '>Makefile.PL' or die "$!\n";
print MFPL <<'EOF';
diff --git a/t/02_assert.t b/t/02_assert.t
index a7fa98d..a652c70 100644
--- a/t/02_assert.t
+++ b/t/02_assert.t
@@ -6,8 +6,7 @@ use File::Path qw[rmtree];
use Capture::Tiny qw[capture_merged];
{
-mkdir 'dist';
-my $tmpdir = tempdir( DIR => 'dist', CLEANUP => 1 );
+my $tmpdir = tempdir( CLEANUP => 1 );
chdir $tmpdir or die "$!\n";
open MFPL, '>Makefile.PL' or die "$!\n";
print MFPL <<'EOF';
--
2.31.1

@ -5,6 +5,8 @@ Summary: Module::Install extension to check that a library is available
License: GPL+ or Artistic
URL: https://metacpan.org/release/Module-Install-CheckLib
Source0: https://cpan.metacpan.org/authors/id/B/BI/BINGOS/Module-Install-CheckLib-%{version}.tar.gz
# Fix tests to work from a read-only location, CPAN RT#140485
Patch0: Module-Install-CheckLib-0.12-Allow-tests-to-run-from-a-read-only-location.patch
BuildArch: noarch
BuildRequires: coreutils
# glibc-common for iconv
@ -12,6 +14,7 @@ BuildRequires: glibc-common
BuildRequires: make
BuildRequires: perl-generators
BuildRequires: perl-interpreter
BuildRequires: perl(Config)
BuildRequires: perl(inc::Module::Install)
BuildRequires: perl(lib)
BuildRequires: perl(Module::Install::AutoLicense)
@ -41,7 +44,7 @@ Requires: perl(Devel::CheckLib) >= 0.7
Requires: perl(Module::Install::Base) >= 0.99
# Remove under-specified dependencies
%global __requires_exclude %{?__requires_exclude:%__requires_exclude|}^perl\\(Module::Install::Base\\)$
%global __requires_exclude %{?__requires_exclude:%__requires_exclude|}^perl\\((Capture::Tiny|Module::Install::Base|Test::More)\\)$
%description
Module::Install::CheckLib is a Module::Install extension that integrates
@ -49,11 +52,28 @@ Devel::CheckLib so that CPAN authors may stipulate which particular C
library and its headers they want available and to exit the Makefile.PL
gracefully if they aren't.
%package tests
Summary: Tests for %{name}
Requires: %{name} = %{?epoch:%{epoch}:}%{version}-%{release}
Requires: perl-Test-Harness
Requires: perl(Capture::Tiny) >= 0.05
Requires: perl(Test::More) >= 0.47
%description tests
Tests from %{name}. Execute them
with "%{_libexecdir}/%{name}/test".
%prep
%setup -q -n Module-Install-CheckLib-%{version}
%autosetup -p1 -n Module-Install-CheckLib-%{version}
# Remove bundled modules
rm -r ./inc
perl -i -ne 'print $_ unless m{^inc/}' MANIFEST
# 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
perl Makefile.PL INSTALLDIRS=vendor NO_PACKLIST=1 NO_PERLLOCAL=1
@ -66,9 +86,19 @@ mv README.utf8 README
%install
%{make_install}
%{_fixperms} $RPM_BUILD_ROOT/*
%{_fixperms} %{buildroot}/*
# Install tests
mkdir -p %{buildroot}%{_libexecdir}/%{name}
cp -a t %{buildroot}%{_libexecdir}/%{name}
rm %{buildroot}%{_libexecdir}/%{name}/t/99_pod*
cat > %{buildroot}%{_libexecdir}/%{name}/test << 'EOF'
#!/bin/sh
cd %{_libexecdir}/%{name} && exec prove -I . -j "$(getconf _NPROCESSORS_ONLN)"
EOF
chmod +x %{buildroot}%{_libexecdir}/%{name}/test
%check
export HARNESS_OPTIONS=j$(perl -e 'if ($ARGV[0] =~ /.*-j([0-9][0-9]*).*/) {print $1} else {print 1}' -- '%{?_smp_mflags}')
make test
%files
@ -77,9 +107,13 @@ make test
%{perl_vendorlib}/*
%{_mandir}/man3/*
%files tests
%{_libexecdir}/%{name}
%changelog
* Wed Dec 15 2021 Petr Pisar <ppisar@redhat.com> - 0.12-16
- Modernize a spec file
- Package tests
* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.12-15
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

Loading…
Cancel
Save