commit:     95fbb322960db274e981b5632dc9a01e540ee8f6
Author:     Volkmar W. Pogatzki <gentoo <AT> pogatzki <DOT> net>
AuthorDate: Mon Feb 27 12:26:24 2023 +0000
Commit:     Miroslav Šulc <fordfrog <AT> gentoo <DOT> org>
CommitDate: Wed Oct 18 07:46:32 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=95fbb322

java-utils-2.eclass: allow etestng to run testng.xml

The etestng function is presently limited to running test classes and
has no option for running testng.xml files. Using testng.xml in an
ebuild requires manual coding in src_test().

This change adds a switch to the etestng function which allows running
default src_test() with either testng.xml files or test classes.

Signed-off-by: Volkmar W. Pogatzki <gentoo <AT> pogatzki.net>
Signed-off-by: Miroslav Šulc <fordfrog <AT> gentoo.org>

 eclass/java-utils-2.eclass | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/eclass/java-utils-2.eclass b/eclass/java-utils-2.eclass
index 92e02e3085b1..1efb655acf71 100644
--- a/eclass/java-utils-2.eclass
+++ b/eclass/java-utils-2.eclass
@@ -1886,7 +1886,7 @@ ejunit4() {
 # @CODE
 # $1 - -cp or -classpath
 # $2 - the classpath passed to it
-# $@ - test classes for testng to run.
+# $@ - test classes or testng.xml for testng to run.
 # @CODE
 etestng() {
        debug-print-function ${FUNCNAME} $*
@@ -1910,6 +1910,7 @@ etestng() {
                -cp ${cp}
                -Djava.io.tmpdir="${T}"
                -Djava.awt.headless=true
+               -Dtest.resources.dir="${JAVA_TEST_RESOURCE_DIRS}"
                ${JAVA_TEST_EXTRA_ARGS[@]}
                ${runner}
                ${JAVA_TEST_RUNNER_EXTRA_ARGS[@]}
@@ -1922,7 +1923,11 @@ etestng() {
                )
        fi
 
-       args+=( -testclass ${tests} )
+       if [[ "${test%.xml}" == "${test}" ]]; then
+               args+=( -testclass ${tests} )
+       else
+               args+=( ${tests%,} )
+       fi
 
        debug-print "java ${args[@]}"
        java ${args[@]} || die "Running TestNG failed."

Reply via email to