From 576e4e987980b6f736bed9f71ec65b6dfc9f09db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Josef=20=C5=A0pa=C4=8Dek?= Date: Sat, 13 Jul 2024 12:57:13 +0200 Subject: [PATCH] Package tests --- .fmf/version | 1 + 0001-Fix_internal_packages.patch | 26 +++++++++++ 0002-Rename_internal_test_name.patch | 66 ++++++++++++++++++++++++++++ perl-IO-All.spec | 46 ++++++++++++++++++- plans/sanity.fmf | 5 +++ tests/upstream-tests.fmf | 12 +++++ 6 files changed, 154 insertions(+), 2 deletions(-) create mode 100644 .fmf/version create mode 100644 0001-Fix_internal_packages.patch create mode 100644 0002-Rename_internal_test_name.patch create mode 100644 plans/sanity.fmf create mode 100644 tests/upstream-tests.fmf 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/0001-Fix_internal_packages.patch b/0001-Fix_internal_packages.patch new file mode 100644 index 0000000..6908168 --- /dev/null +++ b/0001-Fix_internal_packages.patch @@ -0,0 +1,26 @@ +diff -r -u IO-All-0.87.orig/t/inline_subclass.t IO-All-0.87/t/inline_subclass.t +--- IO-All-0.87.orig/t/inline_subclass.t 2024-07-12 23:29:29.589115127 +0200 ++++ IO-All-0.87/t/inline_subclass.t 2024-07-12 23:30:02.370263343 +0200 +@@ -9,7 +9,8 @@ + + sub io { return IO::Dumper->new(@_) }; + +-package IO::All::Filesys; ++package ++ IO::All::Filesys; + sub dump { + my $self = shift; + $self->print(Data::Dumper::Dumper(@_)); +diff -r -u IO-All-0.87.orig/t/IO_Dumper.pm IO-All-0.87/t/IO_Dumper.pm +--- IO-All-0.87.orig/t/IO_Dumper.pm 2024-07-12 23:29:29.590115131 +0200 ++++ IO-All-0.87/t/IO_Dumper.pm 2024-07-12 23:29:43.273176997 +0200 +@@ -7,7 +7,8 @@ + + sub io { return IO_Dumper->new(@_) }; + +-package IO::All::Filesys; ++package ++ IO::All::Filesys; + use Data::Dumper; + sub dump { + my $self = shift; diff --git a/0002-Rename_internal_test_name.patch b/0002-Rename_internal_test_name.patch new file mode 100644 index 0000000..fce3246 --- /dev/null +++ b/0002-Rename_internal_test_name.patch @@ -0,0 +1,66 @@ +diff -r -u IO-All-0.87.orig/t/read.t IO-All-0.87/t/read.t +--- IO-All-0.87.orig/t/read.t 2024-07-12 23:29:29.594115149 +0200 ++++ IO-All-0.87/t/read.t 2024-07-13 12:43:44.872734094 +0200 +@@ -6,7 +6,7 @@ + + my $outfile = "$t/out.pm"; + ok(not -f $outfile); +-my $input = io('lib/IO/All.pm')->open; ++my $input = io('lib/IO/All.pod')->open; + ok(ref $input); + my $output = io($outfile)->open('>'); + ok(ref $output); +@@ -17,7 +17,7 @@ + $output->write while $input->read; + ok(not length($buffer)); + ok($output->close); +-test_matching_files($outfile, 'lib/IO/All.pm'); ++test_matching_files($outfile, 'lib/IO/All.pod'); + ok($output->unlink); + + del_output_dir(); +diff -r -u IO-All-0.87.orig/t/read_write.t IO-All-0.87/t/read_write.t +--- IO-All-0.87.orig/t/read_write.t 2024-07-12 23:29:29.590115131 +0200 ++++ IO-All-0.87/t/read_write.t 2024-07-13 12:43:52.018766082 +0200 +@@ -4,11 +4,11 @@ + use IO::All; + use IO_All_Test; + +-my $io = io('lib/IO/All.pm'); ++my $io = io('lib/IO/All.pod'); + my $buffer; + $io->buffer($buffer); + 1 while $io->read; + ok(length($buffer)); +-test_file_contents($buffer, 'lib/IO/All.pm'); ++test_file_contents($buffer, 'lib/IO/All.pod'); + + del_output_dir(); +diff -r -u IO-All-0.87.orig/t/synopsis2.t IO-All-0.87/t/synopsis2.t +--- IO-All-0.87.orig/t/synopsis2.t 2024-07-12 23:29:29.591115136 +0200 ++++ IO-All-0.87/t/synopsis2.t 2024-07-13 11:56:28.923878422 +0200 +@@ -1,5 +1,5 @@ + use strict; use warnings; +-my $t; use lib ($t = -e 't' ? 't' : 'test'); ++my $t; use lib ($t = -e 't' ? 't' : '_test'); + use Test::More tests => 10; + use IO::All; + use IO_All_Test; +@@ -16,7 +16,7 @@ + + for my $line (sort @results) { + my $dataline = ; +- $dataline =~ s/^t\//test\// if -e 'test'; ++ $dataline =~ s/^t\//_test\// if -e '_test'; + is($line, flip_slash $dataline); + } + +@@ -26,7 +26,7 @@ + grep {! /CVS|\.svn/} io("$t/mydir")->all_files(0) + ) { + my $dataline = ; +- $dataline =~ s/^t\//test\// if -e 'test'; ++ $dataline =~ s/^t\//_test\// if -e '_test'; + is("$_\n", flip_slash $dataline) + } + diff --git a/perl-IO-All.spec b/perl-IO-All.spec index 17f38f7..72aa7e2 100644 --- a/perl-IO-All.spec +++ b/perl-IO-All.spec @@ -15,11 +15,14 @@ Name: perl-IO-All Version: 0.87 -Release: 23%{?dist} +Release: 24%{?dist} Summary: IO::All Perl module License: GPL-1.0-or-later OR Artistic-1.0-Perl URL: https://metacpan.org/release/IO-All Source0: https://cpan.metacpan.org/authors/id/F/FR/FREW/IO-All-%{version}.tar.gz +# Both patches are for *-tests package +Patch0: 0001-Fix_internal_packages.patch +Patch1: 0002-Rename_internal_test_name.patch BuildArch: noarch # Module Build BuildRequires: coreutils @@ -27,6 +30,7 @@ BuildRequires: findutils BuildRequires: make BuildRequires: perl-generators BuildRequires: perl-interpreter +BuildRequires: perl(Config) BuildRequires: perl(ExtUtils::MakeMaker) # Module Runtime BuildRequires: perl(Carp) @@ -54,7 +58,6 @@ BuildRequires: perl(Tie::File) BuildRequires: perl(warnings) # Test Suite BuildRequires: perl(base) -BuildRequires: perl(Config) BuildRequires: perl(Data::Dumper) BuildRequires: perl(diagnostics) BuildRequires: perl(Exporter) @@ -87,6 +90,10 @@ Recommends: perl(MLDBM) Requires: perl(Tie::File) Requires: perl(warnings) +# Remove private test modules +%global __requires_exclude %{?__requires_exclude:%__requires_exclude|}^perl\\(IO_All_Test|IO_Dumper\\)$ +%global __provides_exclude %{?__provides_exclude:%__provides_exclude|}^perl\\(IO_All_Test|IO_Dumper\\)$ + %description The IO::All object is a proxy for IO::File, IO::Dir, IO::Socket, IO::String, Tie::File, File::Spec, File::Path and File::ReadBackwards; as @@ -95,9 +102,25 @@ found in these classes and in IO::Handle (which they inherit from). IO::All adds dozens of other helpful idiomatic methods including file stat and manipulation functions. +%package tests +Summary: Tests for %{name} +Requires: %{name} = %{?epoch:%{epoch}:}%{version}-%{release} +Requires: perl-Test-Harness + +%description tests +Tests from %{name}. Execute them +with "%{_libexecdir}/%{name}/test". + %prep %setup -q -n IO-All-%{version} +%patch -P0 -p1 +%patch -P1 -p1 find -type f -perm /0100 -name '*.pm' -exec chmod -c a-x {} \; +# Help generators to recognize Perl scripts +for F in t/*.t; do + perl -i -MConfig -ple 'print $Config{startperl} if $. == 1 && !s{\A#!.*perl\b}{$Config{startperl}}' "$F" + chmod +x "$F" +done %build perl Makefile.PL INSTALLDIRS=vendor @@ -107,6 +130,19 @@ make %{?_smp_mflags} make pure_install DESTDIR=%{buildroot} find %{buildroot} -type f -name .packlist -delete %{_fixperms} -c %{buildroot} +# Install tests +mkdir -p %{buildroot}%{_libexecdir}/%{name} +cp -a t %{buildroot}%{_libexecdir}/%{name} +# Use lib directory for testing purposes +mkdir -p %{buildroot}%{_libexecdir}/%{name}/lib/IO +cp -a lib/IO/All.pod %{buildroot}%{_libexecdir}/%{name}/lib/IO +# Remove 000-compile-modules.t which is testing on t/lib dir which we haven't. +rm -f %{buildroot}%{_libexecdir}/%{name}/t/000-compile-modules.t +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 %if %{with perl_IO_All_enables_extra_test} @@ -133,7 +169,13 @@ make %{?_smp_mflags} test %{_mandir}/man3/IO::All::String.3* %{_mandir}/man3/IO::All::Temp.3* +%files tests +%{_libexecdir}/%{name} + %changelog +* Fri Jul 12 2024 Michal Josef Špaček - 0.87-24 +- Package tests + * Mon Jun 24 2024 Troy Dawson - 0.87-23 - Bump release for June 2024 mass rebuild 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..d76c696 --- /dev/null +++ b/tests/upstream-tests.fmf @@ -0,0 +1,12 @@ +summary: Upstream tests +contact: Michal Josef Spacek +component: perl-IO-All +require: perl-IO-All-tests +test: /usr/libexec/perl-IO-All/test +enabled: true +tag: + - rhel-buildroot +adjust: + - enabled: false + when: distro < rhel-10 or distro < centos-stream-10 + continue: false