diff mbox series

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

Message ID 20250107203009.3251029-1-derek@asterius.io
State New
Headers show
Series classes/ptest-python-pytest: simplify python ptest file overriding | expand

Commit Message

Derek Straka Jan. 7, 2025, 8:30 p.m. UTC
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.

Signed-off-by: Derek Straka <derek@asterius.io>
---
 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

Comments

Richard Purdie Jan. 7, 2025, 10:35 p.m. UTC | #1
On Tue, 2025-01-07 at 20:30 +0000, Derek Straka via lists.openembedded.org wrote:
> 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.
> 
> Signed-off-by: Derek Straka <derek@asterius.io>
> ---
>  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
> 
> diff --git a/meta/classes-recipe/ptest-python-pytest.bbclass b/meta/classes-recipe/ptest-python-pytest.bbclass
> index 801079e6ab..7ed84584b7 100644
> --- a/meta/classes-recipe/ptest-python-pytest.bbclass
> +++ b/meta/classes-recipe/ptest-python-pytest.bbclass
> @@ -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
> +

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

Cheers,

Richard
Derek Straka Jan. 8, 2025, 12:15 a.m. UTC | #2
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.

On Tue, Jan 7, 2025 at 4:35 PM Richard Purdie <
richard.purdie@linuxfoundation.org> wrote:

> On Tue, 2025-01-07 at 20:30 +0000, Derek Straka via lists.openembedded.org
> wrote:
> > 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.
> >
> > Signed-off-by: Derek Straka <derek@asterius.io>
> > ---
> >  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
> >
> > diff --git a/meta/classes-recipe/ptest-python-pytest.bbclass
> b/meta/classes-recipe/ptest-python-pytest.bbclass
> > index 801079e6ab..7ed84584b7 100644
> > --- a/meta/classes-recipe/ptest-python-pytest.bbclass
> > +++ b/meta/classes-recipe/ptest-python-pytest.bbclass
> > @@ -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
> > +
>
> Do you need to set the exec bit on that file having created it?
>
> Cheers,
>
> Richard
>
>
Alexander Kanavin Jan. 8, 2025, 4:30 p.m. UTC | #3
On Wed, 8 Jan 2025 at 01:16, Derek Straka via lists.openembedded.org
<derek=asterius.io@lists.openembedded.org> wrote:
>
> 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
diff mbox series

Patch

diff --git a/meta/classes-recipe/ptest-python-pytest.bbclass b/meta/classes-recipe/ptest-python-pytest.bbclass
index 801079e6ab..7ed84584b7 100644
--- a/meta/classes-recipe/ptest-python-pytest.bbclass
+++ b/meta/classes-recipe/ptest-python-pytest.bbclass
@@ -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}
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