On 2019/03/17 20:41, Kurt Mosiejczuk wrote:
> On Sun, Mar 17, 2019 at 08:24:07PM -0400, Kurt Mosiejczuk wrote:
>
> > In the default case with pytest we *don't* want a TEST_TARGET to
> > happen but if we leave it empty it gets filled in. We don't want to
> > override it to empty it if it has been set. So we'd be back at some
> > sort of dance with MODPY_PYTEST_ARGS. I may be missing something
> > though.
>
> Got it. If it is empty, we set it to "./". That makes pytest happy since
> it can be fed a directory and it keeps it from getting filled in with
> test.
>
> --Kurt
>
> --- python.port.mk.phase2 Sun Mar 17 19:59:34 2019
> +++ python.port.mk Sun Mar 17 20:38:54 2019
> @@ -63,12 +63,18 @@ MODPY_PYOEXTENSION = pyo
> MODPY_PYOEXTENSION ?= opt-1.pyc
> .endif
>
> -MODPY_WANTLIB = python${MODPY_VERSION}${MODPY_LIB_SUFFIX}
> +MODPY_WANTLIB = python${MODPY_VERSION}${MODPY_LIB_SUFFIX}
>
> +MODPY_PYTEST ?= no
> +
> MODPY_RUN_DEPENDS = lang/python/${MODPY_VERSION}
> MODPY_LIB_DEPENDS = lang/python/${MODPY_VERSION}
> _MODPY_BUILD_DEPENDS = lang/python/${MODPY_VERSION}
> +.if ${MODPY_PYTEST:L} == "yes"
> +MODPY_TEST_DEPENDS = devel/py-test${MODPY_FLAVOR}
> +.else
> MODPY_TEST_DEPENDS =
> +.endif
>
> .if ${NO_BUILD:L} == "no"
> MODPY_BUILDDEP ?= Yes
> @@ -91,6 +97,14 @@ TEST_DEPENDS += ${MODPY_TEST_DEPENDS}
> .endif
>
> _MODPY_PRE_BUILD_STEPS = :
> +.if ${MODPY_PYTEST:L} == "yes"
> +# pytest doesn't need a target, but empty will get filled in
> +TEST_TARGET ?= ./
I'm about to zzz now so haven't tested... but I suppose the effective
default setting could come from a previously loaded mk file from another
MODULES entry if there are more than one.. These empty variables are
awkward! So this may indeed need a specific variable.
> +.elif defined(MODPY_SETUPTOOLS) && ${MODPY_PYTEST:L} == "no"
> +# The setuptools uses test target while pytest does not
> +TEST_TARGET ?= test
> +.endif
> +
> .if defined(MODPY_SETUPTOOLS) && ${MODPY_SETUPTOOLS:L} == "yes"
> # The setuptools module provides a package locator (site.py) that is
> # required at runtime for the pkg_resources stuff to work
> @@ -99,8 +113,6 @@ MODPY_SETUPUTILS_DEPEND ?= devel/py-setuptools${MODPY_
> MODPY_RUN_DEPENDS += ${MODPY_SETUPUTILS_DEPEND}
> BUILD_DEPENDS += ${MODPY_SETUPUTILS_DEPEND}
> MODPY_SETUPUTILS = Yes
> -# The setuptools uses test target
> -TEST_TARGET ?= test
> _MODPY_USERBASE =
> _MODPY_PRE_BUILD_STEPS += ;${MODPY_CMD} egg_info || true
> .else
> @@ -161,9 +173,14 @@ MODPY_CMD = cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} \
> ${MODPY_BIN} ./${MODPY_SETUP} \
> ${MODPY_SETUP_ARGS}
>
> +.if ${MODPY_PYTEST:L} == "yes"
> MODPY_TEST_CMD = cd ${WRKSRC} && ${SETENV} ${ALL_TEST_ENV} \
> + ${MODPY_BIN} -m pytest
> +.else
> +MODPY_TEST_CMD = cd ${WRKSRC} && ${SETENV} ${ALL_TEST_ENV} \
> ${MODPY_BIN} ./${MODPY_SETUP} \
> ${MODPY_SETUP_ARGS}
> +.endif
>
> MODPY_TEST_LOCALE ?= LC_CTYPE=en_US.UTF-8
>
> @@ -209,7 +226,8 @@ do-install:
> . endif
>
> # setuptools supports regress testing from setup.py using a standard target
> -. if !target(do-test) && ${MODPY_SETUPUTILS:L} == "yes"
> +. if !target(do-test) && (${MODPY_SETUPUTILS:L} == "yes" || \
> + ${MODPY_PYTEST:L} == "yes" )
> do-test:
> @${MODPY_TEST_TARGET}
> . endif
>