Commit 4585c8fa authored by beberlei's avatar beberlei

[2.0] Refactoring of build.xml to generate coverage xml optionally via...

[2.0] Refactoring of build.xml to generate coverage xml optionally via build.properties. Also added option to set the phpunit xml configuration file.
parent 724ae317
...@@ -6,3 +6,5 @@ dist.dir=dist ...@@ -6,3 +6,5 @@ dist.dir=dist
report.dir=reports report.dir=reports
log.archive.dir=logs log.archive.dir=logs
svn.path=/usr/bin/svn svn.path=/usr/bin/svn
test.phpunit_configuration_file=
test.phpunit_generate_coverage=0
\ No newline at end of file
...@@ -63,6 +63,9 @@ ...@@ -63,6 +63,9 @@
</fileset> </fileset>
<target name="clean"> <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="${build.dir}" includeemptydirs="true" />
<delete dir="${dist.dir}" includeemptydirs="true" /> <delete dir="${dist.dir}" includeemptydirs="true" />
<delete dir="${report.dir}" includeemptydirs="true" /> <delete dir="${report.dir}" includeemptydirs="true" />
...@@ -122,19 +125,18 @@ ...@@ -122,19 +125,18 @@
Runs the full test suite. Runs the full test suite.
--> -->
<target name="test" depends="prepare"> <target name="test" depends="prepare">
<!--<phpunit printsummary="true" haltonfailure="true" haltonskipped="false" haltonincomplete="false" haltonerror="true"> <if><equals arg1="${test.phpunit_generate_coverage}" arg2="1" />
<formatter todir="${build.dir}/logs" type="xml"/> <then>
<batchtest classpath="tests"> <property name="test.phpunit_coverage_file" value="${build.dir}/logs/clover.xml" />
<fileset dir="tests"> </then>
<include name="**/*Test.php" /> <else>
<exclude name="**/*Performance*.php" /> <property name="test.phpunit_coverage_file" value="false" />
</fileset> </else>
</batchtest> </if>
</phpunit>
-->
<nativephpunit <nativephpunit
testfile="./tests/Doctrine/Tests/AllTests.php" junitlogfile="${build.dir}/logs/testsuites.xml" 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" /> <phpunitreport infile="${build.dir}/logs/testsuites.xml" format="frames" todir="${report.dir}/tests" />
......
...@@ -44,14 +44,26 @@ class NativePhpunitTask extends Task ...@@ -44,14 +44,26 @@ class NativePhpunitTask extends Task
} }
public function setJunitlogfile($junitlogfile) { public function setJunitlogfile($junitlogfile) {
if (strlen($junitlogfile) == 0) {
$junitlogfile = NULL;
}
$this->junitlogfile = $junitlogfile; $this->junitlogfile = $junitlogfile;
} }
public function setConfiguration($configuration) { public function setConfiguration($configuration) {
if (strlen($configuration) == 0) {
$configuration = NULL;
}
$this->configuration = $configuration; $this->configuration = $configuration;
} }
public function setCoverageClover($coverageClover) { public function setCoverageClover($coverageClover) {
if (strlen($coverageClover) == 0) {
$coverageClover = NULL;
}
$this->coverageClover = $coverageClover; $this->coverageClover = $coverageClover;
} }
...@@ -92,7 +104,7 @@ class NativePhpunitTask extends Task ...@@ -92,7 +104,7 @@ class NativePhpunitTask extends Task
$printer = new NativePhpunitPrinter(); $printer = new NativePhpunitPrinter();
$arguments = array( $arguments = array(
'configuration' => $this->configurationFile, 'configuration' => $this->configuration,
'coverageClover' => $this->coverageClover, 'coverageClover' => $this->coverageClover,
'junitLogfile' => $this->junitlogfile, 'junitLogfile' => $this->junitlogfile,
'printer' => $printer, 'printer' => $printer,
...@@ -114,7 +126,9 @@ class NativePhpunitTask extends Task ...@@ -114,7 +126,9 @@ class NativePhpunitTask extends Task
$this->log("PHPUnit Success: ".count($result->passed())." tests passed, no ". $this->log("PHPUnit Success: ".count($result->passed())." tests passed, no ".
"failures (".$result->skippedCount()." skipped, ".$result->notImplementedCount()." not implemented)"); "failures (".$result->skippedCount()." skipped, ".$result->notImplementedCount()." not implemented)");
// Hudson for example doesn't like the backslash in class names
if (file_exists($this->coverageClover)) { if (file_exists($this->coverageClover)) {
$this->log("Generated Clover Coverage XML to: ".$this->coverageClover);
$content = file_get_contents($this->coverageClover); $content = file_get_contents($this->coverageClover);
$content = str_replace("\\", ".", $content); $content = str_replace("\\", ".", $content);
file_put_contents($this->coverageClover, $content); file_put_contents($this->coverageClover, $content);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment