diff options
| author | Tim Orling <ticotimo@gmail.com> | 2023-12-16 21:41:33 -0800 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-12-17 19:07:22 +0000 |
| commit | 7d881f0214f9761990e52595d33246700c4da15c (patch) | |
| tree | 8d95533ed07a819499a84f2bcce94d46a1cfd316 /meta/lib/oeqa/sdk | |
| parent | b2b2e0277509a07a37022caf51f7e536adad898f (diff) | |
| download | poky-7d881f0214f9761990e52595d33246700c4da15c.tar.gz | |
oeqa: add "maturin develop" SDK test case
'maturin develop' first checks that a virtual environment
has been created, which is a good test for our python3 SDK
environment ;)
Source for guessing-game lifted from https://www.maturin.rs/tutorial
The test case is expected to fetch any necessary crates, build a
development version of the crate and package it as a wheel
Needs at a minimum the following in e.g. local.conf:
TOOLCHAIN_HOST_TASK:append = " nativesdk-python3-maturin"
SDK_INCLUDE_TOOLCHAIN = '1'
SDK_TOOLCHAIN_LANGS += 'rust'
The output of 'maturin develop' should be something like:
...
🔗 Found pyo3 bindings with abi3 support for Python ≥ 3.8
🐍 Not using a specific python interpreter
📡 Using build options features from pyproject.toml
...
Compiling guessing-game v0.1.0 (/path/to/guessing-game)
Finished dev [unoptimized + debuginfo] target(s) in 7.14s
📦 Built wheel for abi3 Python ≥ 3.8 to /path/to/tmpdir/guessing_game-0.1.0-cp38-abi3-linux_x86_64.whl
🛠 Installed guessing-game-0.1.0
(From OE-Core rev: 5265dd0b102cd7f3c6bb2ae1b18e9f625b834b39)
Signed-off-by: Tim Orling <tim.orling@konsulko.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/sdk')
| -rw-r--r-- | meta/lib/oeqa/sdk/cases/maturin.py | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/meta/lib/oeqa/sdk/cases/maturin.py b/meta/lib/oeqa/sdk/cases/maturin.py index 14245bc36e..ea10f568b2 100644 --- a/meta/lib/oeqa/sdk/cases/maturin.py +++ b/meta/lib/oeqa/sdk/cases/maturin.py | |||
| @@ -4,9 +4,12 @@ | |||
| 4 | # SPDX-License-Identifier: MIT | 4 | # SPDX-License-Identifier: MIT |
| 5 | # | 5 | # |
| 6 | 6 | ||
| 7 | import os | ||
| 8 | import shutil | ||
| 7 | import unittest | 9 | import unittest |
| 8 | from oeqa.sdk.case import OESDKTestCase | ||
| 9 | 10 | ||
| 11 | from oeqa.core.utils.path import remove_safe | ||
| 12 | from oeqa.sdk.case import OESDKTestCase | ||
| 10 | from oeqa.utils.subprocesstweak import errors_have_output | 13 | from oeqa.utils.subprocesstweak import errors_have_output |
| 11 | 14 | ||
| 12 | errors_have_output() | 15 | errors_have_output() |
| @@ -31,3 +34,46 @@ class MaturinTest(OESDKTestCase): | |||
| 31 | output, | 34 | output, |
| 32 | r" - CPython %s (.+)/usr/bin/python%s$" % (python_version, python_version), | 35 | r" - CPython %s (.+)/usr/bin/python%s$" % (python_version, python_version), |
| 33 | ) | 36 | ) |
| 37 | |||
| 38 | |||
| 39 | class MaturinDevelopTest(OESDKTestCase): | ||
| 40 | @classmethod | ||
| 41 | def setUpClass(self): | ||
| 42 | targetdir = os.path.join(self.tc.sdk_dir, "guessing-game") | ||
| 43 | try: | ||
| 44 | shutil.rmtree(targetdir) | ||
| 45 | except FileNotFoundError: | ||
| 46 | pass | ||
| 47 | shutil.copytree( | ||
| 48 | os.path.join(self.tc.files_dir, "maturin/guessing-game"), targetdir | ||
| 49 | ) | ||
| 50 | |||
| 51 | def setUp(self): | ||
| 52 | machine = self.td.get("MACHINE") | ||
| 53 | if not ( | ||
| 54 | self.tc.hasHostPackage("nativesdk-python3-maturin") | ||
| 55 | or self.tc.hasHostPackage("python3-maturin-native") | ||
| 56 | ): | ||
| 57 | raise unittest.SkipTest("No python3-maturin package in the SDK") | ||
| 58 | if not ( | ||
| 59 | self.tc.hasHostPackage("packagegroup-rust-cross-canadian-%s" % machine) | ||
| 60 | ): | ||
| 61 | raise unittest.SkipTest( | ||
| 62 | "Testing 'maturin develop' requires Rust cross-canadian in the SDK" | ||
| 63 | ) | ||
| 64 | |||
| 65 | def test_maturin_develop(self): | ||
| 66 | """ | ||
| 67 | This test case requires: | ||
| 68 | (1) that a .venv can been created. | ||
| 69 | (2) a functional 'rustc' and 'cargo' | ||
| 70 | """ | ||
| 71 | self._run("cd %s/guessing-game; python3 -m venv .venv" % self.tc.sdk_dir) | ||
| 72 | cmd = "cd %s/guessing-game; maturin develop" % self.tc.sdk_dir | ||
| 73 | output = self._run(cmd) | ||
| 74 | self.assertRegex(output, r"🔗 Found pyo3 bindings with abi3 support for Python ≥ 3.8") | ||
| 75 | self.assertRegex(output, r"🐍 Not using a specific python interpreter") | ||
| 76 | self.assertRegex(output, r"📡 Using build options features from pyproject.toml") | ||
| 77 | self.assertRegex(output, r"Compiling guessing-game v0.1.0") | ||
| 78 | self.assertRegex(output, r"📦 Built wheel for abi3 Python ≥ 3.8") | ||
| 79 | self.assertRegex(output, r"🛠 Installed guessing-game-0.1.0") | ||
