diff --git a/tests/pythontest.spec b/tests/pythontest.spec new file mode 100644 index 0000000..a0f052c --- /dev/null +++ b/tests/pythontest.spec @@ -0,0 +1,33 @@ +%global basedir /opt/test/byte_compilation + +Name: pythontest +Version: 0 +Release: 0 +Summary: ... +License: MIT +BuildRequires: python3-devel + +%description +... + +%install +mkdir -p %{buildroot}%{basedir}/directory/to/test/recursion + +echo "print()" > %{buildroot}%{basedir}/file.py +echo "print()" > %{buildroot}%{basedir}/directory/to/test/recursion/file_in_dir.py + +%py_byte_compile %{python3} %{buildroot}%{basedir}/file.py +%py_byte_compile %{python3} %{buildroot}%{basedir}/directory + +%check +# Count .py and .pyc files +PY=$(find %{buildroot}%{basedir} -name "*.py" | wc -l) +PYC=$(find %{buildroot}%{basedir} -name "*.pyc" | wc -l) + +# 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 +test $(expr $PY \* 2) -eq $PYC + +%files +%pycached %{basedir}/file.py +%pycached %{basedir}/directory/to/test/recursion/file_in_dir.py diff --git a/tests/tests.yml b/tests/tests.yml index 9fb4da3..7098b4b 100644 --- a/tests/tests.yml +++ b/tests/tests.yml @@ -16,6 +16,9 @@ - pytest: dir: . run: pytest -v + - manual_byte_compilation: + dir: . + run: rpmbuild -ba pythontest.spec required_packages: - rpm-build - python-rpm-macros