Ticket #16601: v1-0001-test-targets-add-hardfail-variants-which-will-abo.patch

File v1-0001-test-targets-add-hardfail-variants-which-will-abo.patch, 3.9 KB (added by ris, 8 years ago)
  • build.xml

    From 2758c5af6bdc5b58e4769106ceb15c6561475537 Mon Sep 17 00:00:00 2001
    From: Robert Scott <code@humanleg.org.uk>
    Date: Sun, 29 Jul 2018 21:41:20 +0100
    Subject: [PATCH v1 1/2] test targets: add "-hardfail" variants which will
     abort with an error code on failure
    
    intended for use when specifying targets from top level rather than as a
    dependency. also add a test-unit mode which will only run unit tests.
    ---
     build.xml | 32 +++++++++++++++++++++++++++++++-
     1 file changed, 31 insertions(+), 1 deletion(-)
    
    diff --git a/build.xml b/build.xml
    index c732880e8..55989d359 100644
    a b Build-Date: ${build.tstamp}  
    505505            <echo message="Running @{testfamily}@{testITsuffix} tests with JUnit"/>
    506506            <jacoco:coverage destfile="${test.dir}/jacoco@{testITsuffix}.exec" enabled="@{coverage}" includes="${jacoco.includes}"
    507507                inclbootstrapclasses="${jacoco.inclbootstrapclasses}" inclnolocationclasses="${jacoco.inclnolocationclasses}">
    508                 <junit printsummary="yes" fork="true" forkmode="once">
     508                <junit printsummary="yes" fork="true" forkmode="once" failureproperty="test.@{testfamily}@{testITsuffix}.failed">
    509509                    <jvmarg value="-Dfile.encoding=UTF-8"/>
    510510                    <jvmarg value="-javaagent:${test.dir}/lib/jmockit-1.41.jar"/>
    511511                    <jvmarg value="--add-modules" if:set="isJava9" unless:set="isJava11" />
    Build-Date: ${build.tstamp}  
    557557        <call-junit testfamily="unit"/>
    558558        <call-junit testfamily="functional"/>
    559559    </target>
     560    <target name="test-hardfail" depends="test" description="Run 'test' target but abort if tests failed">
     561        <fail message="'test' failed">
     562            <condition>
     563                <or>
     564                    <isset property="test.unit.failed"/>
     565                    <isset property="test.functional.failed"/>
     566                </or>
     567            </condition>
     568        </fail>
     569    </target>
     570    <target name="test-unit" depends="test-compile" unless="test-unit.notRequired"
     571        description="Run unit tests. OSM API (TEST) account shall be set with -Dosm.username and -Dosm.password">
     572        <call-junit testfamily="unit"/>
     573    </target>
     574    <target name="test-unit-hardfail" depends="test-unit" description="Run 'test-unit' target but abort if tests failed">
     575        <fail message="'test-unit' failed" if="test.unit.failed"/>
     576    </target>
    560577    <target name="test-it" depends="test-compile" unless="test-it.notRequired"
    561578        description="Run integration tests. OSM API (TEST) account shall be set with -Dosm.username and -Dosm.password">
    562579        <call-junit testfamily="unit" testITsuffix="IT"/>
    563580        <call-junit testfamily="functional" testITsuffix="IT"/>
    564581    </target>
     582    <target name="test-it-hardfail" depends="test-it" description="Run 'test-it' target but abort if tests failed">
     583        <fail message="'test-it' failed">
     584            <condition>
     585                <or>
     586                    <isset property="test.unitIT.failed"/>
     587                    <isset property="test.functionalIT.failed"/>
     588                </or>
     589            </condition>
     590        </fail>
     591    </target>
    565592    <target name="test-perf" depends="test-compile" unless="test-perf.notRequired"
    566593        description="Run performance tests. OSM API (TEST) account shall be set with -Dosm.username and -Dosm.password">
    567594        <call-junit testfamily="performance" coverage="false"/>
    568595    </target>
     596    <target name="test-perf-hardfail" depends="test-perf" description="Run 'test-perf' target but abort if tests failed">
     597        <fail message="'test-perf' failed" if="test.performance.failed"/>
     598    </target>
    569599    <target name="test-html" depends="test, test-it, test-perf" description="Generate HTML test reports">
    570600        <!-- May require additional ant dependencies like ant-trax package -->
    571601        <junitreport todir="${test.dir}/report">