On 2019/04/22 14:25, Kurt Mosiejczuk wrote:
> Landry was having a problem converting geo/py-proj to use MODPY_PYTEST.
> The tests just wouldn't run. The port had to cd into ${WRKSRC}/test and
> then run pytest. Normally the solution would be to put "test" into
> MODPY_PYTEST_ARGS and pytest would be happy. That doesn't work in this
> case.
>
> So I added MODPY_TEST_DIR to python.port.mk. It defaults to ${WRKSRC}
> so default behavior is identical, but in a case where you need to cd
> into another directory for the tests to work, you can override it.
>
> Landry tested this diff and it solved his issue with geo/py-proj.
>
> I've tested a handful of ports with this. It's a pretty trivial change
> to the logic.
>
> I am also including a diff for port-modules(5).
>
> --Kurt
>
> python.port.mk portion
>
> Index: python.port.mk
> ===================================================================
> RCS file: /cvs/ports/lang/python/python.port.mk,v
> retrieving revision 1.106
> diff -u -p -r1.106 python.port.mk
> --- python.port.mk 21 Apr 2019 09:33:32 -0000 1.106
> +++ python.port.mk 22 Apr 2019 18:12:13 -0000
> @@ -169,7 +169,9 @@ MODPY_CMD = cd ${WRKSRC} && ${SETENV} ${
> ${MODPY_BIN} ./${MODPY_SETUP} \
> ${MODPY_SETUP_ARGS}
>
> -MODPY_TEST_CMD = cd ${WRKSRC} && ${SETENV} ${ALL_TEST_ENV} ${MODPY_BIN}
> +MODPY_TEST_DIR ?= ${WRKSRC}
> +
> +MODPY_TEST_CMD = cd ${MODPY_TEST_DIR} && ${SETENV} ${ALL_TEST_ENV}
> ${MODPY_BIN}
> .if ${MODPY_PYTEST:L} == "yes"
> MODPY_TEST_CMD += -m pytest
> .else
>
> port-modules man page diff
>
>
> Index: port-modules.5
> ===================================================================
> RCS file: /cvs/src/share/man/man5/port-modules.5,v
> retrieving revision 1.238
> diff -u -p -r1.238 port-modules.5
> --- port-modules.5 4 Apr 2019 02:28:23 -0000 1.238
> +++ port-modules.5 22 Apr 2019 18:16:28 -0000
> @@ -1332,6 +1332,7 @@ Sets
> .Ev MODPY_SITEPKG ,
> .Ev MODPY_SETUP ,
> .Ev MODPY_TEST_LOCALE ,
> +.Ev MODPY_TEST_DIR ,
> .Ev MODPY_WANTLIB ,
> .Ev MODPY_LIB_DEPENDS ,
> .Ev MODPY_RUN_DEPENDS ,
> @@ -1375,6 +1376,10 @@ Arguments can be passed to pytest during
> .Cm test
> with
> .Ev MODPY_PYTEST_ARGS .
> +The directory to change to during
> +.Cm test
> +can be set via
> +.Ev MODPY_TEST_DIR .
> All ports that generate egg-info files should set
> .Ev MODPY_EGG_VERSION
> to the version string used by the port's setup.py setup() function.
>
I think maybe this reads a bit better?
pytest tests are run from the directory specified in
.Ev MODPY_TEST_DIR ,
by default WRKSRC.