From de8951c853a54378983692aef4a1ca80197e701b Mon Sep 17 00:00:00 2001 From: Jitka Plesnikova Date: Thu, 26 Jan 2023 10:19:25 +0100 Subject: [PATCH] Package tests --- .fmf/version | 1 + gating.yaml | 7 ++++++ perl-YAML-LibYAML.spec | 46 ++++++++++++++++++++++++++++++++++++++++ plans/sanity.fmf | 5 +++++ tests/upstream-tests.fmf | 4 ++++ 5 files changed, 63 insertions(+) create mode 100644 .fmf/version create mode 100644 gating.yaml 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/gating.yaml b/gating.yaml new file mode 100644 index 0000000..282e16b --- /dev/null +++ b/gating.yaml @@ -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} diff --git a/perl-YAML-LibYAML.spec b/perl-YAML-LibYAML.spec index b452311..35ffe4d 100644 --- a/perl-YAML-LibYAML.spec +++ b/perl-YAML-LibYAML.spec @@ -70,12 +70,24 @@ Requires: libyaml >= 0.2.4 # Avoid provides for perl shared objects %{?perl_default_filter} +# Filter modules bundled for tests +%global __provides_exclude_from %{?__provides_exclude_from:%__provides_exclude_from|}^%{_libexecdir} +%global __requires_exclude %{?__requires_exclude:%__requires_exclude|}^perl\\(TestYAML.*\\) %description Kirill Siminov's "libyaml" is arguably the best YAML implementation. The C library is written precisely to the YAML 1.1 specification. It was originally bound to Python and was later bound to Ruby. +%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 YAML-LibYAML-%{version} # Unbundled libyaml, the source files are the same as in libyaml-0.2.4 @@ -87,6 +99,11 @@ for file in api.c dumper.c emitter.c loader.c parser.c reader.c scanner.c \ rm LibYAML/$file sed -i -e "/^LibYAML\/$file/d" MANIFEST done +# 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 OPTIMIZE="%{optflags}" NO_PACKLIST=1 NO_PERLLOCAL=1 @@ -97,7 +114,32 @@ perl Makefile.PL INSTALLDIRS=vendor OPTIMIZE="%{optflags}" NO_PACKLIST=1 NO_PERL find %{buildroot} -type f -name '*.bs' -empty -delete %{_fixperms} -c %{buildroot} +# Install tests +mkdir -p %{buildroot}%{_libexecdir}/%{name} +cp -a t %{buildroot}%{_libexecdir}/%{name} +# It needs libraries in lib/ not in system directories +rm %{buildroot}%{_libexecdir}/%{name}/t/000-require-modules.t +# Remove author test +rm %{buildroot}%{_libexecdir}/%{name}/t/author-pod-syntax.t +# Don't use blib +perl -i -pe 's{^use blib;}{#use blib;}' %{buildroot}%{_libexecdir}/%{name}/t/TestYAML.pm +perl -i -pe 's{^use_blib: 1}{use_blib: 0}' %{buildroot}%{_libexecdir}/%{name}/t/yaml_tests.yaml +cat > %{buildroot}%{_libexecdir}/%{name}/test << 'EOF' +#!/bin/bash +set -e +# 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 +export HARNESS_OPTIONS=j$(perl -e 'if ($ARGV[0] =~ /.*-j([0-9][0-9]*).*/) {print $1} else {print 1}' -- '%{?_smp_mflags}') make test %files @@ -109,9 +151,13 @@ make test %{_mandir}/man3/YAML::XS.3* %{_mandir}/man3/YAML::XS::LibYAML.3* +%files tests +%{_libexecdir}/%{name} + %changelog * Thu Jan 26 2023 Jitka Plesnikova - 1:0.86-1 - 0.86 bump +- Package tests * Fri Jan 20 2023 Fedora Release Engineering - 1:0.85-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_38_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..4852801 --- /dev/null +++ b/tests/upstream-tests.fmf @@ -0,0 +1,4 @@ +summary: Upstream tests +component: perl-YAML-LibYAML +require: perl-YAML-LibYAML-tests +test: /usr/libexec/perl-YAML-LibYAML/test