Make the build fail if the count of passed tests is fewer than expected
http://java.net/jira/browse/JAVASERVERFACES-1990
SECTION: Modified Files
----------------------------
M build.xml
SECTION: Diffs
----------------------------
Index: build.xml
===================================================================
--- build.xml (revision 8920)
+++ build.xml (working copy)
@@ -230,8 +230,38 @@
<ant dir="jsf-ri" antfile="build.xml" target="generate.reports"/>
</target>
+ <target name="assert.expected.passed.test.count"
+ depends="generate.reports">
+ <if>
+ <isset property="expected.passed.test.count" />
+ <then>
+<echo>perform the assertion</echo>
+ <sequential>
+ <property name="test.report.dir"
+ value="${impl.dir}/build/test-reports" />
+ <loadfile property="report.summary"
+ srcFile="${test.report.dir}/html/overview-summary.html" />
+ <propertyregex property="actual.passed.test.count"
+ input="${report.summary}"
+ regexp="(?s)(.*)(href=.all-tests.html.>)([0-9]{1,6})(.*)"
+ select="\3"
+ />
+ <math result="passed.test.count.difference" datatype="int"
+ operation="subtract"
+ operand1="${actual.passed.test.count}"
+ operand2="${expected.passed.test.count}" />
+ <propertyregex property="actual.lessthan.expected"
+ input="${passed.test.count.difference}"
+ regexp="^-.*"
+ replace="actual.lessthan.expected" />
+ <fail if="actual.lessthan.expected" status="-1"
+ message="
+--JOB FAILED!-- Fewer than expected tests passed. Expected: ${expected.passed.test.count} Actual: ${actual.passed.test.count}"/>
+ </sequential>
+ </then>
+ </if>
+ </target>
-
<target name="build.and.debug" depends="clean, main"
description="Clean, build, and deploy, restarting in debug mode">
<trycatch>
--
| edward.burns_at_oracle.com | office: +1 407 458 0017
| homepage: | http://ridingthecrest.com/