On Fri, Mar 15, 2019 at 11:46:30AM +0100, Antoine Jacoutot wrote: > On Fri, Mar 15, 2019 at 10:43:39AM +0000, Stuart Henderson wrote: > > On 2019/03/15 11:25, Antoine Jacoutot wrote: > > > On Fri, Mar 15, 2019 at 09:48:39AM +0000, Stuart Henderson wrote: > > > > I'd really like if this could be factored into the module so we can get > > > > rid > > > > of copies all over the tree.. perhaps behind a MODPY_PYTEST=Yes and > > > > using > > > > something like MODPY_PYTEST_FLAGS for those that need more than just -m > > > > pytest? > > > > > > Why don't we add it by default for lang/python module ports? > > > I mean, would it hurt anything? > > > > We already have a different default test target for python that uses > > setup.py.. It's annoying, there are about 3 common methods. > > I mean adding a default TEST_ENV in the module.
This adds TEST_ENV to python.port.mk. Plus it adds MODPY_PYTEST and MODPY_PYTEST_ARGS to deal with "-m pytest". I counted a bit more than 70 ports using this testing method. I added productivity/vdirsyncer as an example. OK? Remi Index: lang/python/python.port.mk =================================================================== RCS file: /cvs/ports/lang/python/python.port.mk,v retrieving revision 1.100 diff -u -p -r1.100 python.port.mk --- lang/python/python.port.mk 4 Dec 2018 05:57:31 -0000 1.100 +++ lang/python/python.port.mk 16 Mar 2019 20:40:34 -0000 @@ -150,6 +150,7 @@ CONFIGURE_ENV += PYTHON="${MODPY_BIN}" CONFIGURE_ENV += ac_cv_prog_PYTHON="${MODPY_BIN}" \ ac_cv_path_PYTHON="${MODPY_BIN}" .endif +TEST_ENV += LC_CTYPE=C.UTF-8 MODPY_CMD = cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} \ ${MODPY_BIN} ./${MODPY_SETUP} \ @@ -159,6 +160,9 @@ MODPY_TEST_CMD = cd ${WRKSRC} && ${SETEN ${MODPY_BIN} ./${MODPY_SETUP} \ ${MODPY_SETUP_ARGS} +MODPY_PYTEST_CMD = cd ${WRKSRC} && ${SETENV} ${ALL_TEST_ENV} \ + ${MODPY_BIN} -m pytest + SUBST_VARS := MODPY_PYCACHE MODPY_COMMENT MODPY_ABI3SO MODPY_PYC_MAGIC_TAG \ MODPY_BIN MODPY_EGG_VERSION MODPY_VERSION MODPY_BIN_SUFFIX \ MODPY_PY_PREFIX MODPY_PYOEXTENSION ${SUBST_VARS} @@ -184,6 +188,8 @@ MODPY_INSTALL_TARGET = \ ${MODPY_DISTUTILS_INSTALL} ${MODPY_DISTUTILS_INSTALLARGS} MODPY_TEST_TARGET = \ ${MODPY_TEST_CMD} ${TEST_TARGET} +MODPY_PYTEST ?= no +MODPY_PYTEST_ARGS ?= # dirty way to do it with no modifications in bsd.port.mk .if empty(CONFIGURE_STYLE) @@ -198,8 +204,11 @@ do-install: @${MODPY_INSTALL_TARGET} . endif +. if !target(do-test) && ${MODPY_PYTEST:L} == "yes" +do-test: + ${MODPY_PYTEST_CMD} ${MODPY_PYTEST_ARGS} # setuptools supports regress testing from setup.py using a standard target -. if !target(do-test) && ${MODPY_SETUPUTILS:L} == "yes" +. elif !target(do-test) && ${MODPY_SETUPUTILS:L} == "yes" do-test: @${MODPY_TEST_TARGET} . endif Index: productivity/vdirsyncer/Makefile =================================================================== RCS file: /cvs/ports/productivity/vdirsyncer/Makefile,v retrieving revision 1.7 diff -u -p -r1.7 Makefile --- productivity/vdirsyncer/Makefile 16 Aug 2018 21:37:55 -0000 1.7 +++ productivity/vdirsyncer/Makefile 16 Mar 2019 20:40:34 -0000 @@ -20,6 +20,8 @@ MODULES = lang/python MODPY_VERSION= ${MODPY_DEFAULT_VERSION_3} MODPY_PI = Yes MODPY_SETUPTOOLS = Yes +MODPY_PYTEST = Yes +MODPY_PYTEST_ARGS = tests/ BUILD_DEPENDS = textproc/py-sphinx${MODPY_FLAVOR} \ devel/py-setuptools_scm${MODPY_FLAVOR} \ @@ -37,6 +39,9 @@ TEST_DEPENDS = devel/py-hypothesis${MOD www/py-urllib3${MODPY_FLAVOR} \ ${RUN_DEPENDS} +TEST_ENV += DAV_SERVER=skip \ + DETERMINISTIC_TESTS=true + post-build: cd ${WRKSRC}/docs; ${MAKE_ENV} PYTHONPATH=${WRKSRC} \ sphinx-build${MODPY_BIN_SUFFIX} \ @@ -52,9 +57,5 @@ post-install: pax -rw * ${PREFIX}/share/doc/vdirsyncer ${INSTALL_DATA} ${WRKSRC}/config.example \ ${PREFIX}/share/examples/vdirsyncer - -do-test: - cd ${WRKSRC}; DAV_SERVER=skip DETERMINISTIC_TESTS=true \ - ${MODPY_BIN} -m pytest tests/ .include <bsd.port.mk>