Package tests

This commit is contained in:
Jitka Plesnikova 2023-01-30 12:20:12 +01:00
parent 2c38c01f91
commit 1cf1ec95ec
5 changed files with 70 additions and 1 deletions

1
.fmf/version Normal file
View File

@ -0,0 +1 @@
1

7
gating.yaml Normal file
View File

@ -0,0 +1,7 @@
--- !Policy
product_versions:
- fedora-*
decision_context: bodhi_update_push_stable
subject_type: koji_build
rules:
- !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional}

View File

@ -65,6 +65,29 @@ Requires: perl(IPC::System::Simple) >= 0.12
# Remove falsely detected perl(lib) # Remove falsely detected perl(lib)
%global __requires_exclude %{?__requires_exclude:%__requires_exclude|}^perl\\(lib\\)$ %global __requires_exclude %{?__requires_exclude:%__requires_exclude|}^perl\\(lib\\)$
# Filter modules bundled for tests
%global __provides_exclude_from %{?__provides_exclude_from:%__provides_exclude_from|}^%{_libexecdir}
%global __requires_exclude %{__requires_exclude}|^perl\\(autodie::test.*\\)
%global __requires_exclude %{__requires_exclude}|^perl\\(autodie_.*\\)
%global __requires_exclude %{__requires_exclude}|^perl\\(Caller_helper\\)
%global __requires_exclude %{__requires_exclude}|^perl\\(Hints_.*\\)
%global __requires_exclude %{__requires_exclude}|^perl\\(lethal\\)
%global __requires_exclude %{__requires_exclude}|^perl\\(my::.*\\)
%global __requires_exclude %{__requires_exclude}|^perl\\(Some::Module\\)
%package tests
Summary: Tests for %{name}
Requires: %{name} = %{?epoch:%{epoch}:}%{version}-%{release}
Requires: perl-Test-Harness
%if %{with perl_autodie_enables_optional_test} && !%{defined perl_bootstrap}
Requires: perl(BSD::Resource)
Requires: perl(Import::Into) >= 1.002004
%endif
%description tests
Tests from %{name}. Execute them
with "%{_libexecdir}/%{name}/test".
%description %description
The "autodie" and "Fatal" pragma provides a convenient way to replace The "autodie" and "Fatal" pragma provides a convenient way to replace
functions that normally return false on failure with equivalents that throw an functions that normally return false on failure with equivalents that throw an
@ -77,16 +100,41 @@ autodie in preference to "Fatal".
%setup -q -n autodie-%{version} %setup -q -n autodie-%{version}
find -type f -exec chmod -x {} + find -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#!.*perl\b}{$Config{startperl}}' "$F"
chmod +x "$F"
done
%build %build
perl Makefile.PL INSTALLDIRS=vendor NO_PACKLIST=1 NO_PERLLOCAL=1 perl Makefile.PL INSTALLDIRS=vendor NO_PACKLIST=1 NO_PERLLOCAL=1
%{make_build} %{make_build}
%install %install
%{make_install} %{make_install}
%{_fixperms} $RPM_BUILD_ROOT/* %{_fixperms} %{buildroot}/*
# Install tests
mkdir -p %{buildroot}%{_libexecdir}/%{name}
cp -a t %{buildroot}%{_libexecdir}/%{name}
cat > %{buildroot}%{_libexecdir}/%{name}/test << 'EOF'
#!/bin/bash
set -e
unset AUTHOR_TESTING AUTOMATED_TESTING PERL_CORE RELEASE_TESTING
# Some tests write into temporary files/directories. The solution is to
# copy the tests into a writable directory and execute them from there.
DIR=$(mktemp -d)
pushd "$DIR"
cp -a %{_libexecdir}/%{name}/* ./
prove -I . -j "$(getconf _NPROCESSORS_ONLN)"
popd
rm -rf "$DIR"
EOF
chmod +x %{buildroot}%{_libexecdir}/%{name}/test
%check %check
unset AUTHOR_TESTING AUTOMATED_TESTING PERL_CORE RELEASE_TESTING unset AUTHOR_TESTING AUTOMATED_TESTING PERL_CORE RELEASE_TESTING
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
@ -95,9 +143,13 @@ make test
%{perl_vendorlib}/* %{perl_vendorlib}/*
%{_mandir}/man3/* %{_mandir}/man3/*
%files tests
%{_libexecdir}/%{name}
%changelog %changelog
* Mon Jan 30 2023 Jitka Plesnikova <jplesnik@redhat.com> - 2.35-1 * Mon Jan 30 2023 Jitka Plesnikova <jplesnik@redhat.com> - 2.35-1
- 2.35 bump - 2.35 bump
- Package tests
* Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 2.34-491 * Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 2.34-491
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

5
plans/sanity.fmf Normal file
View File

@ -0,0 +1,5 @@
summary: Sanity tests
discover:
how: fmf
execute:
how: tmt

4
tests/upstream-tests.fmf Normal file
View File

@ -0,0 +1,4 @@
summary: Upstream tests
component: perl-autodie
require: perl-autodie-tests
test: /usr/libexec/perl-autodie/test