cross platform unit test hostname faking not relying

on external tools

The original method failed on Archlinux. This should work everywhere.
This commit is contained in:
kytv
2013-01-03 22:58:21 +00:00
parent d28184ce72
commit 8e5c26270e
2 changed files with 20 additions and 12 deletions

View File

@ -192,12 +192,14 @@
<reporter type="stdout" />
<reporter type="junitxml" directory="../../reports/core/scalatest/" />
</scalatest>
<!-- fetch the real hostname of this machine -->
<exec executable="hostname" outputproperty="host.name"/>
<!-- set if unset -->
<property name="host.fakename" value="i2ptester" />
<!-- replace hostname that junit inserts into reports with fake one -->
<replace dir="../../reports/core/scalatest/" token="${host.name}" value="${host.fakename}"/>
<replaceregexp byline="true"
match="(hostname=)&quot;[^&quot;]+&quot;"
replace="\1&quot;${host.fakename}&quot;">
<fileset dir="../../reports/core/scalatest/" />
</replaceregexp>
</target>
<target name="junit.test" depends="clean, junit.compileTest, prepareTest">
<property name="hamcrest.home" value="${ant.home}/lib/" />
@ -239,12 +241,14 @@
</batchtest>
<formatter type="xml"/>
</junit>
<!-- fetch the real hostname of this machine -->
<exec executable="hostname" outputproperty="host.name"/>
<!-- set if unset -->
<property name="host.fakename" value="i2ptester" />
<!-- replace hostname that junit inserts into reports with fake one -->
<replace dir="../../reports/core/junit/" token="${host.name}" value="${host.fakename}"/>
<replaceregexp byline="true"
match="(hostname=)&quot;[^&quot;]+&quot;"
replace="\1&quot;${host.fakename}&quot;">
<fileset dir="../../reports/core/junit/" />
</replaceregexp>
</target>
<target name="test" depends="junit.test, scalatest.test"/>
<!-- test reports -->

View File

@ -204,12 +204,14 @@
<reporter type="stdout" />
<reporter type="junitxml" directory="../../reports/router/scalatest/" />
</scalatest>
<!-- fetch the real hostname of this machine -->
<exec executable="hostname" outputproperty="host.name"/>
<!-- set if unset -->
<property name="host.fakename" value="i2ptester" />
<!-- replace hostname that junit inserts into reports with fake one -->
<replace dir="../../reports/router/scalatest/" token="${host.name}" value="${host.fakename}"/>
<replaceregexp byline="true"
match="(hostname=)&quot;[^&quot;]+&quot;"
replace="\1&quot;${host.fakename}&quot;">
<fileset dir="../../reports/router/scalatest/" />
</replaceregexp>
</target>
<target name="junit.test" depends="clean, junit.compileTest, prepareTest">
<mkdir dir="../../reports/router/junit/" />
@ -240,12 +242,14 @@
</batchtest>
<formatter type="xml"/>
</junit>
<!-- fetch the real hostname of this machine -->
<exec executable="hostname" outputproperty="host.name"/>
<!-- set if unset -->
<property name="host.fakename" value="i2ptester" />
<!-- replace hostname that junit inserts into reports with fake one -->
<replace dir="../../reports/router/junit/" token="${host.name}" value="${host.fakename}"/>
<replaceregexp byline="true"
match="(hostname=)&quot;[^&quot;]+&quot;"
replace="\1&quot;${host.fakename}&quot;">
<fileset dir="../../reports/router/junit/" />
</replaceregexp>
</target>
<target name="test" depends="junit.test"/>
<!-- test reports -->