mirror of
https://github.com/nicolabs/ciform.git
synced 2026-04-12 00:58:15 +02:00
+ JsUnit test integration to CruiseControl
This commit is contained in:
parent
753025c8bc
commit
26519bb0ac
|
|
@ -31,6 +31,7 @@ src.dir=${basedir}/src/main/javascript
|
|||
build.dir=${basedir}/build
|
||||
|
||||
tests.dir=${basedir}/src/test/javascript
|
||||
tests.logs=${build.dir}/logs
|
||||
|
||||
# Where the generated files are going
|
||||
target.dir=${basedir}/target
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
<ivy:retrieve/>
|
||||
<!-- Creates necessary directories -->
|
||||
<mkdir dir="${target.dir}" />
|
||||
<delete dir="${build.dir}"/>
|
||||
<mkdir dir="${build.dir}"/>
|
||||
</target>
|
||||
|
||||
<target name="compile" depends="validate" description="Compiles the source code of the project.">
|
||||
|
|
@ -37,26 +39,54 @@
|
|||
Firefox 3 users : change the security.fileuri.strict_origin_policy parameter to 'false' for the following target to work
|
||||
-->
|
||||
<target name="test" depends="compile" description="Tests the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed.">
|
||||
<!-- 0. First create a temp. dir inside the preferred temp. dir (yes...) -->
|
||||
<tempfile property="tests.tmp" destDir="${tmp.dir}"/>
|
||||
<mkdir dir="${tests.tmp}"/>
|
||||
<!-- 1. ... and copy all required files inside -->
|
||||
<copy file="${jsunit.core}" todir="${tests.tmp}"/>
|
||||
<copy file="${src.dir}/sha1.js" todir="${tests.tmp}"/>
|
||||
<copy file="${tests.dir}/AllTests.html" todir="${tests.tmp}"/>
|
||||
<!-- 2. Then call the JsUnit target against our unit tests -->
|
||||
<ant antfile="${jsunit.build}"
|
||||
dir="${jsunit.dir}"
|
||||
target="standalone_test">
|
||||
<!-- Look at http://jsunit.net and JsUnit's build.xml source for a definition of the following properties -->
|
||||
<property name="browserFileNames" value="${jsunit.browsers}"/>
|
||||
<property name="logsDirectory" value="${build.dir}"/> <!-- those logs will be used by CruiseControl -->
|
||||
<property name="port" value="45678"/> <!-- a port that's not likely to conflict with an existing daemon -->
|
||||
<property name="url" value="${jsunit.testrunner}?testPage=${tests.tmp}/AllTests.html"/>
|
||||
<!--property name="resourceBase" value="${tests.tmp}"/-->
|
||||
</ant>
|
||||
<!-- 3. Finally remove the temp. dir / files -->
|
||||
<delete dir="${tests.tmp}"/>
|
||||
<!-- 1. Copies all files required for the tests in a working directory -->
|
||||
<tempfile property="tests.tmp" prefix="test-" suffix=".tmp" destDir="${build.dir}"/>
|
||||
<copy file="${jsunit.core}" todir="${tests.tmp}"/> <!-- JsUnit's core library -->
|
||||
<copy file="${src.dir}/sha1.js" todir="${tests.tmp}"/> <!-- The library to test -->
|
||||
<copy file="${tests.dir}/AllTests.html" todir="${tests.tmp}"/> <!-- The unit tests -->
|
||||
<!-- 2. Calls the JsUnit target against our unit tests -->
|
||||
<mkdir dir="${tests.logs}"/>
|
||||
<junit showoutput="true"
|
||||
fork="true"
|
||||
errorproperty="jsunit.error"
|
||||
failureproperty="jsunit.failed"
|
||||
printsummary="on"
|
||||
dir="${tests.tmp}">
|
||||
<classpath>
|
||||
<fileset dir="${jsunit.dir}/java/lib">
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
<fileset dir="${jsunit.dir}/java/bin">
|
||||
<include name="jsunit.jar"/>
|
||||
</fileset>
|
||||
<dirset dir="${jsunit.dir}/java/config"/>
|
||||
</classpath>
|
||||
<formatter type="xml"/>
|
||||
<sysproperty key="browserFileNames" value="${jsunit.browsers}"/>
|
||||
<!--sysproperty key="logsDirectory" value="${tests.tmp}/logs"/-->
|
||||
<sysproperty key="port" value="45678"/>
|
||||
<sysproperty key="url" value="${jsunit.testrunner}?testPage=${tests.tmp}/AllTests.html"/>
|
||||
<test name="net.jsunit.StandaloneTest" todir="${tests.logs}">
|
||||
</test>
|
||||
</junit>
|
||||
<!-- 2.b Transforms test results into a CruiseControl understandable format -->
|
||||
<!--
|
||||
<xslt style="jsunit2cc-1.xsl"
|
||||
basedir="${tests.tmp}/logs"
|
||||
destdir="/opt/CruiseControl/logs/crypto-sha1/"
|
||||
extension="xml">
|
||||
</xslt>
|
||||
-->
|
||||
<!-- Fails if a test failed -->
|
||||
<delete dir="${tests.tmp}"/> <!-- removes the temp. dir / files -->
|
||||
<fail message="An error or a failure occured during the automated tests.">
|
||||
<condition>
|
||||
<or>
|
||||
<isset property="jsunit.failed"/>
|
||||
<isset property="jsunit.error"/>
|
||||
</or>
|
||||
</condition>
|
||||
</fail>
|
||||
</target>
|
||||
|
||||
<target name="package" depends="test, doc, compile, build-compressed" description="Takes the compiled code and package it in its distributable format, such as a JAR.">
|
||||
|
|
|
|||
Loading…
Reference in a new issue