diff options
Diffstat (limited to 'meta/classes-recipe/ptest-python-pytest.bbclass')
-rw-r--r-- | meta/classes-recipe/ptest-python-pytest.bbclass | 37 |
1 files changed, 37 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..a4615e12bf --- /dev/null +++ b/meta/classes-recipe/ptest-python-pytest.bbclass | |||
@@ -0,0 +1,37 @@ | |||
1 | # | ||
2 | # Copyright OpenEmbedded Contributors | ||
3 | # | ||
4 | # SPDX-License-Identifier: MIT | ||
5 | # | ||
6 | |||
7 | inherit ptest | ||
8 | |||
9 | # Overridable configuration for the directory within the source tree | ||
10 | # containing the pytest files | ||
11 | PTEST_PYTEST_DIR ?= "tests" | ||
12 | |||
13 | do_install_ptest() { | ||
14 | # Check if the recipe provides its own version of run-ptest | ||
15 | # If nothing exists in the SRC_URI, dynamically create a | ||
16 | # run-test script of "last resort" that has the default | ||
17 | # pytest behavior. | ||
18 | # | ||
19 | # Users can override this behavior by simply including a | ||
20 | # custom script (run-ptest) in the source file list | ||
21 | if [ ! -f "${UNPACKDIR}/run-ptest" ]; then | ||
22 | cat > ${D}${PTEST_PATH}/run-ptest << EOF | ||
23 | #!/bin/sh | ||
24 | pytest --automake | ||
25 | EOF | ||
26 | # Ensure the newly created script has the execute bit set | ||
27 | chmod 755 ${D}${PTEST_PATH}/run-ptest | ||
28 | fi | ||
29 | if [ -d "${S}/${PTEST_PYTEST_DIR}" ]; then | ||
30 | install -d ${D}${PTEST_PATH}/${PTEST_PYTEST_DIR} | ||
31 | cp -rf ${S}/${PTEST_PYTEST_DIR}/* ${D}${PTEST_PATH}/${PTEST_PYTEST_DIR}/ | ||
32 | fi | ||
33 | } | ||
34 | |||
35 | FILES:${PN}-ptest:prepend = "${PTEST_PATH}/*" | ||
36 | |||
37 | RDEPENDS:${PN}-ptest:prepend = "python3-pytest python3-unittest-automake-output " | ||