1
0
mirror of synced 2024-12-05 03:06:05 +03:00

[2.0] Refactoring of build.xml to generate coverage xml optionally via build.properties. Also added option to set the phpunit xml configuration file.

This commit is contained in:
beberlei 2010-02-07 09:31:32 +00:00
parent 724ae3172e
commit 4585c8fa2b
3 changed files with 31 additions and 13 deletions

View File

@ -5,4 +5,6 @@ build.dir=build
dist.dir=dist
report.dir=reports
log.archive.dir=logs
svn.path=/usr/bin/svn
svn.path=/usr/bin/svn
test.phpunit_configuration_file=
test.phpunit_generate_coverage=0

View File

@ -63,6 +63,9 @@
</fileset>
<target name="clean">
<available file="./build.properties" property="build_properties_exist" value="true"/>
<fail unless="build_properties_exist" message="The build.properties file is missing." />
<delete dir="${build.dir}" includeemptydirs="true" />
<delete dir="${dist.dir}" includeemptydirs="true" />
<delete dir="${report.dir}" includeemptydirs="true" />
@ -122,19 +125,18 @@
Runs the full test suite.
-->
<target name="test" depends="prepare">
<!--<phpunit printsummary="true" haltonfailure="true" haltonskipped="false" haltonincomplete="false" haltonerror="true">
<formatter todir="${build.dir}/logs" type="xml"/>
<batchtest classpath="tests">
<fileset dir="tests">
<include name="**/*Test.php" />
<exclude name="**/*Performance*.php" />
</fileset>
</batchtest>
</phpunit>
-->
<if><equals arg1="${test.phpunit_generate_coverage}" arg2="1" />
<then>
<property name="test.phpunit_coverage_file" value="${build.dir}/logs/clover.xml" />
</then>
<else>
<property name="test.phpunit_coverage_file" value="false" />
</else>
</if>
<nativephpunit
testfile="./tests/Doctrine/Tests/AllTests.php" junitlogfile="${build.dir}/logs/testsuites.xml"
testdirectory="./tests" coverageclover="${build.dir}/logs/clover.xml"
testdirectory="./tests" coverageclover="${test.phpunit_coverage_file}" configuration="${test.phpunit_configuration_file}"
/>
<phpunitreport infile="${build.dir}/logs/testsuites.xml" format="frames" todir="${report.dir}/tests" />

View File

@ -44,14 +44,26 @@ class NativePhpunitTask extends Task
}
public function setJunitlogfile($junitlogfile) {
if (strlen($junitlogfile) == 0) {
$junitlogfile = NULL;
}
$this->junitlogfile = $junitlogfile;
}
public function setConfiguration($configuration) {
if (strlen($configuration) == 0) {
$configuration = NULL;
}
$this->configuration = $configuration;
}
public function setCoverageClover($coverageClover) {
if (strlen($coverageClover) == 0) {
$coverageClover = NULL;
}
$this->coverageClover = $coverageClover;
}
@ -92,7 +104,7 @@ class NativePhpunitTask extends Task
$printer = new NativePhpunitPrinter();
$arguments = array(
'configuration' => $this->configurationFile,
'configuration' => $this->configuration,
'coverageClover' => $this->coverageClover,
'junitLogfile' => $this->junitlogfile,
'printer' => $printer,
@ -114,7 +126,9 @@ class NativePhpunitTask extends Task
$this->log("PHPUnit Success: ".count($result->passed())." tests passed, no ".
"failures (".$result->skippedCount()." skipped, ".$result->notImplementedCount()." not implemented)");
// Hudson for example doesn't like the backslash in class names
if (file_exists($this->coverageClover)) {
$this->log("Generated Clover Coverage XML to: ".$this->coverageClover);
$content = file_get_contents($this->coverageClover);
$content = str_replace("\\", ".", $content);
file_put_contents($this->coverageClover, $content);