Created
January 18, 2010 20:56
-
-
Save davemo/280368 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<target name="coverage" depends="clean, copy-coverage-so, copy-index-yaml-static"> | |
<tempfile property="coverage.outfile" destDir="/tmp" /> | |
<!-- Temporarily turns off the USE_I18N in settings.py, re-enabled when coverage has completed --> | |
<replace file="${srcdir}/settings.py" token="USE_I18N = False" value="USE_I18N = True" /> | |
<!-- see comments in "test" target --> | |
<exec dir="${srcdir}" executable="python" failonerror="false" resultproperty="coverage.retcode" output="${coverage.outfile}" logError="true"> | |
<env key="UNITTESTS" value="${tests}" /> | |
<env key="PYTHONPATH" value="${test.pythonpath}"/> | |
<arg line="manage.py test ${project} --verbosity=2" /> | |
</exec> | |
<!-- echo for teamcity to grep out tags --> | |
<exec executable="cat"> | |
<arg line="${coverage.outfile}" /> | |
</exec> | |
<!-- make sure the output is as expected --> | |
<exec executable="cat" outputproperty="coverage.output"> | |
<arg line="${coverage.outfile}" /> | |
</exec> | |
<!-- ${coverage.expected} --> | |
<propertyregex property="coverage.match" input="${coverage.output}" regexp="(?m).*(teamcity\[buildStatisticValue value='(.*)\.(.*)' key='coverage'\]).*" select="\2" /> | |
<exec executable="bash" failonerror="false" resultproperty="coverage.test"> | |
<arg line="-c" /> | |
<arg line=""test ${coverage.match} -ge ${coverage.target}"" /> | |
</exec> | |
<if> | |
<equals arg1="${coverage.test}" arg2="0" /> | |
<then> | |
<property name="coverage.result" value="" /> | |
</then> | |
</if> | |
<fail message="Coverage is at ${coverage.match}, required level is ${coverage.target}." unless="coverage.result"/> | |
<!-- now check the return code for a coverage regression (exit_code=42)--> | |
<if> | |
<equals arg1="${coverage.retcode}" arg2="42" /> | |
<then> | |
<property name="coverage.regression" value="" /> | |
</then> | |
</if> | |
<fail message="At least one module has regressed in code coverage" if="coverage.regression"/> | |
</target> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment