Gentoo Archives: gentoo-commits

From: "Miroslav Šulc" <fordfrog@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Sat, 03 Jul 2021 06:21:44
Message-Id: 1625293292.3ac5e8eef28744ef11948894c1f7cf64586f36d7.fordfrog@gentoo
1 commit: 3ac5e8eef28744ef11948894c1f7cf64586f36d7
2 Author: Miroslav Šulc <fordfrog <AT> gentoo <DOT> org>
3 AuthorDate: Sat Jul 3 06:21:16 2021 +0000
4 Commit: Miroslav Šulc <fordfrog <AT> gentoo <DOT> org>
5 CommitDate: Sat Jul 3 06:21:32 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3ac5e8ee
7
8 java-utils-2.eclass: added support for parsing args to tests
9
10 Signed-off-by: Miroslav Šulc <fordfrog <AT> gentoo.org>
11
12 eclass/java-utils-2.eclass | 24 ++++++++++++++++++++----
13 1 file changed, 20 insertions(+), 4 deletions(-)
14
15 diff --git a/eclass/java-utils-2.eclass b/eclass/java-utils-2.eclass
16 index 7b61c0b74cf..ed4951ac97b 100644
17 --- a/eclass/java-utils-2.eclass
18 +++ b/eclass/java-utils-2.eclass
19 @@ -125,6 +125,22 @@ JAVA_PKG_ALLOW_VM_CHANGE=${JAVA_PKG_ALLOW_VM_CHANGE:="yes"}
20 # JAVA_PKG_WANT_TARGET=1.3 emerge bar
21 # @CODE
22
23 +# @ECLASS-VARIABLE: JAVA_TEST_EXTRA_ARGS
24 +# @DEFAULT_UNSET
25 +# @DESCRIPTION:
26 +# Array of extra arguments that should be passed to java command when running tests.
27 +# It is useful when you need to pass a value to a Java program that uses
28 +# System.getProperty(). If it uses System.getenv(), use `export var=value` instead.
29 +#
30 +# It is used only when running tests.
31 +#
32 +# @CODE
33 +# JAVA_TEST_EXTRA_ARGS=(
34 +# -Dsome.var=x
35 +# "-Dother.var=\"y z\""
36 +# )
37 +# @CODE
38 +
39 # @ECLASS-VARIABLE: JAVA_PKG_DEBUG
40 # @DEFAULT_UNSET
41 # @DESCRIPTION:
42 @@ -1797,8 +1813,8 @@ ejunit_() {
43 if [[ "${junit}" == "junit-4" ]] ; then
44 runner=org.junit.runner.JUnitCore
45 fi
46 - debug-print "Calling: java -cp \"${cp}\" -Djava.io.tmpdir=\"${T}\" -Djava.awt.headless=true ${runner} ${@}"
47 - java -cp "${cp}" -Djava.io.tmpdir="${T}/" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
48 + debug-print "Calling: java -cp \"${cp}\" -Djava.io.tmpdir=\"${T}\" -Djava.awt.headless=true ${JAVA_TEST_EXTRA_ARGS[@]} ${runner} ${@}"
49 + java -cp "${cp}" -Djava.io.tmpdir="${T}/" -Djava.awt.headless=true ${JAVA_TEST_EXTRA_ARGS[@]} ${runner} "${@}" || die "Running junit failed"
50 }
51
52 # @FUNCTION: ejunit
53 @@ -1877,9 +1893,9 @@ etestng() {
54 done
55
56 debug-print "java -cp \"${cp}\" -Djava.io.tmpdir=\"${T}\""\
57 - "-Djava.awt.headless=true ${runner}"\
58 + "-Djava.awt.headless=true ${JAVA_TEST_EXTRA_ARGS[@]} ${runner}"\
59 "-usedefaultlisteners false -testclass ${tests}"
60 - java -cp "${cp}" -Djava.io.tmpdir=\"${T}\" -Djava.awt.headless=true\
61 + java -cp "${cp}" -Djava.io.tmpdir=\"${T}\" -Djava.awt.headless=true ${JAVA_TEST_EXTRA_ARGS[@]}\
62 ${runner} -usedefaultlisteners false -testclass ${tests}\
63 || die "Running TestNG failed."
64 }