Make tests working on systems without non-versioned python macros

See RHBZ 1784688

We are using unversioned python macros, such as `%__python` and
`%python_sitelib` which are not supported in Fedora rawhide
anymore. Instead, we should use `%__python3` and `%python3_sitelib`.
This commit is contained in:
Jakub Kadlcik 2020-10-06 21:46:42 +02:00 committed by Jakub Kadlčík
parent 861d15518e
commit 998f7fb067
5 changed files with 83 additions and 7 deletions

View file

@ -18,6 +18,7 @@ Functional Tests for the GitAnnexBuilder.
import os import os
import glob import glob
import tempfile import tempfile
import sys
import shutil import shutil
from nose.plugins.skip import SkipTest from nose.plugins.skip import SkipTest
from os.path import join from os.path import join
@ -56,7 +57,8 @@ class GitAnnexBuilderTests(TitoGitTestFixture):
"true") "true")
os.chdir(self.repo_dir) os.chdir(self.repo_dir)
spec = join(os.path.dirname(__file__), "specs/extsrc.spec") specname = "extsrc-3.spec" if sys.version_info[0] == 3 else "extsrc-2.spec"
spec = join(os.path.dirname(__file__), "specs", specname)
self.create_project_from_spec(PKG_NAME, self.config, self.create_project_from_spec(PKG_NAME, self.config,
spec=spec) spec=spec)
self.source_filename = 'extsrc-0.0.2.tar.gz' self.source_filename = 'extsrc-0.0.2.tar.gz'

View file

@ -17,6 +17,7 @@ Functional Tests for the FetchBuilder.
import glob import glob
import os import os
import sys
import shutil import shutil
import tempfile import tempfile
@ -49,7 +50,11 @@ class FetchBuilderTests(TitoGitTestFixture):
def setUp(self): def setUp(self):
TitoGitTestFixture.setUp(self) TitoGitTestFixture.setUp(self)
self.pkg_dir = join(self.repo_dir, EXT_SRC_PKG) self.pkg_dir = join(self.repo_dir, EXT_SRC_PKG)
spec = join(os.path.dirname(__file__), "specs/extsrc.spec")
specname = "extsrc-3.spec" if sys.version_info[0] == 3 else "extsrc-2.spec"
spec = join(os.path.dirname(__file__), "specs", specname)
shutil.copyfile(spec, os.path.join(self.repo_dir, "extsrc.spec"))
spec = join(self.repo_dir, "extsrc.spec")
# Setup test config: # Setup test config:
self.config = RawConfigParser() self.config = RawConfigParser()

View file

@ -13,6 +13,7 @@
# in this software or its documentation. # in this software or its documentation.
import os import os
import sys
import shutil import shutil
import tempfile import tempfile
import unittest import unittest
@ -22,7 +23,50 @@ from tito.common import run_command
# NOTE: No Name in test spec file as we re-use it for several packages. # NOTE: No Name in test spec file as we re-use it for several packages.
# Name must be written first. # Name must be written first.
TEST_SPEC = """ TEST_SPEC_3 = """
%{!?python3_sitelib: %define python3_sitelib %(%{__python3} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
Version: 0.0.1
Release: 1%{?dist}
Summary: Tito test package.
URL: https://example.com
Group: Applications/Internet
License: GPLv2
BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n)
BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: python3-setuptools
Source0: %{name}-%{version}.tar.gz
%description
Nobody cares.
%prep
#nothing to do here
%setup -q -n %{name}-%{version}
%build
%{__python3} setup.py build
%install
rm -rf $RPM_BUILD_ROOT
%{__python3} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT
rm -f $RPM_BUILD_ROOT%{python3_sitelib}/*egg-info/requires.txt
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root)
#%dir %{python3_sitelib}/%{name}
%{python3_sitelib}/%{name}-*.egg-info
%changelog
"""
# NOTE: No Name in test spec file as we re-use it for several packages.
# Name must be written first.
TEST_SPEC_2 = """
%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")} %{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
Version: 0.0.1 Version: 0.0.1
@ -165,8 +209,9 @@ class TitoGitTestFixture(unittest.TestCase):
self.write_file(os.path.join(full_pkg_dir, 'a.txt'), "BLERG\n") self.write_file(os.path.join(full_pkg_dir, 'a.txt'), "BLERG\n")
# Write the test spec file: # Write the test spec file:
spec = TEST_SPEC_3 if sys.version_info[0] == 3 else TEST_SPEC_2
self.write_file(os.path.join(full_pkg_dir, "%s.spec" % pkg_name), self.write_file(os.path.join(full_pkg_dir, "%s.spec" % pkg_name),
"Name: %s\n%s" % (pkg_name, TEST_SPEC)) "Name: %s\n%s" % (pkg_name, spec))
# Write test setup.py: # Write test setup.py:
self.write_file(os.path.join(full_pkg_dir, "setup.py"), self.write_file(os.path.join(full_pkg_dir, "setup.py"),

View file

@ -1,4 +1,4 @@
%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")} %{!?python2_sitelib: %define python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
Name: extsrc Name: extsrc
Version: 0.0.1 Version: 0.0.1
@ -22,7 +22,5 @@ Nobody cares.
%files %files
%defattr(-,root,root) %defattr(-,root,root)
#%dir %{python_sitelib}/%{name}
#%{python_sitelib}/%{name}-*.egg-info
%changelog %changelog

View file

@ -0,0 +1,26 @@
%{!?python3_sitelib: %define python3_sitelib %(%{__python3} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
Name: extsrc
Version: 0.0.1
Release: 1%{?dist}
Summary: tito test package for the external source builder
URL: https://example.com
License: GPLv2
Source0: %{name}-%{version}.tar.gz
BuildArch: noarch
%description
Nobody cares.
%prep
%build
%install
%clean
%files
%defattr(-,root,root)
%changelog