Changeset 30562 in osm


Ignore:
Timestamp:
2014-08-05T13:21:35+02:00 (10 years ago)
Author:
donvip
Message:

[josm_plugins] support for unit tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/build-common.xml

    r30561 r30562  
    9797        <antcall target="add-manifest-attribute">
    9898            <param name="manifest.attribute" value="Plugin-Link"/>
    99             <param name="propery.name" value="plugin.link"/>
    100             <param name="propery.value" value="${plugin.link}"/>
     99            <param name="property.name" value="plugin.link"/>
     100            <param name="property.value" value="${plugin.link}"/>
    101101        </antcall>
    102102        <antcall target="add-manifest-attribute">
    103103            <param name="manifest.attribute" value="Plugin-Icon"/>
    104             <param name="propery.name" value="plugin.icon"/>
    105             <param name="propery.value" value="${plugin.icon}"/>
     104            <param name="property.name" value="plugin.icon"/>
     105            <param name="property.value" value="${plugin.icon}"/>
    106106        </antcall>
    107107        <antcall target="add-manifest-attribute">
    108108            <param name="manifest.attribute" value="Plugin-Early"/>
    109             <param name="propery.name" value="plugin.early"/>
    110             <param name="propery.value" value="${plugin.early}"/>
     109            <param name="property.name" value="plugin.early"/>
     110            <param name="property.value" value="${plugin.early}"/>
    111111        </antcall>
    112112        <antcall target="add-manifest-attribute">
    113113            <param name="manifest.attribute" value="Plugin-Requires"/>
    114             <param name="propery.name" value="plugin.requires"/>
    115             <param name="propery.value" value="${plugin.requires}"/>
     114            <param name="property.name" value="plugin.requires"/>
     115            <param name="property.value" value="${plugin.requires}"/>
    116116        </antcall>
    117117        <antcall target="add-manifest-attribute">
    118118            <param name="manifest.attribute" value="Plugin-Stage"/>
    119             <param name="propery.name" value="plugin.stage"/>
    120             <param name="propery.value" value="${plugin.stage}"/>
     119            <param name="property.name" value="plugin.stage"/>
     120            <param name="property.value" value="${plugin.stage}"/>
    121121        </antcall>
    122122        <antcall target="additional-manifest" />
     
    130130        <!-- to be overidden by plugins that need to perform additional tasks on resulting jar -->
    131131    </target>
    132     <target name="add-manifest-attribute" depends="check-manifest-attribute" if="have-${propery.name}">
     132    <target name="add-manifest-attribute" depends="check-manifest-attribute" if="have-${property.name}">
    133133        <manifest file="MANIFEST" mode="update">
    134             <attribute name="${manifest.attribute}" value="${propery.value}" />
     134            <attribute name="${manifest.attribute}" value="${property.value}" />
    135135        </manifest>
    136136    </target>
     
    139139    </target>
    140140    <target name="check-manifest-attribute">
    141         <condition property="have-${propery.name}">
     141        <condition property="have-${property.name}">
    142142            <and>
    143                 <isset property="${propery.name}"/>
     143                <isset property="${property.name}"/>
    144144                <not>
    145                     <equals arg1="${propery.value}" arg2=""/>
     145                    <equals arg1="${property.value}" arg2=""/>
    146146                </not>
    147147                <not>
    148                     <equals arg1="${propery.value}" arg2="..."/>
     148                    <equals arg1="${property.value}" arg2="..."/>
    149149                </not>
    150150            </and>
     
    200200           </not>
    201201       </condition>
    202    </target>
     202    </target>
    203203    <!--
    204204      ** Initializes the REVISION.XML file from git (w/o svn) information.
     
    369369        <pathelement path="${groovy.jar}"/>
    370370    </path>
     371    <condition property="plugin.requires.jars.set">
     372        <isreference refid="plugin.requires.jars"/>
     373    </condition>
    371374    <macrodef name="init-test-preferences">
    372         <attribute name="testfamily"/>
    373375        <sequential>
    374             <copy file="${plugin.test.dir}/config/preferences.template.xml" tofile="${plugin.test.dir}/config/@{testfamily}-josm.home/preferences.xml"/>
    375             <replace file="${plugin.test.dir}/config/@{testfamily}-josm.home/preferences.xml" encoding="UTF-8" token="@OSM_USERNAME@" value="${osm.username}"/>
    376             <replace file="${plugin.test.dir}/config/@{testfamily}-josm.home/preferences.xml" encoding="UTF-8" token="@OSM_PASSWORD@" value="${osm.password}"/>
     376            <copy file="${plugin.test.dir}/config/preferences.template.xml" tofile="${plugin.test.dir}/config/unit-josm.home/preferences.xml"/>
     377            <replace file="${plugin.test.dir}/config/unit-josm.home/preferences.xml" encoding="UTF-8" token="@OSM_USERNAME@" value="${osm.username}"/>
     378            <replace file="${plugin.test.dir}/config/unit-josm.home/preferences.xml" encoding="UTF-8" token="@OSM_PASSWORD@" value="${osm.password}"/>
    377379        </sequential>
    378380    </macrodef>
     
    381383        <mkdir dir="${plugin.test.dir}/build/unit"/>
    382384        <mkdir dir="${plugin.test.dir}/report"/>
    383         <init-test-preferences testfamily="unit"/>
     385        <init-test-preferences/>
    384386    </target>
    385387    <target name="test-clean">
     
    391393    </target>
    392394    <macrodef name="call-groovyc">
    393         <attribute name="testfamily"/>
    394395        <element name="cp-elements"/>
    395396        <sequential>
    396             <groovyc srcdir="${plugin.test.dir}/@{testfamily}" destdir="${plugin.test.dir}/build/@{testfamily}" encoding="UTF-8">
     397            <groovyc srcdir="${plugin.test.dir}/unit" destdir="${plugin.test.dir}/build/unit" encoding="UTF-8">
    397398                <classpath>
    398399                    <cp-elements/>
     400                    <path refid="test.classpath"/>
    399401                </classpath>
    400                 <javac target="1.7" source="1.7" debug="on">
     402                <javac target="1.7" source="1.7" debug="on" encoding="UTF-8">
    401403                    <compilerarg value="-Xlint:all"/>
    402404                    <compilerarg value="-Xlint:-serial"/>
     
    405407        </sequential>
    406408    </macrodef>
     409    <target name="call-groovyc-extended" if="plugin.requires.jars.set">
     410        <call-groovyc>
     411            <cp-elements>
     412                <fileset refid="plugin.requires.jars"/>
     413            </cp-elements>
     414        </call-groovyc>
     415    </target>
     416    <target name="call-groovyc-base" unless="plugin.requires.jars.set">
     417        <call-groovyc>
     418            <cp-elements/>
     419        </call-groovyc>
     420    </target>
    407421    <target name="test-compile" depends="test-init,dist">
    408422        <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpath="${groovy.jar}"/>
    409         <call-groovyc testfamily="unit">
    410             <cp-elements>
    411                 <path refid="test.classpath"/>
    412             </cp-elements>
    413         </call-groovyc>
     423        <antcall target="call-groovyc-base"/>
     424        <antcall target="call-groovyc-extended"/>
    414425    </target>
    415426    <macrodef name="call-junit">
    416         <attribute name="testfamily"/>
     427        <element name="cp-elements"/>
    417428        <sequential>
    418             <echo message="Running @{testfamily} tests with JUnit"/>
     429            <echo message="Running unit tests with JUnit"/>
    419430            <jacoco:coverage destfile="${plugin.test.dir}/jacoco.exec">
    420431                <junit printsummary="yes" fork="true" forkmode="once" dir="${basedir}">
    421                     <sysproperty key="josm.home" value="${plugin.test.dir}/config/@{testfamily}-josm.home"/>
     432                    <jvmarg value="-Dfile.encoding=UTF-8"/>
     433                    <sysproperty key="josm.home" value="${plugin.test.dir}/config/unit-josm.home"/>
    422434                    <sysproperty key="josm.test.data" value="${plugin.test.dir}/data"/>
    423435                    <sysproperty key="java.awt.headless" value="true"/>
    424436                    <sysproperty key="suppressPermanentFailure" value="${suppressPermanentFailure}"/>
    425437                    <classpath>
     438                        <cp-elements/>
    426439                        <path refid="test.classpath"/>
    427440                        <pathelement path="${plugin.test.dir}/build/unit"/>
    428                         <pathelement path="${plugin.test.dir}/build/@{testfamily}"/>
    429                         <pathelement path="${plugin.test.dir}/config"/>
    430441                    </classpath>
    431442                    <formatter type="plain"/>
    432443                    <formatter type="xml"/>
    433444                    <batchtest fork="yes" todir="${plugin.test.dir}/report">
    434                         <fileset dir="${plugin.test.dir}/build/@{testfamily}" includes="**/*Test.class"/>
     445                        <fileset dir="${plugin.test.dir}/build/unit" includes="**/*Test.class"/>
    435446                    </batchtest>
    436447                </junit>
     
    438449        </sequential>
    439450    </macrodef>
    440     <target name="test" depends="test-compile"
     451    <target name="call-junit-extended" if="plugin.requires.jars.set">
     452        <call-junit>
     453            <cp-elements>
     454                <fileset refid="plugin.requires.jars"/>
     455            </cp-elements>
     456        </call-junit>
     457    </target>
     458    <target name="call-junit-base" unless="plugin.requires.jars.set">
     459        <call-junit>
     460            <cp-elements/>
     461        </call-junit>
     462    </target>
     463    <target name="test" depends="dist, test-compile"
    441464        description="Run unit tests. OSM API (TEST) account shall be set with -Dosm.username and -Dosm.password">
    442465        <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml" classpath="../00_core_tools/jacocoant.jar" />
    443         <call-junit testfamily="unit"/>
     466        <antcall target="call-junit-base"/>
     467        <antcall target="call-junit-extended"/>
    444468    </target>
    445469       
Note: See TracChangeset for help on using the changeset viewer.