| 1 | <?xml version="1.0" encoding="UTF-8"?>
|
|---|
| 2 | <project basedir="." default="build" name="build example">
|
|---|
| 3 | <property name="srcDir" value="/var/www/htdocs" />
|
|---|
| 4 | <property name="unittestFailed" value="true" />
|
|---|
| 5 |
|
|---|
| 6 | <echo msg="Unittest failureproperty is initialized through PropertyTask as '${unittestFailed}'" />
|
|---|
| 7 | <echo msg="IfTask with arg2=1 on that property will pass regardless of actual success of Unittests, leading to 'failed' message." />
|
|---|
| 8 |
|
|---|
| 9 | <target name="test" depends="">
|
|---|
| 10 | <phpunit printsummary="true" failureproperty="unittestFailed">
|
|---|
| 11 | <batchtest>
|
|---|
| 12 | <fileset dir="${srcDir}">
|
|---|
| 13 | <include name="**/*.php"/>
|
|---|
| 14 | </fileset>
|
|---|
| 15 | </batchtest>
|
|---|
| 16 | </phpunit>
|
|---|
| 17 | </target>
|
|---|
| 18 |
|
|---|
| 19 | <target name="build" depends="test">
|
|---|
| 20 | <if>
|
|---|
| 21 | <equals arg1="${unittestFailed}" arg2="1" />
|
|---|
| 22 | <then>
|
|---|
| 23 | <echo msg="Unittests have failed." />
|
|---|
| 24 | </then>
|
|---|
| 25 | <else>
|
|---|
| 26 | <echo msg="Unittests passed." />
|
|---|
| 27 | </else>
|
|---|
| 28 | </if>
|
|---|
| 29 | </target>
|
|---|
| 30 | </project> |
|---|