public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
To: git-commits@fedoraproject.org
Subject: [rpms/pyproject-rpm-macros] rawhide: Add basic eval tests
Date: Tue, 13 Oct 2026 12:14:46 GMT [thread overview]
Message-ID: <179189368615.1.11310503337315200098.rpms-pyproject-rpm-macros-56853f4750e4@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : rpms/pyproject-rpm-macros
Branch : rawhide
Commit : 56853f4750e4332010032c52598e72449d296d98
Author : Miro Hrončok <miro@hroncok.cz>
Date : 2026-10-13T09:30:01+00:00
Stats : +87/-0 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/pyproject-rpm-macros/c/56853f4750e4332010032c52598e72449d296d98?branch=rawhide
Log:
Add basic eval tests
Assisted-By: Claude Opus 4.6
---
diff --git a/pyproject-rpm-macros.spec b/pyproject-rpm-macros.spec
index 12f675f..2a92829 100644
--- a/pyproject-rpm-macros.spec
+++ b/pyproject-rpm-macros.spec
@@ -39,6 +39,7 @@ Source: pyproject_getopt.lua
Source: compare_mandata.py
Source: test_dependency_overrides.py
Source: test_pyproject_buildrequires.py
+Source: test_pyproject_evals.py
Source: test_pyproject_getopt.lua
Source: test_pyproject_getopt_consistency.py
Source: test_pyproject_getopt_parser.py
diff --git a/test_pyproject_evals.py b/test_pyproject_evals.py
new file mode 100644
index 0000000..78ffdc1
--- /dev/null
+++ b/test_pyproject_evals.py
@@ -0,0 +1,86 @@
+"""Test RPM macro expansion from macros.pyproject.
+
+This test was added late in the pyproject-rpm-macros life cycle and does
+not include all macros.
+
+When there is a regression that can be easily tested here, we'll add it.
+"""
+
+import os
+import subprocess
+from pathlib import Path
+
+import pytest
+
+BASEDIR = Path(__file__).parent
+
+PRELOAD_LUA = (
+ 'package.preload["fedora.rpm.pyproject_getopt"]'
+ f' = loadfile("{BASEDIR}/pyproject_getopt.lua")'
+)
+
+
+def rpm_eval(macro_call):
+ """Expand an RPM macro using the local macros.pyproject and Lua files."""
+ r = subprocess.run(
+ [
+ "rpm",
+ f"--macros=/usr/lib/rpm/macros:/usr/lib/rpm/macros.d/macros.*:{BASEDIR}/macros.aaa-pyproject-srpm:{BASEDIR}/macros.pyproject",
+ "--eval",
+ f"%{{lua:{PRELOAD_LUA}}}{macro_call}",
+ ],
+ capture_output=True,
+ text=True,
+ env={**os.environ, "LANG": "C.UTF-8"},
+ )
+ assert r.returncode == 0, f"rpm --eval failed:\n{r.stderr}"
+ return r.stdout.strip()
+
+
+class TestPyprojectExtrasSubpkg:
+ def test_short_options(self):
+ r = rpm_eval("%pyproject_extras_subpkg -n test-pkg -f /dev/null myextra")
+ assert "%package -n test-pkg+myextra" in r
+
+ def test_long_name(self):
+ r = rpm_eval("%pyproject_extras_subpkg --name test-pkg -f /dev/null myextra")
+ assert "%package -n test-pkg+myextra" in r
+
+ def test_multiple_extras(self):
+ r = rpm_eval("%pyproject_extras_subpkg -n test-pkg -f /dev/null extra1 extra2")
+ assert "%package -n test-pkg+extra1" in r
+ assert "%package -n test-pkg+extra2" in r
+
+
+class TestNormalizeName:
+ @pytest.mark.parametrize(
+ "input, expected",
+ [
+ ("Foo_Bar.baz", "foo-bar-baz"),
+ ("UPPER", "upper"),
+ ("already-normalized", "already-normalized"),
+ ("dots...dashes---underscores___mixed", "dots-dashes-underscores-mixed"),
+ ("simple", "simple"),
+ ],
+ )
+ def test_normalize(self, input, expected):
+ assert rpm_eval(f"%__pyproject_normalize_name {input}") == expected
+
+
+@pytest.mark.parametrize(
+ "macro",
+ [
+ "pyproject_files",
+ "_pyproject_modules",
+ "_pyproject_ghost_distinfo",
+ ],
+)
+class TestPathMacros:
+ def test_without_dist_name(self, macro):
+ assert "pyproject-" in rpm_eval(f"%{macro}")
+
+ def test_with_short_dist_name(self, macro):
+ assert rpm_eval(f"%{macro} -D My_Package").endswith("-my-package")
+
+ def test_with_long_dist_name(self, macro):
+ assert rpm_eval(f"%{macro} --dist-name My_Package").endswith("-my-package")
reply other threads:[~2026-10-13 12:14 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179189368615.1.11310503337315200098.rpms-pyproject-rpm-macros-56853f4750e4@fedoraproject.org \
--to=git-commits@fedoraproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox