public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH 1/3] distutils-r1: distutils_enable_tests, add 'setup.py' option
@ 2019-11-15 16:35 Michał Górny
  2019-11-15 16:35 ` [gentoo-dev] [PATCH 2/3] distutils-r1.eclass: distutils_enable_tests, handle no deps better Michał Górny
  2019-11-15 16:35 ` [gentoo-dev] [PATCH 3/3] distutils-r1.eclass: Add tests for distutils_enable_tests Michał Górny
  0 siblings, 2 replies; 4+ messages in thread
From: Michał Górny @ 2019-11-15 16:35 UTC (permalink / raw
  To: gentoo-dev; +Cc: python, Michał Górny

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/distutils-r1.eclass | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 2edffdb2d7c5..99da6f5111cd 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -241,6 +241,7 @@ fi
 #
 # - nose: nosetests (dev-python/nose)
 # - pytest: dev-python/pytest
+# - setup.py: setup.py test (no deps included)
 # - unittest: for built-in Python unittest module
 #
 # This function is meant as a helper for common use cases, and it only
@@ -273,6 +274,11 @@ distutils_enable_tests() {
 				pytest -vv || die "Tests fail with ${EPYTHON}"
 			}
 			;;
+		setup.py)
+			python_test() {
+				esetup.py test
+			}
+			;;
 		unittest)
 			python_test() {
 				"${EPYTHON}" -m unittest discover -v ||
-- 
2.24.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-dev] [PATCH 2/3] distutils-r1.eclass: distutils_enable_tests, handle no deps better
  2019-11-15 16:35 [gentoo-dev] [PATCH 1/3] distutils-r1: distutils_enable_tests, add 'setup.py' option Michał Górny
@ 2019-11-15 16:35 ` Michał Górny
  2019-11-16 11:03   ` Michał Górny
  2019-11-15 16:35 ` [gentoo-dev] [PATCH 3/3] distutils-r1.eclass: Add tests for distutils_enable_tests Michał Górny
  1 sibling, 1 reply; 4+ messages in thread
From: Michał Górny @ 2019-11-15 16:35 UTC (permalink / raw
  To: gentoo-dev; +Cc: python, Michał Górny

Do not set IUSE or other variables if the test runner does not have
any deps, and RDEPEND is empty.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/distutils-r1.eclass | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 99da6f5111cd..f316f85c3fc8 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -255,21 +255,16 @@ distutils_enable_tests() {
 	debug-print-function ${FUNCNAME} "${@}"
 	[[ ${#} -eq 1 ]] || die "${FUNCNAME} takes exactly one argument: test-runner"
 
-	[[ ${EAPI} == [56] ]] && local BDEPEND
-
-	IUSE+=" test"
-	RESTRICT+=" !test? ( test )"
-	BDEPEND+=" test? ("
-
+	local test_deps
 	case ${1} in
 		nose)
-			BDEPEND+=" dev-python/nose[${PYTHON_USEDEP}]"
+			test_deps="dev-python/nose[${PYTHON_USEDEP}]"
 			python_test() {
 				nosetests -v || die "Tests fail with ${EPYTHON}"
 			}
 			;;
 		pytest)
-			BDEPEND+=" dev-python/pytest[${PYTHON_USEDEP}]"
+			test_deps="dev-python/pytest[${PYTHON_USEDEP}]"
 			python_test() {
 				pytest -vv || die "Tests fail with ${EPYTHON}"
 			}
@@ -289,9 +284,15 @@ distutils_enable_tests() {
 			die "${FUNCNAME}: unsupported argument: ${1}"
 	esac
 
-	BDEPEND+=" ${RDEPEND} )"
-
-	[[ ${EAPI} == [56] ]] && DEPEND+=" ${BDEPEND}"
+	if [[ -n ${test_deps} || -n ${RDEPEND} ]]; then
+		IUSE+=" test"
+		RESTRICT+=" !test? ( test )"
+		if [[ ${EAPI} == [56] ]]; then
+			DEPEND+=" test? ( ${test_deps} ${RDEPEND} )"
+		else
+			BDEPEND+=" test? ( ${test_deps} ${RDEPEND} )"
+		fi
+	fi
 
 	# we need to ensure successful return in case we're called last,
 	# otherwise Portage may wrongly assume sourcing failed
-- 
2.24.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-dev] [PATCH 3/3] distutils-r1.eclass: Add tests for distutils_enable_tests
  2019-11-15 16:35 [gentoo-dev] [PATCH 1/3] distutils-r1: distutils_enable_tests, add 'setup.py' option Michał Górny
  2019-11-15 16:35 ` [gentoo-dev] [PATCH 2/3] distutils-r1.eclass: distutils_enable_tests, handle no deps better Michał Górny
