Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

…a build.properties. Also added option to set the phpunit xml configuration file.
  • Loading branch information...
commit 4585c8fa2bd6ff4f9e7a85fb4fcbf95754b2632d 1 parent 724ae31
beberlei authored
Showing with 31 additions and 13 deletions.
  1. +3 −1 build.properties.dev
  2. +13 −11 build.xml
  3. +15 −1 tools/NativePhpunitTask.php
View
4 build.properties.dev
@@ -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
24 build.xml
@@ -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
16 tools/NativePhpunitTask.php
@@ -44,14 +44,26 @@ public function setTestfile($testfile) {
}
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 @@ public function main()
$printer = new NativePhpunitPrinter();
$arguments = array(
- 'configuration' => $this->configurationFile,
+ 'configuration' => $this->configuration,
'coverageClover' => $this->coverageClover,
'junitLogfile' => $this->junitlogfile,
'printer' => $printer,
@@ -114,7 +126,9 @@ public function main()
$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);
Please sign in to comment.
Something went wrong with that request. Please try again.