diff options
author | Ross Burton <ross.burton@arm.com> | 2025-05-10 09:43:48 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-05-12 22:01:55 +0100 |
commit | 04e4586c66b61891f45438a6ff19d26cfe30d480 (patch) | |
tree | f49c26490fd7b82f10a02c609cc18ccd4b046526 | |
parent | b8009efc1976faa906a5fcaef1ef0ea30c6441d5 (diff) | |
download | poky-04e4586c66b61891f45438a6ff19d26cfe30d480.tar.gz |
oeqa/sdk/maturin: be less picky in the list_python test
The test assumed that maturin would only find a single Python binary, in
/usr/bin/python3*.
However in eSDKs with buildtools a Python is shipped with the SDK, so
the test failed.
Generalise the test so that it runs python3 and obtains its path and
version, and then verifies that path and and version are found by
Maturin. This means we're not assuming a single Python, or the paths, or
that the Python is CPython.
(From OE-Core rev: ae9b5dae77ef140422fcf71d239ca028c9208447)
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/lib/oeqa/sdk/cases/maturin.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/meta/lib/oeqa/sdk/cases/maturin.py b/meta/lib/oeqa/sdk/cases/maturin.py index 42394c7a97..83d13c4ec5 100644 --- a/meta/lib/oeqa/sdk/cases/maturin.py +++ b/meta/lib/oeqa/sdk/cases/maturin.py | |||
@@ -19,17 +19,15 @@ class MaturinTest(OESDKTestCase): | |||
19 | self.ensure_host_package("python3-maturin") | 19 | self.ensure_host_package("python3-maturin") |
20 | 20 | ||
21 | def test_maturin_list_python(self): | 21 | def test_maturin_list_python(self): |
22 | py_major = self._run("python3 -c 'import sys; print(sys.version_info.major)'") | 22 | out = self._run(r"""python3 -c 'import sys; print(f"{sys.executable}\n{sys.version_info.major}.{sys.version_info.minor}")'""") |
23 | py_minor = self._run("python3 -c 'import sys; print(sys.version_info.minor)'") | 23 | executable, version = out.splitlines() |
24 | python_version = "%s.%s" % (py_major.strip(), py_minor.strip()) | ||
25 | cmd = "maturin list-python" | ||
26 | output = self._run(cmd) | ||
27 | self.assertRegex(output, r"^🐍 1 python interpreter found:\n") | ||
28 | self.assertRegex( | ||
29 | output, | ||
30 | r" - CPython %s (.+)/usr/bin/python%s$" % (python_version, python_version), | ||
31 | ) | ||
32 | 24 | ||
25 | output = self._run("maturin list-python") | ||
26 | # The output looks like this: | ||
27 | # - CPython 3.13 at /usr/bin/python3 | ||
28 | # We don't want to assume CPython so just check for the version and path. | ||
29 | expected = f"{version} at {executable}" | ||
30 | self.assertIn(expected, output) | ||
33 | 31 | ||
34 | class MaturinDevelopTest(OESDKTestCase): | 32 | class MaturinDevelopTest(OESDKTestCase): |
35 | @classmethod | 33 | @classmethod |