On Fri, Mar 6, 2026 at 7:00 AM Stefano Tondo via
lists.openembedded.org <[email protected]>
wrote:
>
> Add test verifying that version extraction patterns work correctly for:
> - Rust crates (.crate files)
> - Go modules
> - Python packages (PyPI)
> - Generic tarball formats
> - Git revision hashes
>
> Test builds tar recipe and validates that all packages have proper
> version strings extracted from their filenames.
>
> Signed-off-by: Stefano Tondo <[email protected]>
> ---
> meta/lib/oeqa/selftest/cases/spdx.py | 53 ++++++++++++++++++++++++++++
> 1 file changed, 53 insertions(+)
>
> diff --git a/meta/lib/oeqa/selftest/cases/spdx.py
> b/meta/lib/oeqa/selftest/cases/spdx.py
> index 9b6fcd335c..14a50205d5 100644
> --- a/meta/lib/oeqa/selftest/cases/spdx.py
> +++ b/meta/lib/oeqa/selftest/cases/spdx.py
> @@ -448,3 +448,56 @@ class SPDX30Check(SPDX3CheckBase, OESelftestTestCase):
> f"External references {'found' if found_external_refs else 'not
> found'} "
> f"in SPDX output (defensive handling verified)"
> )
> +
> + def test_version_extraction_patterns(self):
> + """
> + Test that version extraction works for various package formats.
> +
> + This test verifies that version patterns correctly extract versions
> from:
> + 1. Rust crates (.crate files)
> + 2. Go modules
> + 3. Python packages (PyPI)
> + 4. Generic tarball formats
> + 5. Git revision hashes
> + """
> + # Build a package that has dependencies with various formats
> + objset = self.check_recipe_spdx(
> + "tar",
> +
> "{DEPLOY_DIR_SPDX}/{SSTATE_PKGARCH}/recipes/recipe-tar.spdx.json",
> + # Use a unique namespace prefix to ensure do_create_spdx runs
> + # fresh regardless of sstate from prior tests in the same
> + # oe-selftest worker (see test_extra_opts for rationale)
> + extraconf="""\
> + SPDX_NAMESPACE_PREFIX =
> "http://spdx.org/spdxdocs/test-version-extract"
> + """,
> + )
Again, you aren't changing anything so this should work just fine when
pulled from sstate.
> +
> + # Collect all packages with versions
> + packages_with_versions = []
> + for pkg in objset.foreach_type(oe.spdx30.software_Package):
> + if hasattr(pkg, 'software_packageVersion') and
> pkg.software_packageVersion:
hasattr is redundant.
> + packages_with_versions.append((pkg.name,
> pkg.software_packageVersion))
> +
> + self.assertGreater(
> + len(packages_with_versions), 0,
> + "Should find packages with extracted versions"
> + )
> +
> + self.logger.info(f"Found {len(packages_with_versions)} packages with
> versions")
> +
> + # Log some examples for debugging
> + for name, version in packages_with_versions[:5]:
> + self.logger.info(f" {name}: {version}")
> +
> + # Verify that versions follow expected patterns
> + for name, version in packages_with_versions:
> + # Version should not be empty
> + self.assertIsNotNone(version)
> + self.assertNotEqual(version, "")
> +
> + # Version should contain digits
> + self.assertRegex(
> + version,
> + r'\d',
> + f"Version '{version}' for package '{name}' should contain
> digits"
> + )
> --
> 2.53.0
>
>
>
>
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#232624):
https://lists.openembedded.org/g/openembedded-core/message/232624
Mute This Topic: https://lists.openembedded.org/mt/118170502/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-