@@ -59,7 +59,7 @@ def search_package_in_distros(pkglst_dir, recipe, data):
removes = ['nativesdk-', '-native', '-cross', '-initial']
for r in removes:
- recipe_name.replace(r, '')
+ recipe_name = recipe_name.replace(r, '')
distro_alias = data.getVar('DISTRO_PN_ALIAS', True)
if distro_alias:
new file mode 100644
@@ -0,0 +1,45 @@
+# layerindex-web - tests for matching recipes to distro packages in rrs/tools/rrs_distros.py
+#
+# Licensed under the MIT license, see COPYING.MIT for details
+#
+# SPDX-License-Identifier: MIT
+
+import os
+import sys
+import types
+
+import pytest
+
+sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'rrs', 'tools'))
+
+
+@pytest.fixture
+def rrs_distros(monkeypatch):
+ # The test settings don't install the rrs app, which the script imports
+ monkeypatch.setitem(sys.modules, 'rrs.models', types.SimpleNamespace(RecipeDistro=None, MaintenancePlan=None))
+ monkeypatch.delitem(sys.modules, 'rrs_distros', raising=False)
+ import rrs_distros
+ return rrs_distros
+
+
+@pytest.fixture
+def pkglst_dir(tmp_path):
+ # Package lists as OE-Core's distro_check writes them: <distro>-<release>, "<name>:<section>" lines
+ (tmp_path / 'Debian-13.7').write_text('brotli:main\npython3-brotli:main\nlz4:main\nfoo:main\n')
+ (tmp_path / 'Fedora-45').write_text('python-brotli:main\nlz4:main\n')
+ return tmp_path
+
+
+def search(rrs_distros, pkglst_dir, pn, alias=None):
+ recipe = types.SimpleNamespace(pn=pn)
+ data = types.SimpleNamespace(getVar=lambda name, expand=True: alias if name == 'DISTRO_PN_ALIAS' else None)
+ return rrs_distros.search_package_in_distros(str(pkglst_dir), recipe, data)
+
+
+def test_native_suffix_is_ignored(rrs_distros, pkglst_dir):
+ assert search(rrs_distros, pkglst_dir, 'foo-native') == {'Debian-main': 'foo'}
+
+
+def test_distro_pn_alias(rrs_distros, pkglst_dir):
+ assert search(rrs_distros, pkglst_dir, 'liblz4', alias='Debian=lz4 Fedora=lz4') == {'Debian-main': 'lz4', 'Fedora-main': 'lz4'}
+
search_package_in_distros() meant to strip nativesdk-, -native, -cross and -initial from the recipe name, but discarded the result of str.replace(). Keep it. [YOCTO #16513] AI-Generated: Claude Opus 5.5 Signed-off-by: Tim Orling <tim.orling@konsulko.com> --- rrs/tools/rrs_distros.py | 2 +- tests/test_rrs_distros.py | 45 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 tests/test_rrs_distros.py