CI: Test only python3 byte compilation and pytest

pythontest.spec changes are roughly a revert to a state from Fedora dist-git's
commit hash: 37bf640f37
This commit is contained in:
Karolina Surma 2024-08-19 14:55:49 +02:00
parent 556700bf19
commit ebd0fe6b2c
2 changed files with 5 additions and 25 deletions

View File

@ -1,18 +1,11 @@
%global basedir /opt/test/byte_compilation
# We have 3 different ways of bytecompiling: for 3.9+, 3.4-3.8, and 2.7
# Test with a representative of each.
%global python36_sitelib /usr/lib/python3.6/site-packages
%global python27_sitelib /usr/lib/python2.7/site-packages
Name: pythontest
Version: 0
Release: 0%{?dist}
Summary: ...
License: MIT
BuildRequires: python3-devel
BuildRequires: python3.6
BuildRequires: python2.7
%description
...
@ -30,26 +23,18 @@ echo "print()" > %{buildroot}%{basedir}/directory/to/test/recursion/file_in_dir.
mkdir -p %{buildroot}%{python3_sitelib}/directory/
echo "print()" > %{buildroot}%{python3_sitelib}/directory/file.py
mkdir -p %{buildroot}%{python36_sitelib}/directory/
echo "print()" > %{buildroot}%{python36_sitelib}/directory/file.py
mkdir -p %{buildroot}%{python27_sitelib}/directory/
echo "print()" > %{buildroot}%{python27_sitelib}/directory/file.py
%check
LOCATIONS="
%{buildroot}%{basedir}
%{buildroot}%{python3_sitelib}/directory/
%{buildroot}%{python36_sitelib}/directory/
%{buildroot}%{python27_sitelib}/directory/
"
# Count .py and .pyc files
PY=$(find $LOCATIONS -name "*.py" | wc -l)
PYC=$(find $LOCATIONS -name "*.py[co]" | wc -l)
PYC=$(find $LOCATIONS -name "*.pyc" | wc -l)
# We should have 5 .py files (3 for python3, one each for 3.6 & 2.7)
test $PY -eq 5
# We should have 3 .py files
test $PY -eq 3
# Every .py file should be byte-compiled to two .pyc files (optimization level 0 and 1)
# so we should have two times more .pyc files than .py files
@ -61,7 +46,7 @@ test $(expr $PY \* 2) -eq $PYC
# number of source files. (Or be smaller, if the dupe detection is done
# across all files.)
INODES=$(stat --format %i $(find $LOCATIONS -name "*.py[co]") | sort -u | wc -l)
INODES=$(stat --format %i $(find $LOCATIONS -name "*.pyc") | sort -u | wc -l)
test $PY -ge $INODES
@ -69,8 +54,6 @@ test $PY -ge $INODES
%pycached %{basedir}/file.py
%pycached %{basedir}/directory/to/test/recursion/file_in_dir.py
%pycached %{python3_sitelib}/directory/file.py
%pycached %{python36_sitelib}/directory/file.py
%{python27_sitelib}/directory/file.py*
%changelog

View File

@ -15,7 +15,7 @@
tests:
- pytest:
dir: .
run: PYTHONPATH=/usr/lib/rpm/redhat ALTERNATE_PYTHON_VERSION=3.6 pytest -v
run: PYTHONPATH=/usr/lib/rpm/redhat ALTERNATE_PYTHON_VERSION=SKIP pytest -v
- manual_byte_compilation_clamp_mtime_off:
dir: .
run: rpmbuild --define 'dist .clamp0' --define 'clamp_mtime_to_source_date_epoch 0' -ba pythontest.spec
@ -35,6 +35,3 @@
- python3-rpm-macros
- python3-devel
- python3-pytest
- python3.6
- python2.7