Package the tests

epel9
Petr Písař 3 years ago
parent 54a1f3bbb1
commit d2a397f078

@ -0,0 +1,159 @@
From 7659698f13d3aa5b2fc7dfea81c8c5c38e1316cd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Thu, 3 Mar 2022 12:47:19 +0100
Subject: [PATCH] Use File::Path for creating temporary directories in the
tests
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The tests used to create a temporary tree under a working directory.
But that does not work if that location is read-only:
$ perl t/01syntax.t
Uncaught exception from user code:
_Inline_01syntax.17483: Permission denied
BEGIN failed--compilation aborted at /usr/libexec/perl-Inline-C/t/TestInlineSetup.pm line 30.
Compilation failed in require at t/01syntax.t line 6.
BEGIN failed--compilation aborted at t/01syntax.t line 6.
Also the code tried hard to pick up a unique name to allow testing in
parallel. And then cleaning up when exiting.
This patch replaced that code with File::Temp. Not only it replaces
complex code, it also enables testing from a read only location
because File::Test utilizes a system-wide temporary path.
I cannot test it on Win32 platform. But I believe it should correctly
work there because the cleanup is performed when the File::Temp object
goes out of scope which should be after END block.
Petr Písař: Ported to 0.82 tar ball release.
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
Makefile.PL | 2 ++
t/03typemap.t | 1 +
t/18quote_space.t | 12 +++---------
t/27inline_maker.t | 1 +
t/TestInlineSetup.pm | 12 ++----------
5 files changed, 9 insertions(+), 19 deletions(-)
diff --git a/Makefile.PL b/Makefile.PL
index 71abe69..5ade319 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -33,6 +33,7 @@ my %WriteMakefileArgs = (
"TEST_REQUIRES" => {
"File::Copy::Recursive" => 0,
"File::Path" => 0,
+ "File::Temp" >= "0.19",
"Test::More" => "0.88",
"Test::Warn" => "0.23",
"YAML::XS" => 0,
@@ -51,6 +52,7 @@ my %FallbackPrereqs = (
"File::Copy::Recursive" => 0,
"File::Path" => 0,
"File::Spec" => "0.8",
+ "File::Temp" >= "0.19",
"Inline" => "0.86",
"Parse::RecDescent" => "1.967009",
"Pegex" => "0.66",
diff --git a/t/03typemap.t b/t/03typemap.t
index 16e5ea2..6a07c30 100644
--- a/t/03typemap.t
+++ b/t/03typemap.t
@@ -8,6 +8,7 @@ BEGIN {
use Test::More;
use TestInlineSetup;
use Inline Config => DIRECTORY => $TestInlineSetup::DIR;
+use File::Spec;
use Inline C => DATA =>
TYPEMAPS => File::Spec->catfile($t, 'typemap');
diff --git a/t/18quote_space.t b/t/18quote_space.t
index be4e360..7b30526 100644
--- a/t/18quote_space.t
+++ b/t/18quote_space.t
@@ -1,6 +1,6 @@
use strict;
use warnings;
-use Cwd;
+use File::Temp 0.19;
require Inline::C;
@@ -126,8 +126,8 @@ else {
delete $ENV{NO_INSANE_DIRNAMES};
my $have_file_path;
-my $newdir = Cwd::getcwd();
-$newdir .= '/foo -I/';
+my $tempdir = File::Temp->newdir();
+my $newdir = $tempdir . '/foo -I/';
eval {require File::Path;};
if ($@) {
@@ -159,9 +159,3 @@ else {
warn "\n\$\@: $@\n";
print "not ok 10\n";
}
-
-
-END {
- File::Path::rmtree($newdir) if $have_file_path;
- warn "Failed to remove $newdir" if -d $newdir;
-};
diff --git a/t/27inline_maker.t b/t/27inline_maker.t
index 67b1d7f..d989e95 100644
--- a/t/27inline_maker.t
+++ b/t/27inline_maker.t
@@ -7,6 +7,7 @@ use Config;
use IPC::Cmd qw/run/;
require version;
use File::Path;
+use File::Spec;
use Cwd;
use File::Copy::Recursive qw(rcopy);
use autodie;
diff --git a/t/TestInlineSetup.pm b/t/TestInlineSetup.pm
index 8c8c93d..fd1f753 100644
--- a/t/TestInlineSetup.pm
+++ b/t/TestInlineSetup.pm
@@ -1,8 +1,7 @@
use strict; use warnings; use diagnostics;
package TestInlineSetup;
-use File::Path;
-use File::Spec;
+use File::Temp 0.19;
use constant IS_WIN32 => $^O eq 'MSWin32' ;
sub import {
@@ -22,14 +21,8 @@ BEGIN {
our $DIR;
BEGIN {
- ($_, $DIR) = caller(2);
- $DIR =~ s/.*?(\w+)\.t$/$1/ or die;
- $DIR = "_Inline_$DIR.$$";
- rmtree($DIR) if -d $DIR;
- mkdir($DIR) or die "$DIR: $!\n";
+ $DIR = File::Temp->newdir();
}
-my $absdir = File::Spec->rel2abs($DIR);
-($absdir) = $absdir =~ /(.*)/; # untaint
my $startpid = $$;
END {
@@ -54,7 +47,6 @@ END {
}
}
}
- rmtree($absdir);
}
}
--
2.34.1

@ -1,2 +1,4 @@
# This package builds XS modules at run-time. # This package builds XS modules at run-time.
addFilter('perl-Inline-C.noarch: E: devel-dependency perl-devel') addFilter('perl-Inline-C.noarch: E: devel-dependency perl-devel')
addFilter('perl-Inline-C-tests\.noarch: W: devel-file-in-non-devel-package')
addFilter('-tests\.noarch: W: no-documentation')

@ -8,13 +8,18 @@ Summary: Write Perl subroutines in C
License: GPL+ or Artistic License: GPL+ or Artistic
URL: https://metacpan.org/release/Inline-C URL: https://metacpan.org/release/Inline-C
Source0: https://cpan.metacpan.org/authors/id/E/ET/ETJ/Inline-C-%{version}.tar.gz Source0: https://cpan.metacpan.org/authors/id/E/ET/ETJ/Inline-C-%{version}.tar.gz
# Fix tests to work from a read-only location, proposed to an upstream,
# <https://github.com/ingydotnet/inline-c-pm/pull/102>
Patch0: Inline-C-0.82-Use-File-Path-for-creating-temporary-directories-in-.patch
BuildArch: noarch BuildArch: noarch
# Build: # Build:
BuildRequires: coreutils BuildRequires: coreutils
BuildRequires: findutils
BuildRequires: make BuildRequires: make
BuildRequires: perl-generators BuildRequires: perl-generators
BuildRequires: perl-interpreter BuildRequires: perl-interpreter
BuildRequires: perl(:VERSION) >= 5.10 BuildRequires: perl(:VERSION) >= 5.10
BuildRequires: perl(Config)
BuildRequires: perl(ExtUtils::MakeMaker) >= 7.00 BuildRequires: perl(ExtUtils::MakeMaker) >= 7.00
BuildRequires: perl(File::ShareDir::Install) BuildRequires: perl(File::ShareDir::Install)
BuildRequires: perl(strict) BuildRequires: perl(strict)
@ -23,7 +28,6 @@ BuildRequires: perl(warnings)
BuildRequires: gcc BuildRequires: gcc
BuildRequires: perl-devel BuildRequires: perl-devel
BuildRequires: perl(Carp) BuildRequires: perl(Carp)
BuildRequires: perl(Config)
BuildRequires: perl(constant) BuildRequires: perl(constant)
BuildRequires: perl(Cwd) BuildRequires: perl(Cwd)
BuildRequires: perl(Data::Dumper) BuildRequires: perl(Data::Dumper)
@ -48,6 +52,7 @@ BuildRequires: perl(Exporter)
BuildRequires: perl(File::Copy::Recursive) BuildRequires: perl(File::Copy::Recursive)
BuildRequires: perl(File::Find) BuildRequires: perl(File::Find)
BuildRequires: perl(File::Path) BuildRequires: perl(File::Path)
BuildRequires: perl(File::Temp) >= 0.19
BuildRequires: perl(Inline::MakeMaker) BuildRequires: perl(Inline::MakeMaker)
BuildRequires: perl(IPC::Cmd) BuildRequires: perl(IPC::Cmd)
BuildRequires: perl(lib) BuildRequires: perl(lib)
@ -77,15 +82,53 @@ Requires: perl(Time::HiRes)
# Split from Inline in 0.58 # Split from Inline in 0.58
Conflicts: perl-Inline < 0.58 Conflicts: perl-Inline < 0.58
%global __requires_exclude %{?__requires_exclude:%__requires_exclude|}^perl\\(File::Spec\\)$ # Remove under-specified dependencies
%global __requires_exclude %{?__requires_exclude:%__requires_exclude|}^perl\\((File::Spec|Test::More|Test::Warn|version)\\)$
# Remove private modules
%global __requires_exclude %{__requires_exclude}|^perl\\(TestInline
%global __provides_exclude %{?__provides_exclude:%{__requires_exclude}|}^perl\\(TestInline
%description %description
Inline::C is a module that allows you to write Perl subroutines in C. Since Inline::C is a module that allows you to write Perl subroutines in C. Since
version 0.30 the Inline module supports multiple programming languages and version 0.30 the Inline module supports multiple programming languages and
each language has its own support module. each language has its own support module.
%package tests
Summary: Tests for %{name}
Requires: %{name} = %{?epoch:%{epoch}:}%{version}-%{release}
Requires: perl-Test-Harness
# t/27inline_maker.t uses example/modules/Boo-2.01 that uses Inline::MakeMaker
# that generated Makefile.PL with "perl -Mblib".
Requires: perl(blib)
Requires: perl(File::Spec) >= 0.8
Requires: perl(Inline::MakeMaker)
Requires: perl(Test::More) >= 0.88
%if %{with perl_Inline_C_enables_optional_tests}
Requires: perl(Test::Warn) >= 0.23
%endif
Requires: perl(version) >= 0.77
%description tests
Tests from %{name}. Execute them
with "%{_libexecdir}/%{name}/test".
%prep %prep
%setup -q -n Inline-C-%{version} %autosetup -p1 -n Inline-C-%{version}
%if !%{with perl_Inline_C_enables_optional_tests}
rm t/08taint.t
perl -i -ne 'print $_ unless m{^t/08taint\.t}' MANIFEST
%endif
# Remove author tests
rm t/author-pod-syntax.t
perl -i -ne 'print $_ unless m{^t/author-pod-syntax\.t}' MANIFEST
# Fix permissions
find example t -type f -exec chmod -x {} +
# 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
perl Makefile.PL INSTALLDIRS=vendor NO_PACKLIST=1 NO_PERLLOCAL=1 OPTIMIZE="%{optflags}" perl Makefile.PL INSTALLDIRS=vendor NO_PACKLIST=1 NO_PERLLOCAL=1 OPTIMIZE="%{optflags}"
@ -94,11 +137,34 @@ perl Makefile.PL INSTALLDIRS=vendor NO_PACKLIST=1 NO_PERLLOCAL=1 OPTIMIZE="%{opt
%install %install
%{make_install} %{make_install}
%{_fixperms} %{buildroot}/* %{_fixperms} %{buildroot}/*
# Install tests
mkdir -p %{buildroot}%{_libexecdir}/%{name}
cp -a example t %{buildroot}%{_libexecdir}/%{name}
# t/000-require-modules.t operates on modules in ./lib, symlink the tree
find lib -type d -exec mkdir '%{buildroot}%{_libexecdir}/%{name}/{}' \;
pushd lib
for F in $(find -type f -name '*.pm'); do
ln -s \
$(realpath --relative-to \
"%{buildroot}%{_libexecdir}/%{name}/lib/$(dirname $F)" \
"%{buildroot}%{perl_vendorlib}/$F") \
"%{buildroot}%{_libexecdir}/%{name}/lib/$F"
done
popd
cat > %{buildroot}%{_libexecdir}/%{name}/test << 'EOF'
#!/bin/sh
unset ACTIVEPERL_CONFIG_SILENT AUTHOR_TESTING CPATH DEBUG INCLUDE MAKEFLAGS \
PERL_INLINE_BUILD_NOISY PERL_INLINE_DEVELOPER_TEST PERL_INSTALL_ROOT \
PERL_PEGEX_AUTO_COMPILE NO_INSANE_DIRNAMES
cd %{_libexecdir}/%{name} && exec prove -I . -j "$(getconf _NPROCESSORS_ONLN)"
EOF
chmod +x %{buildroot}%{_libexecdir}/%{name}/test
%check %check
unset ACTIVEPERL_CONFIG_SILENT AUTHOR_TESTING CPATH DEBUG INCLUDE MAKEFLAGS \ unset ACTIVEPERL_CONFIG_SILENT AUTHOR_TESTING CPATH DEBUG INCLUDE MAKEFLAGS \
PERL_INLINE_BUILD_NOISY PERL_INLINE_DEVELOPER_TEST PERL_INSTALL_ROOT \ PERL_INLINE_BUILD_NOISY PERL_INLINE_DEVELOPER_TEST PERL_INSTALL_ROOT \
PERL_PEGEX_AUTO_COMPILE NO_INSANE_DIRNAMES PERL_PEGEX_AUTO_COMPILE NO_INSANE_DIRNAMES
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
@ -108,9 +174,13 @@ make test
%{perl_vendorlib}/Inline/* %{perl_vendorlib}/Inline/*
%{_mandir}/man3/* %{_mandir}/man3/*
%files tests
%{_libexecdir}/%{name}
%changelog %changelog
* Wed Mar 02 2022 Petr Pisar <ppisar@redhat.com> - 0.82-1 * Wed Mar 02 2022 Petr Pisar <ppisar@redhat.com> - 0.82-1
- 0.82 bump - 0.82 bump
- Package the tests
* Fri Jan 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.81-12 * Fri Jan 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.81-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

Loading…
Cancel
Save