Package tests

This commit is contained in:
Jitka Plesnikova 2023-01-26 10:19:25 +01:00
parent 614fd288a1
commit de8951c853
5 changed files with 63 additions and 0 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

@ -70,12 +70,24 @@ Requires: libyaml >= 0.2.4
# Avoid provides for perl shared objects # Avoid provides for perl shared objects
%{?perl_default_filter} %{?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 %description
Kirill Siminov's "libyaml" is arguably the best YAML implementation. The C 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 library is written precisely to the YAML 1.1 specification. It was originally
bound to Python and was later bound to Ruby. 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 %prep
%setup -q -n YAML-LibYAML-%{version} %setup -q -n YAML-LibYAML-%{version}
# Unbundled libyaml, the source files are the same as in libyaml-0.2.4 # 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 rm LibYAML/$file
sed -i -e "/^LibYAML\/$file/d" MANIFEST sed -i -e "/^LibYAML\/$file/d" MANIFEST
done 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 %build
perl Makefile.PL INSTALLDIRS=vendor OPTIMIZE="%{optflags}" NO_PACKLIST=1 NO_PERLLOCAL=1 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 find %{buildroot} -type f -name '*.bs' -empty -delete
%{_fixperms} -c %{buildroot} %{_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 %check
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
@ -109,9 +151,13 @@ make test
%{_mandir}/man3/YAML::XS.3* %{_mandir}/man3/YAML::XS.3*
%{_mandir}/man3/YAML::XS::LibYAML.3* %{_mandir}/man3/YAML::XS::LibYAML.3*
%files tests
%{_libexecdir}/%{name}
%changelog %changelog
* Thu Jan 26 2023 Jitka Plesnikova <jplesnik@redhat.com> - 1:0.86-1 * Thu Jan 26 2023 Jitka Plesnikova <jplesnik@redhat.com> - 1:0.86-1
- 0.86 bump - 0.86 bump
- Package tests
* Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1:0.85-2 * Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1:0.85-2
- 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-YAML-LibYAML
require: perl-YAML-LibYAML-tests
test: /usr/libexec/perl-YAML-LibYAML/test