Skip to content

Commit 5471270

Browse files
author
Erik Olsson
committedJul 5, 2011
Added ant target 'test-all' that runs tests over available libs (jquery/mootools/prototype)
1 parent 044e56b commit 5471270

12 files changed

+54303
-5
lines changed
 

‎build.xml

+81-2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959
<mkdir dir="${minify.dir}"/>
6060
<mkdir dir="${testoutput.dir}"/>
6161
<mkdir dir="${coveragereport.dir}"/>
62+
63+
<delete file="${basedir}/jsTestDriver.conf" failonerror="false"/>
64+
<delete file="${basedir}/jsTestDriverCoverage.conf" failonerror="false"/>
6265
</target>
6366

6467
<!-- Assembles the source parts into one file. -->
@@ -140,13 +143,83 @@
140143
<echo message="Exit the server by pressing Control-C in the java window."/>
141144
</target>
142145

146+
<target name="test-all" description="Runs the unit tests on all adapters. The server must be running (i.e. 'server').">
147+
<!-- Param "testrun.name" used in echo output and to build a folder name where test result goes. -->
148+
<!-- Param "required.lib" specifies wich third-party lib is used while testing. -->
149+
<!-- Param "required.adapter" specifies the corresponding adapter that matches the lib. Leave unset for the built-in jquery support. -->
150+
151+
<!-- jquery versions -->
152+
<antcall target="test-specific-lib">
153+
<param name="testrun.name" value="jquery-1.6.2"/>
154+
<param name="required.lib" value="jquery-1.6.2.js"/>
155+
</antcall>
156+
<antcall target="test-specific-lib">
157+
<param name="testrun.name" value="jquery-1.6.1"/>
158+
<param name="required.lib" value="jquery-1.6.1.js"/>
159+
</antcall>
160+
<antcall target="test-specific-lib">
161+
<param name="testrun.name" value="jquery-1.5.2"/>
162+
<param name="required.lib" value="jquery-1.5.2.js"/>
163+
</antcall>
164+
165+
<!-- mootools versions -->
166+
<antcall target="test-specific-lib">
167+
<param name="testrun.name" value="mootools-1.3.2"/>
168+
<param name="required.lib" value="mootools-core-1.3.2-full-compat.js"/>
169+
<param name="required.adapter" value="js/adapters/mootools-adapter.src.js"/>
170+
</antcall>
171+
172+
<!-- prototype versions -->
173+
<antcall target="test-specific-lib">
174+
<param name="testrun.name" value="prototype-1.7.0.0"/>
175+
<param name="required.lib" value="prototype-1.7.0.0.js"/>
176+
<param name="required.adapter" value="js/adapters/prototype-adapter.src.js"/>
177+
</antcall>
178+
</target>
179+
180+
<target name="test" description="Runs the unit tests latest jquery. The server must be running (i.e. 'server').">
181+
<antcall target="test-specific-lib">
182+
<param name="testrun.name" value="jquery-1.6.2"/>
183+
<param name="required.lib" value="jquery-1.6.2.js"/>
184+
</antcall>
185+
</target>
186+
187+
<!-- Replace the lib with the specified ones, if set. -->
188+
<target name="replace-lib" if="required.lib">
189+
<replace file="jsTestDriver.conf" token="#required.lib" value=" - lib/${required.lib}" summary="true"/>
190+
</target>
191+
192+
<!-- Replace the adapter with the specified ones, if set. -->
193+
<target name="replace-adapter" if="required.adapter">
194+
<replace file="jsTestDriver.conf" token="#required.adapter" value=" - ${required.adapter}" summary="true"/>
195+
</target>
196+
197+
<target name="test-specific-lib" depends="set.properties">
198+
<echo message="-----------------------------------------------"/>
199+
<echo message=" Running tests using: ${testrun.name}"/>
200+
<echo message="-----------------------------------------------"/>
201+
202+
<!-- Copy the templated jsTestDriver configuration to root. -->
203+
<copy file="test/jsTestDriver.conf" todir="${basedir}" overwrite="true"/>
204+
205+
<!-- Expand the tokens to valid js files. -->
206+
<antcall target="replace-lib"/>
207+
<antcall target="replace-adapter"/>
208+
209+
<!-- Create the folder where the report is stored. -->
210+
<mkdir dir="${testoutput.dir}/${testrun.name}"/>
211+
212+
<!-- Run the tests -->
213+
<antcall target="run-test"/>
214+
</target>
215+
143216
<!-- Runs the tests without coverage. This is much faster than with coverage enabled. -->
144-
<target name="test" depends="set.properties" description="Runs the unit tests. The server must be running (i.e. 'server').">
217+
<target name="run-test" depends="set.properties">
145218
<java jar="${jstestdriver.jar}" fork="true">
146219
<arg value="--config"/>
147220
<arg value="jsTestDriver.conf"/>
148221
<arg value="--testOutput"/>
149-
<arg value="${testoutput.dir}"/>
222+
<arg value="${testoutput.dir}/${testrun.name}"/>
150223
<arg value="--tests"/>
151224
<arg value="all"/>
152225
<arg value="--verbose"/>
@@ -157,6 +230,9 @@
157230
<!-- Starts the test driver server with coverage enabled. -->
158231
<!-- This must be done on a separate port to the test-server. -->
159232
<target name="server-coverage" depends="set.properties" description="Starts the unit test server with coverage enabled on localhost:5225.">
233+
<!-- Copy the jsTestDriverCoverage configuration to root. -->
234+
<copy file="test/jsTestDriverCoverage.conf" todir="${basedir}" overwrite="true"/>
235+
160236
<exec executable="cmd" dir="${basedir}" >
161237
<arg value="/k start java -jar ${jstestdriver.jar} --config jsTestDriverCoverage.conf --port 5225"/>
162238
</exec>
@@ -167,6 +243,9 @@
167243

168244
<!-- Runs coverage analysis for the tests. -->
169245
<target name="test-coverage" depends="set.properties" description="Runs the unit tests together with code coverage. The server must be running (i.e. 'server-coverage')">
246+
<!-- Copy the jsTestDriverCoverage configuration to root. -->
247+
<copy file="test/jsTestDriverCoverage.conf" todir="${basedir}" overwrite="true"/>
248+
170249
<!-- Run the tests with coverage enabled. -->
171250
<java jar="${jstestdriver.jar}" fork="true">
172251
<arg value="--config"/>

0 commit comments

Comments
 (0)