From 746ce7f1ccef68849f051ec6e3ed717c374b0074 Mon Sep 17 00:00:00 2001 From: Miroslav Šulc Date: Sun, 4 Jul 2021 15:53:43 +0200 Subject: java-pkg-simple.eclass: added support for running only selected test classes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miroslav Šulc --- eclass/java-pkg-simple.eclass | 53 +++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/eclass/java-pkg-simple.eclass b/eclass/java-pkg-simple.eclass index 174fa08ce4ea..184934eb3bd3 100644 --- a/eclass/java-pkg-simple.eclass +++ b/eclass/java-pkg-simple.eclass @@ -168,6 +168,17 @@ fi # JAVA_TESTING_FRAMEWORKS="junit pkgdiff" # @CODE +# @ECLASS-VARIABLE: JAVA_TEST_RUN_ONLY +# @DEFAULT_UNSET +# @DESCRIPTION: +# A array of classes that should be executed during src_test(). This variable +# has precedence over JAVA_TEST_EXCLUDES, that is if this variable is set, +# the other variable is ignored. +# +# @CODE +# JAVA_TEST_RUN_ONLY=( "net.sf.cglib.AllTests" "net.sf.cglib.TestAll" ) +# @CODE + # @ECLASS-VARIABLE: JAVA_TEST_EXCLUDES # @DEFAULT_UNSET # @DESCRIPTION: @@ -517,25 +528,29 @@ java-pkg-simple_src_test() { fi # grab a set of tests that testing framework will run - tests_to_run=$(find "${classes}" -type f\ - \( -name "*Test.class"\ - -o -name "Test*.class"\ - -o -name "*Tests.class"\ - -o -name "*TestCase.class" \)\ - ! -name "*Abstract*"\ - ! -name "*BaseTest*"\ - ! -name "*TestTypes*"\ - ! -name "*TestUtils*"\ - ! -name "*\$*") - tests_to_run=${tests_to_run//"${classes}"\/} - tests_to_run=${tests_to_run//.class} - tests_to_run=${tests_to_run//\//.} - - # exclude extra test classes, usually corner cases - # that the code above cannot handle - for class in "${JAVA_TEST_EXCLUDES[@]}"; do - tests_to_run=${tests_to_run//${class}} - done + if [[ -n ${JAVA_TEST_RUN_ONLY} ]]; then + tests_to_run="${JAVA_TEST_RUN_ONLY[@]}" + else + tests_to_run=$(find "${classes}" -type f\ + \( -name "*Test.class"\ + -o -name "Test*.class"\ + -o -name "*Tests.class"\ + -o -name "*TestCase.class" \)\ + ! -name "*Abstract*"\ + ! -name "*BaseTest*"\ + ! -name "*TestTypes*"\ + ! -name "*TestUtils*"\ + ! -name "*\$*") + tests_to_run=${tests_to_run//"${classes}"\/} + tests_to_run=${tests_to_run//.class} + tests_to_run=${tests_to_run//\//.} + + # exclude extra test classes, usually corner cases + # that the code above cannot handle + for class in "${JAVA_TEST_EXCLUDES[@]}"; do + tests_to_run=${tests_to_run//${class}} + done + fi # launch test for framework in ${JAVA_TESTING_FRAMEWORKS}; do -- cgit v1.2.3-65-gdbad