diff --git a/tests/pythontest.spec b/tests/pythontest.spec index 182ba59..3b707c5 100644 --- a/tests/pythontest.spec +++ b/tests/pythontest.spec @@ -1,11 +1,18 @@ %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 Summary: ... License: MIT BuildRequires: python3-devel +BuildRequires: python3.6 +BuildRequires: python2.7 %description ... @@ -23,15 +30,26 @@ 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/" +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 "*.pyc" | wc -l) +PYC=$(find $LOCATIONS -name "*.py[co]" | wc -l) -# We should have 3 .py files -test $PY -eq 3 +# We should have 5 .py files (3 for python3, one each for 3.6 & 2.7) +test $PY -eq 5 # 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 @@ -43,7 +61,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 "*.pyc") | sort -u | wc -l) +INODES=$(stat --format %i $(find $LOCATIONS -name "*.py[co]") | sort -u | wc -l) test $PY -ge $INODES @@ -51,3 +69,5 @@ 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* diff --git a/tests/tests.yml b/tests/tests.yml index 117b999..1c0478a 100644 --- a/tests/tests.yml +++ b/tests/tests.yml @@ -26,4 +26,5 @@ - python3-devel - python3-pytest - python3.6 + - python2.7