summaryrefslogtreecommitdiffstats
path: root/meta/classes-recipe
diff options
context:
space:
mode:
authorDerek Straka <derek@asterius.io>2024-12-18 18:05:47 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-01-08 12:37:20 +0000
commit095beae0085c94a105256b6df4bd71bd4a506104 (patch)
tree138d6b7f93f682cc8ac468a28c6f2ce86a6d165f /meta/classes-recipe
parent5375cd0318124a1d14f09d075cc23c31216953e0 (diff)
downloadpoky-095beae0085c94a105256b6df4bd71bd4a506104.tar.gz
classes/ptest-python-pytest: add a new class to consolidate pytest ptest functionality
A large number of python packages leverage the pytest unit test framework for their ptest functionality. Currently, many of the tests have duplicate code for: 1. Installing pytest files 2. Declaring ptest dependencies 3. Script for executing tests (run-ptes) To simplify adding common pytest based ptests, added a new class enabling base functionality. Users can also override the location of the pytest files in addition to using their own version of run-ptest [RP: Minor whitespace tweaks to shell function and missing prepend space] (From OE-Core rev: d66009e608256d42b2d6573d4614a99eb13fd3f1) Signed-off-by: Derek Straka <derek@asterius.io> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-recipe')
-rw-r--r--meta/classes-recipe/ptest-python-pytest.bbclass31
1 files changed, 31 insertions, 0 deletions
diff --git a/meta/classes-recipe/ptest-python-pytest.bbclass b/meta/classes-recipe/ptest-python-pytest.bbclass
new file mode 100644
index 0000000000..6d4f16a96e
--- /dev/null
+++ b/meta/classes-recipe/ptest-python-pytest.bbclass
@@ -0,0 +1,31 @@
1#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
7inherit ptest
8
9FILESEXTRAPATHS:prepend := "${COREBASE}/meta/files:"
10
11SRC_URI:append = "\
12 file://ptest-python-pytest/run-ptest \
13"
14
15# Overridable configuration for the directory within the source tree
16# containing the pytest files
17PTEST_PYTEST_DIR ?= "tests"
18
19do_install_ptest() {
20 if [ ! -f ${D}${PTEST_PATH}/run-ptest ]; then
21 install -m 0755 ${UNPACKDIR}/ptest-python-pytest/run-ptest ${D}${PTEST_PATH}
22 fi
23 if [ -d "${S}/${PTEST_PYTEST_DIR}" ]; then
24 install -d ${D}${PTEST_PATH}/${PTEST_PYTEST_DIR}
25 cp -rf ${S}/${PTEST_PYTEST_DIR}/* ${D}${PTEST_PATH}/${PTEST_PYTEST_DIR}/
26 fi
27}
28
29FILES:${PN}-ptest:prepend = "${PTEST_PATH}/*"
30
31RDEPENDS:${PN}-ptest:prepend = "python3-pytest python3-unittest-automake-output "