* [gentoo-java] Default src_test
@ 2008-02-13 21:36 Petteri Räty
0 siblings, 0 replies; only message in thread
From: Petteri Räty @ 2008-02-13 21:36 UTC (permalink / raw
To: Gentoo Java
[-- Attachment #1.1: Type: text/plain, Size: 159 bytes --]
Here is a proposal as a default src_test function.
It uses autodetection to see if there is a test target in build.xml and
runs that.
Regards,
Petteri
[-- Attachment #1.2: java-default-src_test.patch --]
[-- Type: text/plain, Size: 1802 bytes --]
Index: java-pkg-2.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/java-pkg-2.eclass,v
retrieving revision 1.25
diff -u -r1.25 java-pkg-2.eclass
--- java-pkg-2.eclass 13 Nov 2007 19:36:50 -0000 1.25
+++ java-pkg-2.eclass 13 Feb 2008 21:35:12 -0000
@@ -43,7 +43,7 @@
# ------------------------------------------------------------------------------
RDEPEND="${DEPEND}"
-EXPORT_FUNCTIONS pkg_setup src_compile
+EXPORT_FUNCTIONS pkg_setup src_compile src_test
# ------------------------------------------------------------------------------
# @eclass-pkg_setup
@@ -87,6 +87,40 @@
fi
}
+java-pkg-2_supports-test() {
+ python << EOF
+from xml.dom.minidom import parse
+import sys
+dom = parse("${1}")
+for elem in dom.getElementsByTagName('target'):
+ if elem.getAttribute('name') == 'test':
+ sys.exit(0)
+sys.exit(1)
+EOF
+ return $?
+}
+
+java-pkg-2_src_test() {
+ [[ -e "${EANT_BUILD_XML:=build.xml}" ]] || return
+
+ if [[ ${EANT_TEST_TARGET} ]] || java-pkg-2_supports-test ${EANT_BUILD_XML}; then
+ local opts task
+ if [[ ${EANT_TEST_JUNIT_INTO} ]]; then
+ java-pkg_jar-from --into "${EANT_TEST_JUNIT_INTO}" junit
+ fi
+ if [[ ${DEPEND} = *dev-java/ant-junit* ]]; then
+ ANT_TASKS=${ANT_TASKS:-ant-junit}
+ EANT_GENTOO_CLASSPATH=${EANT_GENTOO_CLASSPATH:-junit}
+ task=true
+ fi
+ if [[ ${task} ]] || [[ ${DEPEND} = *dev-java/junit* ]]; then
+ opts="-Djunit.jar=\"$(java-pkg_getjar --build-only junit junit.jar)\""
+ fi
+ eant ${opts} -f "${EANT_BUILD_XML}" \
+ ${EANT_TEST_EXTRA_ARGS} ${EANT_TEST_TARGET:-test}
+ fi
+}
+
# ------------------------------------------------------------------------------
# @eclass-end
# ------------------------------------------------------------------------------
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-02-13 21:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-13 21:36 [gentoo-java] Default src_test Petteri Räty
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox