]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
classes/ptest-python-pytest: simplify python ptest file overriding
authorDerek Straka <derek@asterius.io>
Fri, 10 Jan 2025 15:59:29 +0000 (15:59 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 14 Jan 2025 11:57:45 +0000 (11:57 +0000)
The complexity of overriding files from the bbclass made the behavior at
times hard to follow and predict. This change replaces the default file with a
heredoc equivalent that creates a default file if the user does not provide their
own version of run-ptest in the SRC_URI.

Signed-off-by: Derek Straka <derek@asterius.io>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes-recipe/ptest-python-pytest.bbclass
meta/files/ptest-python-pytest/run-ptest [deleted file]

index 6d4f16a96eafba6aae55ff811663401d153ea092..a4615e12bf953c4d2a46161e15ef2d5a4b4ac783 100644 (file)
@@ -6,19 +6,25 @@
 
 inherit ptest
 
-FILESEXTRAPATHS:prepend := "${COREBASE}/meta/files:"
-
-SRC_URI:append = "\
-    file://ptest-python-pytest/run-ptest \
-"
-
 # Overridable configuration for the directory within the source tree
 # containing the pytest files
 PTEST_PYTEST_DIR ?= "tests"
 
 do_install_ptest() {
-       if [ ! -f ${D}${PTEST_PATH}/run-ptest ]; then
-               install -m 0755 ${UNPACKDIR}/ptest-python-pytest/run-ptest ${D}${PTEST_PATH}
+       # Check if the recipe provides its own version of run-ptest
+       # If nothing exists in the SRC_URI, dynamically create a 
+       # run-test script of "last resort" that has the default
+       # pytest behavior.
+       # 
+       # Users can override this behavior by simply including a
+       # custom script (run-ptest) in the source file list
+       if [ ! -f "${UNPACKDIR}/run-ptest" ]; then
+               cat > ${D}${PTEST_PATH}/run-ptest << EOF
+#!/bin/sh
+pytest --automake
+EOF
+               # Ensure the newly created script has the execute bit set
+               chmod 755 ${D}${PTEST_PATH}/run-ptest
        fi
        if [ -d "${S}/${PTEST_PYTEST_DIR}" ]; then
                install -d ${D}${PTEST_PATH}/${PTEST_PYTEST_DIR}
diff --git a/meta/files/ptest-python-pytest/run-ptest b/meta/files/ptest-python-pytest/run-ptest
deleted file mode 100755 (executable)
index 8d2017d..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-pytest --automake