On 2019/03/17 20:24, Kurt Mosiejczuk wrote:
> On Sun, Mar 17, 2019 at 11:12:29PM +0000, Stuart Henderson wrote:
>
> > Instead of making "do-test" conditional, just make MODPY_TEST_CMD
> > conditional instead. It's then carried into MODPY_TEST_TARGET which can
> > stay the same in both cases. No need for a special MODPY_PYTEST_ARGS
> > either; the existing TEST_TARGET does the job nicely. And extend the
> > conditional around do-test, rather than adding a second branch.
> > Untested but I think something like this should do the trick:
>
> > .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
>
> > ...
>
> > . if !target(do-test) && (${MODPY_SETUPUTILS:L} == "yes" ||
> > ${MODPY_PYTEST:L} == "yes")
> > do-test:
> > @${MODPY_TEST_TARGET}
> > . endif
>
> The problem I'm having right now is TEST_TARGETS gets defined as test if it
> is empty. pytest does not use this as a default. I'm testing with an
> adapted devel/py-dateutil and tests just fail with:
>
> ========================= no tests ran in 0.01 seconds
> =========================
> ERROR: file not found: test
>
> I've included my current diff for our final third. It is a diff after the
> first two parts have been applied. I'm also including a diff for py-dateutil.
>
> 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.
Ah OK. In that case, MODPY_PYTEST_ARGS (empty by default, with ?=) makes sense.
> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/devel/py-dateutil/Makefile,v
> retrieving revision 1.28
> diff -u -p -r1.28 Makefile
> --- Makefile 3 Mar 2019 08:28:31 -0000 1.28
> +++ Makefile 18 Mar 2019 00:17:11 -0000
> @@ -18,21 +18,15 @@ MODULES = lang/python
>
> MODPY_PI = Yes
> MODPY_SETUPTOOLS = Yes
> +MODPY_PYTEST = Yes
>
> BUILD_DEPENDS = devel/py-setuptools_scm${MODPY_FLAVOR}
> RUN_DEPENDS = devel/py-six${MODPY_FLAVOR}
> TEST_DEPENDS = devel/py-freezegun${MODPY_FLAVOR} \
> devel/py-hypothesis${MODPY_FLAVOR} \
> - devel/py-six${MODPY_FLAVOR} \
> - devel/py-test${MODPY_FLAVOR}
> + devel/py-six${MODPY_FLAVOR}
>
> FLAVORS = python3
> FLAVOR ?=
> -
> -TEST_ENV += LC_CTYPE=C.UTF-8
> -
> -do-test:
> - cd ${WRKSRC} && exec ${SETENV} ${MAKE_ENV} ${TEST_ENV} \
> - ${MODPY_BIN} -m pytest
>
> .include <bsd.port.mk>
> --- python.port.mk.phase2 Sun Mar 17 19:59:34 2019
> +++ python.port.mk Sun Mar 17 19:59:56 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
> @@ -161,9 +167,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 +220,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