@ 2019-11-15 16:35 ` Michał Górny
  1 sibling, 0 replies; 4+ messages in thread
From: Michał Górny @ 2019-11-15 16:35 UTC (permalink / raw
  To: gentoo-dev; +Cc: python, Michał Górny

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/tests/distutils-r1.sh | 67 +++++++++++++++++++++++++++++++++++-
 1 file changed, 66 insertions(+), 1 deletion(-)

diff --git a/eclass/tests/distutils-r1.sh b/eclass/tests/distutils-r1.sh
index d557f6cad534..d5f3e2812ca4 100755
--- a/eclass/tests/distutils-r1.sh
+++ b/eclass/tests/distutils-r1.sh
@@ -17,6 +17,36 @@ test-phase_name_free() {
 	fi
 }
 
+test-distutils_enable_tests() {
+	local runner=${1}
+	local exp_IUSE=${2}
+	local exp_RESTRICT=${3}
+	local exp_DEPEND=${4}
+
+	local IUSE=${IUSE}
+	local RESTRICT=${RESTRICT}
+	local DEPEND=${DEPEND}
+
+	tbegin "${runner}"
+
+	distutils_enable_tests "${runner}"
+
+	local ret var
+	for var in IUSE RESTRICT DEPEND; do
+		local exp_var=exp_${var}
+		if [[ ${!var} != "${!exp_var}" ]]; then
+			eindent
+			eerror "${var} expected: ${!exp_var}"
+			eerror "${var}   actual: ${!var}"
+			eoutdent
+			ret=1
+			tret=1
+		fi
+	done
+
+	tend ${ret}
+}
+
 inherit distutils-r1
 
 tbegin "sane function names"
@@ -27,6 +57,41 @@ test-phase_name_free python_compile
 test-phase_name_free python_test
 test-phase_name_free python_install
 
-tend ${failed}
+tend
+
+einfo distutils_enable_tests
+eindent
+BASE_IUSE="python_targets_python2_7"
+BASE_DEPS="python_targets_python2_7? ( >=dev-lang/python-2.7.5-r2:2.7 ) >=dev-lang/python-exec-2:=[python_targets_python2_7(-)?,-python_single_target_python2_7(-)]"
+TEST_RESTRICT=" !test? ( test )"
+
+einfo "empty RDEPEND"
+eindent
+RDEPEND=""
+test-distutils_enable_tests pytest \
+	"${BASE_IUSE} test" "${TEST_RESTRICT}" "${BASE_DEPS} test? ( dev-python/pytest[${PYTHON_USEDEP}]  )"
+test-distutils_enable_tests nose \
+	"${BASE_IUSE} test" "${TEST_RESTRICT}" "${BASE_DEPS} test? ( dev-python/nose[${PYTHON_USEDEP}]  )"
+test-distutils_enable_tests unittest \
+	"${BASE_IUSE}" "" "${BASE_DEPS}"
+test-distutils_enable_tests setup.py \
+	"${BASE_IUSE}" "" "${BASE_DEPS}"
+eoutdent
+
+einfo "non-empty RDEPEND"
+eindent
+BASE_RDEPEND="dev-python/foo[${PYTHON_USEDEP}]"
+RDEPEND=${BASE_RDEPEND}
+test-distutils_enable_tests pytest \
+	"${BASE_IUSE} test" "${TEST_RESTRICT}" "${BASE_DEPS} test? ( dev-python/pytest[${PYTHON_USEDEP}] ${BASE_RDEPEND} )"
+test-distutils_enable_tests nose \
+	"${BASE_IUSE} test" "${TEST_RESTRICT}" "${BASE_DEPS} test? ( dev-python/nose[${PYTHON_USEDEP}] ${BASE_RDEPEND} )"
+test-distutils_enable_tests unittest \
+	"${BASE_IUSE} test" "${TEST_RESTRICT}" "${BASE_DEPS} test? (  ${BASE_RDEPEND} )"
+test-distutils_enable_tests setup.py \
+	"${BASE_IUSE} test" "${TEST_RESTRICT}" "${BASE_DEPS} test? (  ${BASE_RDEPEND} )"
+eoutdent
+
+eoutdent
 
 texit
-- 
2.24.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [gentoo-dev] [PATCH 2/3] distutils-r1.eclass: distutils_enable_tests, handle no deps better
  2019-11-15 16:35 ` [gentoo-dev] [PATCH 2/3] distutils-r1.eclass: distutils_enable_tests, handle no deps better Michał Górny
