Simplify the %check section, we cannot reasonably test without tox installed
This commit is contained in:
parent
d154cf5aab
commit
b0cb698c46
2 changed files with 22 additions and 31 deletions
|
|
@ -1,8 +1,15 @@
|
|||
# Tests requiring Internet connections are disabled by default
|
||||
# pass --with internet to run them (e.g. when doing a local rebuild
|
||||
# for sanity checks before committing). Example:
|
||||
# $ mock --enable-network --with internet <SRPM>
|
||||
%bcond_with internet
|
||||
# Tests are disbaled by default, they require:
|
||||
# a) tested tox to be installed
|
||||
# b) internet connection
|
||||
# To test, do the following:
|
||||
# 1) Build --without tests (the default)
|
||||
# (e.g. fedpkg mockbuild)
|
||||
# 2) Install the built package
|
||||
# (e.g. mock install ./results_python-tox/.../python3-tox-...rpm)
|
||||
# 3) Build again --with tests (and internet connection)
|
||||
# (e.g. fedpkg mockbuild --enable-network --no-clean-all)
|
||||
# The Fedora CI tests do this.
|
||||
%bcond_with tests
|
||||
|
||||
|
||||
%global pypi_name tox
|
||||
|
|
@ -62,8 +69,7 @@ Obsoletes: python2-tox < 2.9.1-4
|
|||
# Replace detox (no longer supported, functionality is now in tox)
|
||||
Obsoletes: python3-detox < 0.19-5
|
||||
|
||||
%if %{with internet}
|
||||
# for tests
|
||||
%if %{with tests}
|
||||
BuildRequires: python3-filelock
|
||||
BuildRequires: python3-flaky
|
||||
BuildRequires: python3-freezegun
|
||||
|
|
@ -76,7 +82,7 @@ BuildRequires: python3-psutil
|
|||
BuildRequires: python3-py
|
||||
BuildRequires: python3-pytest
|
||||
BuildRequires: python3-pytest-mock
|
||||
#BuildRequires: python3-pytest-randomly -- not packaged
|
||||
BuildRequires: python3-pytest-randomly
|
||||
BuildRequires: python3-pytest-xdist
|
||||
BuildRequires: python3-toml
|
||||
BuildRequires: python3-virtualenv
|
||||
|
|
@ -84,8 +90,13 @@ BuildRequires: python3-wheel
|
|||
BuildRequires: (python3-importlib-metadata if python3 < 3.8)
|
||||
BuildRequires: /usr/bin/gcc
|
||||
BuildRequires: /usr/bin/git
|
||||
BuildRequires: /usr/bin/pip
|
||||
BuildRequires: /usr/bin/poetry
|
||||
BuildRequires: /usr/bin/pytest
|
||||
BuildRequires: /usr/bin/python
|
||||
BuildRequires: libffi-devel
|
||||
# The tests only work if the tested tox is installed :(
|
||||
BuildRequires: %{pypi_name} = %{version}-%{release}
|
||||
%endif
|
||||
|
||||
%?python_enable_dependency_generator
|
||||
|
|
@ -114,29 +125,9 @@ rm -rf %{pypi_name}.egg-info
|
|||
%install
|
||||
%py3_install
|
||||
|
||||
# if internet connection available, run tests
|
||||
%if %{with internet}
|
||||
%if %{with tests}
|
||||
%check
|
||||
# there will be failures like
|
||||
# ModuleNotFoundError: tox
|
||||
# or InterpreterNotFound: python
|
||||
# We juggle the environment variables as much as we can, but it's not perfect.
|
||||
# To workaround this:
|
||||
# 1. build --without internet
|
||||
# 2. install the new python3-tox
|
||||
# 3. build --with internet
|
||||
mkdir .path
|
||||
ln -s %{__python3} .path/python
|
||||
ln -s /usr/bin/easy_install-%{python3_version} .path/easy_install
|
||||
ln -s /usr/bin/pytest-%{python3_version} .path/pytest
|
||||
ln -s /usr/bin/pip3 .path/pip
|
||||
export PATH=$(pwd)/.path:%{buildroot}%{_bindir}:$PATH
|
||||
export PYTHONPATH=%{buildroot}%{python3_sitelib}
|
||||
export TOXENV=py%{python3_version_nodots}
|
||||
export TOX_TESTENV_PASSENV="PATH TOX_TESTENV_PASSENV"
|
||||
# TODO figure out why PEP517/518 tests and test_provision_cli_args_ignore won't pass
|
||||
pytest-3 -n auto -k "not test_verbose_isolated_build and not test_dist_exists_version_change and not test_provision_cli_args_ignore"
|
||||
rm -rf .path
|
||||
%pytest -n auto
|
||||
%endif
|
||||
|
||||
%files -n python3-%{pypi_name}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
tests:
|
||||
- rpmbuild:
|
||||
dir: .
|
||||
run: "dnf -y build-dep --define '_with_internet 1' {{ tenv_workdir }}/python-tox.spec && rpmbuild --define '_sourcedir {{ tenv_workdir }}' --with internet -ba {{ tenv_workdir }}/python-tox.spec"
|
||||
run: "dnf -y build-dep --define '_with_tests 1' {{ tenv_workdir }}/python-tox.spec && rpmbuild --define '_sourcedir {{ tenv_workdir }}' --with tests -ba {{ tenv_workdir }}/python-tox.spec"
|
||||
- smoke27:
|
||||
dir: python/smoke
|
||||
run: VERSION=2.7 METHOD=virtualenv ./venv.sh
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue