Configure testing for the Jython extension

This commit is contained in:
Antonin Delpeuch 2018-01-03 18:37:16 +01:00
parent bdf1c3eda7
commit 4a325c8ff5
7 changed files with 102 additions and 2 deletions

View File

@ -206,6 +206,10 @@
</jacoco:report> </jacoco:report>
</target> </target>
<target name="extensions_test" depends="build">
<ant dir="extensions/" target="test" />
</target>
<!-- ================================================================== --> <!-- ================================================================== -->
<target name="prepare_jar"> <target name="prepare_jar">

View File

@ -22,4 +22,9 @@
<ant dir="gdata/" target="clean" /> <ant dir="gdata/" target="clean" />
<ant dir="pc-axis/" target="clean" /> <ant dir="pc-axis/" target="clean" />
</target> </target>
<target name="test">
<echo message="Testing extensions" />
<ant dir="jython/" target="test" />
</target>
</project> </project>

View File

@ -6,7 +6,7 @@
| |
+--> +-->
<project name="refine-jython" default="build" basedir="."> <project name="refine-jython" default="build" basedir="." xmlns:jacoco="antlib:org.jacoco.ant">
<property environment="env"/> <property environment="env"/>
@ -27,12 +27,14 @@
</condition> </condition>
<property name="fullname" value="${name}-${version}-${revision}" /> <property name="fullname" value="${name}-${version}-${revision}" />
<property name="java_version" value="1.8"/>
<property name="refine.dir" value="${basedir}/../../main" /> <property name="refine.dir" value="${basedir}/../../main" />
<property name="refine.webinf.dir" value="${refine.dir}/webapp/WEB-INF" /> <property name="refine.webinf.dir" value="${refine.dir}/webapp/WEB-INF" />
<property name="refine.modinf.dir" value="${refine.dir}/webapp/modules/core/MOD-INF" /> <property name="refine.modinf.dir" value="${refine.dir}/webapp/modules/core/MOD-INF" />
<property name="refine.classes.dir" value="${refine.webinf.dir}/classes" /> <property name="refine.classes.dir" value="${refine.webinf.dir}/classes" />
<property name="refine.lib.dir" value="${refine.webinf.dir}/lib" /> <property name="refine.lib.dir" value="${refine.webinf.dir}/lib" />
<property name="refine.tests.lib.dir" value="${refine.dir}/tests/server/lib" />
<property name="src.dir" value="${basedir}/src" /> <property name="src.dir" value="${basedir}/src" />
<property name="module.dir" value="${basedir}/module" /> <property name="module.dir" value="${basedir}/module" />
@ -40,6 +42,14 @@
<property name="lib.dir" value="${modinf.dir}/lib" /> <property name="lib.dir" value="${modinf.dir}/lib" />
<property name="classes.dir" value="${modinf.dir}/classes" /> <property name="classes.dir" value="${modinf.dir}/classes" />
<property name="extension.tests.dir" value="${basedir}/tests" />
<property name="tests.build.dir" value="${extension.tests.dir}/build" />
<property name="tests.src.dir" value="${extension.tests.dir}/src" />
<property name="tests.classes.dir" value="${extension.tests.dir}/classes" />
<property name="tests.report.dir" value="${extension.tests.dir}/report"/>
<property name="tests.report.html.dir" value="${tests.report.dir}/html"/>
<property name="tests.report.xml.path" value="${tests.report.dir}/jacoco.xml"/>
<path id="class.path"> <path id="class.path">
<fileset dir="${lib.dir}"> <fileset dir="${lib.dir}">
<include name="**/*.jar" /> <include name="**/*.jar" />
@ -48,8 +58,24 @@
<include name="**/*.jar" /> <include name="**/*.jar" />
</fileset> </fileset>
<pathelement path="${refine.classes.dir}"/> <pathelement path="${refine.classes.dir}"/>
<pathelement path="${classes.dir}" />
</path> </path>
<path id="extension.tests.class.path">
<path refid="class.path"/>
<pathelement location="${tests.classes.dir}"/>
<pathelement location="${refine.tests.lib.dir}/testng-6.8.jar"/>
<fileset dir="${refine.tests.lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<taskdef resource="testngtasks" classpath="${refine.tests.lib.dir}/testng-6.8.jar"/>
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="${refine.tests.lib.dir}/jacocoant.jar"/>
</taskdef>
<target name="build_java"> <target name="build_java">
<mkdir dir="${classes.dir}" /> <mkdir dir="${classes.dir}" />
<javac source="${java_version}" target="${java_version}" encoding="utf-8" destdir="${classes.dir}" debug="true" includeAntRuntime="no"> <javac source="${java_version}" target="${java_version}" encoding="utf-8" destdir="${classes.dir}" debug="true" includeAntRuntime="no">
@ -60,7 +86,46 @@
<target name="build" depends="build_java"/> <target name="build" depends="build_java"/>
<target name="build_tests" depends="build">
<mkdir dir="${tests.classes.dir}" />
<javac source="${java_version}" target="${java_version}" encoding="utf-8" srcdir="${tests.src.dir}" destdir="${tests.classes.dir}" debug="true" includeAntRuntime="no">
<classpath refid="extension.tests.class.path" />
</javac>
<copy file="${tests.src.dir}/tests.log4j.properties" tofile="${tests.classes.dir}/tests.log4j.properties"/>
</target>
<mkdir dir="${tests.build.dir}" />
<target name="test" depends="build_tests">
<jacoco:coverage destfile="${tests.report.dir}/jacoco.exec">
<testng verbose="2" haltOnFailure="true" workingdir="${tests.build.dir}"
listener="org.testng.reporters.DotTestListener" excludedgroups="broken"
classpathref="extension.tests.class.path">
<xmlfileset file="${extension.tests.dir}/conf/tests.xml"/>
</testng>
</jacoco:coverage>
<jacoco:report>
<executiondata>
<file file="${tests.report.dir}/jacoco.exec"/>
</executiondata>
<structure name="Jython extension">
<classfiles>
<fileset dir="${classes.dir}"/>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="${src.dir}"/>
</sourcefiles>
</structure>
<html destdir="${tests.report.html.dir}"/>
<xml destfile="${tests.report.xml.path}"/>
</jacoco:report>
</target>
<target name="clean"> <target name="clean">
<delete dir="${classes.dir}" /> <delete dir="${classes.dir}" />
<delete dir="${tests.classes.dir}" />
<delete dir="${tests.report.dir}" />
<delete dir="${tests.build.dir}" />
</target> </target>
</project> </project>

View File

@ -0,0 +1,14 @@
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Jython extension">
<test name="tests">
<groups>
<run>
<exclude name="broken" />
</run>
</groups>
<packages>
<package name="com.google.refine.jython.*" />
</packages>
</test>
</suite>

View File

@ -0,0 +1,4 @@
log4j.rootLogger=ERROR, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=com.google.refine.logging.IndentingLayout

8
refine
View File

@ -66,6 +66,7 @@ and <action> is one of
test ................................ Run all OpenRefine tests test ................................ Run all OpenRefine tests
server_test ......................... Run only the server tests server_test ......................... Run only the server tests
ui_test ............................. Run only the UI tests ui_test ............................. Run only the UI tests
extensions_test ..................... Run only the extensions tests
broker .............................. Run OpenRefine Broker broker .............................. Run OpenRefine Broker
@ -591,6 +592,7 @@ mac_dist() {
test() { test() {
server_test $1 server_test $1
ui_test $1 ui_test $1
extensions_test $1
} }
ui_test() { ui_test() {
@ -635,6 +637,10 @@ server_test() {
ant server_test ant server_test
} }
extensions_test() {
ant extensions_test
}
run() { run() {
FORK=$1 FORK=$1
@ -1018,6 +1024,8 @@ case "$ACTION" in
ui_tests) ui_test $1;; ui_tests) ui_test $1;;
server_test) server_test $1;; server_test) server_test $1;;
server_tests) server_test $1;; server_tests) server_test $1;;
extensions_test) extensions_test $1;;
extensions_tests) extensions_test $1;;
findbugs) findbugs;; findbugs) findbugs;;
pmd) pmd;; pmd) pmd;;
cpd) cpd;; cpd) cpd;;