Gentoo Archives: gentoo-dev

From: Florian Schmaus <flow@g.o>
To: gentoo-dev@l.g.o
Cc: Florian Schmaus <flow@g.o>, "Miroslav Šulc" <fordfrog@g.o>
Subject: [gentoo-dev] [PATCH] java-utils-2.eclass: introduce JAVA_TEST_RUNNER_EXTRA_ARGS
Date: Fri, 22 Apr 2022 13:17:27
Message-Id: 20220422131703.1661567-1-flow@gentoo.org
1 Also add special handling wrt -usedfaultlisteners for TestNG, see
2 bug #801694.
3
4 Signed-off-by: Florian Schmaus <flow@g.o>
5 Co-authored-by: Miroslav Šulc <fordfrog@g.o>
6 Bug: https://bugs.gentoo.org/801694
7 ---
8 eclass/java-utils-2.eclass | 49 +++++++++++++++++++++++++++++++-------
9 1 file changed, 41 insertions(+), 8 deletions(-)
10
11 diff --git a/eclass/java-utils-2.eclass b/eclass/java-utils-2.eclass
12 index 2a649942550c..6303895885df 100644
13 --- a/eclass/java-utils-2.eclass
14 +++ b/eclass/java-utils-2.eclass
15 @@ -139,6 +139,20 @@ JAVA_PKG_ALLOW_VM_CHANGE=${JAVA_PKG_ALLOW_VM_CHANGE:="yes"}
16 # )
17 # @CODE
18
19 +# @ECLASS-VARIABLE: JAVA_TEST_RUNNER_EXTRA_ARGS
20 +# @DEFAULT_UNSET
21 +# @DESCRIPTION:
22 +# Array of extra arguments that should be passed to the test runner when running tests.
23 +# It is useful when you need to pass an extra argument to the test runner.
24 +#
25 +# It is used only when running tests.
26 +#
27 +# @CODE
28 +# JAVA_TEST_RUNNER_EXTRA_ARGS=(
29 +# -verbose 3
30 +# )
31 +# @CODE
32 +
33 # @ECLASS_VARIABLE: JAVA_PKG_DEBUG
34 # @DEFAULT_UNSET
35 # @DESCRIPTION:
36 @@ -1807,8 +1821,18 @@ ejunit_() {
37 if [[ "${junit}" == "junit-4" ]] ; then
38 runner=org.junit.runner.JUnitCore
39 fi
40 - debug-print "Calling: java -cp \"${cp}\" -Djava.io.tmpdir=\"${T}\" -Djava.awt.headless=true ${JAVA_TEST_EXTRA_ARGS[@]} ${runner} ${@}"
41 - java -cp "${cp}" -Djava.io.tmpdir="${T}/" -Djava.awt.headless=true ${JAVA_TEST_EXTRA_ARGS[@]} ${runner} "${@}" || die "Running junit failed"
42 +
43 + local args=(
44 + -cp ${cp}
45 + -Djava.io.tmpdir="${T}"
46 + -Djava.awt.headless=true
47 + ${JAVA_TEST_EXTRA_ARGS[@]}
48 + ${runner}
49 + ${JAVA_TEST_RUNNER_EXTRA_ARGS[@]}
50 + ${@}
51 + )
52 + debug-print "Calling: java ${args[@]}"
53 + java "${args[@]}" || die "Running junit failed"
54 }
55
56 # @FUNCTION: ejunit
57 @@ -1886,12 +1910,21 @@ etestng() {
58 tests+="${test},"
59 done
60
61 - debug-print "java -cp \"${cp}\" -Djava.io.tmpdir=\"${T}\""\
62 - "-Djava.awt.headless=true ${JAVA_TEST_EXTRA_ARGS[@]} ${runner}"\
63 - "-usedefaultlisteners false -testclass ${tests}"
64 - java -cp "${cp}" -Djava.io.tmpdir=\"${T}\" -Djava.awt.headless=true ${JAVA_TEST_EXTRA_ARGS[@]}\
65 - ${runner} -usedefaultlisteners false -testclass ${tests}\
66 - || die "Running TestNG failed."
67 + local args=(
68 + -cp ${cp}
69 + -Djava.io.tmpdir="${T}"
70 + -Djava.awt.headless=true
71 + ${JAVA_TEST_EXTRA_ARGS[@]}
72 + ${runner}
73 + ${JAVA_TEST_RUNNER_EXTRA_ARGS[@]}
74 + )
75 +
76 + [[ ! "${JAVA_TEST_RUNNER_EXTRA_ARGS[@]}" =~ "-usedefaultlisteners" ]] && args+=( -usedefaultlisteners false )
77 +
78 + args+=( -testclass ${tests} )
79 +
80 + debug-print "java ${args[@]}"
81 + java ${args[@]} || die "Running TestNG failed."
82 }
83
84 # @FUNCTION: java-utils-2_src_prepare
85 --
86 2.35.1