From b0cb698c46f2d9fad264c68dc3c8ebfca791581f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Thu, 9 Jul 2020 12:05:00 +0200 Subject: [PATCH] Simplify the %check section, we cannot reasonably test without tox installed --- python-tox.spec | 51 ++++++++++++++++++++----------------------------- tests/tests.yml | 2 +- 2 files changed, 22 insertions(+), 31 deletions(-) diff --git a/python-tox.spec b/python-tox.spec index 82847b1..c238631 100644 --- a/python-tox.spec +++ b/python-tox.spec @@ -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 -%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} diff --git a/tests/tests.yml b/tests/tests.yml index aab2c27..0c6c663 100644 --- a/tests/tests.yml +++ b/tests/tests.yml @@ -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