Openembedded Core Discussions
 help / color / mirror / Atom feed
* [OE-core][PATCHv3] classes/ptest-python-pytest: simplify python ptest file overriding
@ 2025-01-10 15:59 Derek Straka
  2025-01-13 12:35 ` Quentin Schulz
  0 siblings, 1 reply; 2+ messages in thread
From: Derek Straka @ 2025-01-10 15:59 UTC (permalink / raw)
  To: openembedded-core; +Cc: Derek Straka

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>
---
 .../ptest-python-pytest.bbclass               | 30 +++++++++++--------
 meta/files/ptest-python-pytest/run-ptest      |  3 --
 2 files changed, 18 insertions(+), 15 deletions(-)
 delete mode 100755 meta/files/ptest-python-pytest/run-ptest

diff --git a/meta/classes-recipe/ptest-python-pytest.bbclass b/meta/classes-recipe/ptest-python-pytest.bbclass
index 801079e6ab..0ece83dfc8 100644
--- a/meta/classes-recipe/ptest-python-pytest.bbclass
+++ b/meta/classes-recipe/ptest-python-pytest.bbclass
@@ -6,24 +6,30 @@
 
 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}
+		cp -rf ${S}/${PTEST_PYTEST_DIR}/* ${D}${PTEST_PATH}/${PTEST_PYTEST_DIR}/
 	fi
-    if [ -d "${S}/${PTEST_PYTEST_DIR}" ]; then
-        install -d ${D}${PTEST_PATH}/${PTEST_PYTEST_DIR}
-        cp -rf ${S}/${PTEST_PYTEST_DIR}/* ${D}${PTEST_PATH}/${PTEST_PYTEST_DIR}/
-    fi
 }
 
 FILES:${PN}-ptest:prepend = "${PTEST_PATH}/*"
diff --git a/meta/files/ptest-python-pytest/run-ptest b/meta/files/ptest-python-pytest/run-ptest
deleted file mode 100755
index 8d2017d39c..0000000000
--- a/meta/files/ptest-python-pytest/run-ptest
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-pytest --automake
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-01-13 12:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-10 15:59 [OE-core][PATCHv3] classes/ptest-python-pytest: simplify python ptest file overriding Derek Straka
2025-01-13 12:35 ` Quentin Schulz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox