Skip to contentSkip to conversation

classes/ptest-python-pytest: simplify python ptest file overriding

PATCH Superseded Derek Straka 3 participants 4 messages Jan 7, 2025 – Jan 8, 2025

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 classes/ptest-python-pytest: simplify python ptest file overriding

The complexity of overriding files from the bbclass made the behavior at times hard to follow. 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.

---
 meta/classes-recipe/ptest-python-pytest.bbclass | 12 +++++-------
 meta/files/ptest-python-pytest/run-ptest        |  3 ---
 2 files changed, 5 insertions(+), 10 deletions(-)
 delete mode 100755 meta/files/ptest-python-pytest/run-ptest
meta/classes-recipe/ptest-python-pytest.bbclass +5 -7
index 801079e6ab..7ed84584b7 100644
@@ -6,19 +6,17 @@
 
 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}
+		cat > ${D}${PTEST_PATH}/run-ptest << EOF
+#!/bin/sh
+pytest --automake
+EOF
+
 	fi
     if [ -d "${S}/${PTEST_PYTEST_DIR}" ]; then
         install -d ${D}${PTEST_PATH}/${PTEST_PYTEST_DIR}
meta/files/ptest-python-pytest/run-ptest deleted +0 -3
deleted file mode 100755
index 8d2017d39c..0000000000
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-pytest --automake
Signature · 1 line
2.34.1
#1 lore raw
Quoted 32 lines · Derek Straka via lists.openembedded.org

The complexity of overriding files from the bbclass made the behavior at times hard to follow. 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.

---
 meta/classes-recipe/ptest-python-pytest.bbclass | 12 +++++------- meta/files/ptest-python-pytest/run-ptest        |  3 ---

 2 files changed, 5 insertions(+), 10 deletions(-)

 delete mode 100755 meta/files/ptest-python-pytest/run-ptest

meta/classes-recipe/ptest-python-pytest.bbclass +0 -0
index 801079e6ab..7ed84584b7 100644
@@ -6,19 +6,17 @@


 inherit ptest

meta/classes-recipe/ptest-python-pytest.bbclass +0 -6
-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

meta/classes-recipe/ptest-python-pytest.bbclass line 19

Quoted 6 lines
meta/classes-recipe/ptest-python-pytest.bbclass +5 -1
-		install -m 0755 ${UNPACKDIR}/ptest-python-pytest/run-ptest ${D}${PTEST_PATH}
+		cat > ${D}${PTEST_PATH}/run-ptest << EOF
+#!/bin/sh
+pytest --automake
+EOF
+

Do you need to set the exec bit on that file having created it?

Cheers,

Richard

#2 lore raw

Thanks for the review! Yes, I shouldn't make an assumption about the execute bit. I will send a v2 with that and an update to look at S or UNPACKDIR as the key to create the default run-ptest in the morning.

Quoted 51 lines · Richard Purdie
Quoted 3 lines · Derek Straka via lists.openembedded.org

The complexity of overriding files from the bbclass made the behavior at times hard to follow. This change replaces the default file with a heredoc equivalent that creates a default file if the user does not

provide their

Review

Quoted 10 lines

own version of run-ptest.

---
 meta/classes-recipe/ptest-python-pytest.bbclass | 12 +++++-------
 meta/files/ptest-python-pytest/run-ptest        |  3 ---
 2 files changed, 5 insertions(+), 10 deletions(-)
 delete mode 100755 meta/files/ptest-python-pytest/run-ptest
(quoted diff) +0 -0

b/meta/classes-recipe/ptest-python-pytest.bbclass

Quoted 10 lines

index 801079e6ab..7ed84584b7 100644

meta/classes-recipe/ptest-python-pytest.bbclass +0 -3
@@ -6,19 +6,17 @@
 
 inherit ptest
 
-FILESEXTRAPATHS:prepend := "${COREBASE}/meta/files:"
-
-SRC_URI:append = "\

meta/classes-recipe/ptest-python-pytest.bbclass line 21

Quoted 10 lines
meta/classes-recipe/ptest-python-pytest.bbclass +0 -4
-    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}

meta/classes-recipe/ptest-python-pytest.bbclass line 19

Quoted 5 lines
meta/classes-recipe/ptest-python-pytest.bbclass +5 -0
+             cat > ${D}${PTEST_PATH}/run-ptest << EOF
+#!/bin/sh
+pytest --automake
+EOF
+

Do you need to set the exec bit on that file having created it?

Cheers,

Richard

#3 lore raw
Quoted 2 lines · Derek Straka via lists.openembedded.org

Thanks for the review! Yes, I shouldn't make an assumption about the execute bit. I will send a v2 with that and an update to look at S or UNPACKDIR as the key to create the default run-ptest in the morning.

Yes please, do verify that overriding with a custom recipe-specific run-ptest works (and bonus points for writing instructions into the class comments about how to do it).

Alex