From: Andreas K. Hüttel <dilfri...@gentoo.org>

---
 eclass/perl-module.eclass | 65 ++++++++++++++++++++++++++++++++---------------
 1 file changed, 45 insertions(+), 20 deletions(-)

diff --git a/eclass/perl-module.eclass b/eclass/perl-module.eclass
index faa8a34..c174d5f 100644
--- a/eclass/perl-module.eclass
+++ b/eclass/perl-module.eclass
@@ -314,13 +314,14 @@ perl-module_src_compile() {
 # @DESCRIPTION:
 # (EAPI=6) Variable that controls if tests are run in the test phase
 # at all, and if yes under which conditions. Defaults to "do parallel"
-# In EAPI=5 the variable is called SRC_TEST and defaults to "skip".
-# All of the following have been tested to work:
-#  DIST_TEST="do parallel"
-#  DIST_TEST="parallel"
-#  DIST_TEST="parallel do"
-#  DIST_TEST=parallel
-#  DIST_TEST=skip
+# If neither "do" nor "parallel" is recognized, tests are skipped.
+# (In EAPI=5 the variable is called SRC_TEST, defaults to "skip", and
+# recognizes fewer options.)
+# The following space-separated keywords are recognized:
+#   do       : run tests
+#   parallel : run tests in parallel
+#   verbose  : increase test verbosity
+#   network  : do not try to disable network tests
 
 # @ECLASS-VARIABLE: DIST_TEST_OVERRIDE
 # @DESCRIPTION:
@@ -333,33 +334,57 @@ perl-module_src_compile() {
 # @FUNCTION: perl-module_src-test
 # @USAGE: perl-module_src_test()
 # @DESCRIPTION:
-# This code attempts to work out your threadingness from MAKEOPTS
-# and apply them to Test::Harness.
-#
-# If you want more verbose testing, set TEST_VERBOSE=1
-# in your bashrc | /etc/portage/make.conf | ENV
+# This code attempts to work out your threadingness and runs tests
+# according to the settings of DIST_TEST using Test::Harness.
 perl-module_src_test() {
        debug-print-function $FUNCNAME "$@"
        local my_test_control
+       local my_test_verbose
+
        if [[ ${EAPI:-0} = 5 ]] ; then
                my_test_control=${SRC_TEST}
+               my_test_verbose=${TEST_VERBOSE:-0}
+               if has 'do' ${my_test_control} || has 'parallel' 
${my_test_control} ; then
+                       if has "${my_test_verbose}" 0 && has 'parallel' 
${my_test_control} ; then
+                               export HARNESS_OPTIONS=j$(makeopts_jobs)
+                               einfo "Test::Harness Jobs=$(makeopts_jobs)"
+                       fi
+               else
+                       einfo Skipping tests due to SRC_TEST=${SRC_TEST}
+                       return 0
+               fi
        else
                [[ -n "${DIST_TEST_OVERRIDE}" ]] && ewarn DIST_TEST_OVERRIDE is 
set to ${DIST_TEST_OVERRIDE}
                my_test_control=${DIST_TEST_OVERRIDE:-${DIST_TEST:-do parallel}}
-       fi
 
-       if has 'do' ${my_test_control} || has 'parallel' ${my_test_control} ; 
then
-               if has "${TEST_VERBOSE:-0}" 0 && has 'parallel' 
${my_test_control} ; then
+               if ! has 'do' ${my_test_control} && ! has 'parallel' 
${my_test_control} ; then
+                       einfo Skipping tests due to DIST_TEST=${my_test_control}
+                       return 0
+               fi
+
+               if has verbose ${my_test_control} ; then
+                       my_test_verbose=1
+               else
+                       my_test_verbose=0
+               fi
+
+               if has parallel ${my_test_control} ; then
                        export HARNESS_OPTIONS=j$(makeopts_jobs)
                        einfo "Test::Harness Jobs=$(makeopts_jobs)"
                fi
-               perl_set_version
-               if [[ -f Build ]] ; then
-                       ./Build test verbose=${TEST_VERBOSE:-0} || die "test 
failed"
-               elif [[ -f Makefile ]] ; then
-                       emake test TEST_VERBOSE=${TEST_VERBOSE:-0} || die "test 
failed"
+
+               # this might sometimes work...
+               if ! has network ${my_test_control} ; then
+                       export NO_NETWORK_TESTING=1
                fi
        fi
+
+       perl_set_version
+       if [[ -f Build ]] ; then
+               ./Build test verbose=${my_test_verbose} || die "test failed"
+       elif [[ -f Makefile ]] ; then
+               emake test TEST_VERBOSE=${my_test_verbose} || die "test failed"
+       fi
 }
 
 # @FUNCTION: perl-module_src_install
-- 
2.6.3


Reply via email to