@ 2019-11-16 11:03   ` Michał Górny
  0 siblings, 0 replies; 4+ messages in thread
From: Michał Górny @ 2019-11-16 11:03 UTC (permalink / raw
  To: gentoo-dev; +Cc: python

[-- Attachment #1: Type: text/plain, Size: 2099 bytes --]

On Fri, 2019-11-15 at 17:35 +0100, Michał Górny wrote:
> Do not set IUSE or other variables if the test runner does not have
> any deps, and RDEPEND is empty.
> 
> Signed-off-by: Michał Górny <mgorny@gentoo.org>
> ---
>  eclass/distutils-r1.eclass | 23 ++++++++++++-----------
>  1 file changed, 12 insertions(+), 11 deletions(-)
> 
> diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
> index 99da6f5111cd..f316f85c3fc8 100644
> --- a/eclass/distutils-r1.eclass
> +++ b/eclass/distutils-r1.eclass
> @@ -255,21 +255,16 @@ distutils_enable_tests() {
>  	debug-print-function ${FUNCNAME} "${@}"
>  	[[ ${#} -eq 1 ]] || die "${FUNCNAME} takes exactly one argument: test-runner"
>  
> -	[[ ${EAPI} == [56] ]] && local BDEPEND
> -
> -	IUSE+=" test"
> -	RESTRICT+=" !test? ( test )"
> -	BDEPEND+=" test? ("
> -
> +	local test_deps
>  	case ${1} in
>  		nose)
> -			BDEPEND+=" dev-python/nose[${PYTHON_USEDEP}]"
> +			test_deps="dev-python/nose[${PYTHON_USEDEP}]"
>  			python_test() {
>  				nosetests -v || die "Tests fail with ${EPYTHON}"
>  			}
>  			;;
>  		pytest)
> -			BDEPEND+=" dev-python/pytest[${PYTHON_USEDEP}]"
> +			test_deps="dev-python/pytest[${PYTHON_USEDEP}]"
>  			python_test() {
>  				pytest -vv || die "Tests fail with ${EPYTHON}"
>  			}
> @@ -289,9 +284,15 @@ distutils_enable_tests() {
>  			die "${FUNCNAME}: unsupported argument: ${1}"
>  	esac
>  
> -	BDEPEND+=" ${RDEPEND} )"
> -
> -	[[ ${EAPI} == [56] ]] && DEPEND+=" ${BDEPEND}"
> +	if [[ -n ${test_deps} || -n ${RDEPEND} ]]; then
> +		IUSE+=" test"
> +		RESTRICT+=" !test? ( test )"
> +		if [[ ${EAPI} == [56] ]]; then
> +			DEPEND+=" test? ( ${test_deps} ${RDEPEND} )"
> +		else
> +			BDEPEND+=" test? ( ${test_deps} ${RDEPEND} )"
> +		fi
> +	fi
>  
>  	# we need to ensure successful return in case we're called last,
>  	# otherwise Portage may wrongly assume sourcing failed

I've pushed this one already since it fixes invalid dependency syntax. 
I'll resend the other two with a small change.

-- 
Best regards,
Michał Górny


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 618 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-11-16 11:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-15 16:35 [gentoo-dev] [PATCH 1/3] distutils-r1: distutils_enable_tests, add 'setup.py' option Michał Górny
2019-11-15 16:35 ` [gentoo-dev] [PATCH 2/3] distutils-r1.eclass: distutils_enable_tests, handle no deps better Michał Górny
2019-11-16 11:03   ` Michał Górny
2019-11-15 16:35 ` [gentoo-dev] [PATCH 3/3] distutils-r1.eclass: Add tests for distutils_enable_tests Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox