• Views
  • Iteration Report
  • My Iteration Report
  •  
OMERO.clients
  • Login
  • Help/Guide
  • About Trac
  • Preferences
  • Wiki
  • Timeline
  • Roadmap
  • Browse Source
  • View Tickets
  • Search

Context Navigation

  • Last Change
  • Annotate
  • Revision Log

root/tags/OMERO.insight_3_Beta1/build/test.xml

Revision 4729, 16.2 kB (checked in by jburel, 23 months ago)

replaced OMEROClient by OMERO.insight

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2
3<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 * Child build file to test the application.
5 * This file is only meant to be used as an imported file within the
6 * OMERO.insight master build file.
7~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
8<project name="test" default="usage">
9
10  <!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11   * Fail at import time if the external properties this child depends upon
12   * have not been defined.
13  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--> 
14  <checkdef prop="build.dir" /> 
15  <checkdef prop="base.test.dir" />
16  <checkdef prop="base.test.lib.dir" />
17  <!--
18    NOTE: The last dependency is app.run.classpath, which is a path ref.
19    This can only be checked after the path elements have been created,
20    which happens when the app-init target is invoked.  So we're forced
21    to defer this check until the compile target has been executed.
22  -->
23 
24  <!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25   * Settings to compile and run the tests:
26   *   + test.dir: The destination dir where we compile and run the tests.
27   *   + test.compiled.dir: The sub-dir of ${test.dir} in which we store all
28   *           the compiled test classes and resources.
29   *   + test.lib.dir: The sub-dir of ${test.dir} in which we store all the
30   *           additional library files required for the tests to compile and
31   *           run.
32   *   + test.reports.dir: The sub-dir of ${test.dir} where the results of
33   *           the latest tests run are collected.
34   *   + test.reports.xml.dir: The sub-dir of ${test.reports.dir} which
35   *           contains the results of the latest tests run in xml format.
36   *   + test.reports.html.dir: The sub-dir of ${test.reports.dir} which
37   *           contains the results of the latest tests run in html format.
38   *   + test.sources: All test files to compile.  Currently these are
39   *           all the .java files within ${base.test.dir}.
40   *   + test.suite: All test case files that make up the test suite.
41   *           These are all .java files under ${base.test.dir} that start with
42   *           'Test', with the exclsion of the contents of the env.data.t
43   *           package and its sub-packages.  (Which contain Data Services test
44   *           cases that require a live connection to OMERO to run.)
45   *           It is possible to modify all this by changing the values of the
46   *           test.suite.include and test.suite.exclude properties, which
47   *           specifies what files end up in the test.suite.
48   *   + test.suite.include: Specifies the include pattern to use with the
49   *           test.suite property.   This property comes very handy when you
50   *           want to run a single test or, in general, a subset of all the
51   *           available tests.  Combined with Ant's ability to override
52   *           properties from the command line, it lets you fine-tune a test
53   *           run.  For example: 
54   *             ant -Dtest.suite.include=**/shoola/env/**/Test*.java test 
55   *           runs all the tests in the evn package and its sub-packages, as 
56   *             ant -Dtestset=**/shoola/env/ui/TestTaskBarStartup.java 
57   *           runs just TestTaskBarStartup.
58   *           (Note that you can also use the -propertyfile switch to load
59   *           properties from a file; please refer to the Ant docs.)
60   *   + test.suite.exclude: Specifies the exclude pattern to use with the
61   *           test.suite property.   This property comes very handy when you
62   *           want to avoid running a single test or, in general, a subset of
63   *           all the available tests.  Combined with Ant's ability to override
64   *           properties from the command line, it lets you fine-tune a test
65   *           run.  For example: 
66   *             ant -Dtest.suite.exclude=**/shoola/util/**/* test
67   *           excludes all tests in the shoola.util package and all its
68   *           sub-packages.
69   *           (Note that you can also use the -propertyfile switch to load
70   *           properties from a file; please refer to the Ant docs.)
71   *   + test.libs: All libraries required by the tests.  Currently all jar
72   *           files within ${base.test.lib.dir}.  Note that jar files in
73   *           sub-dirs are not included.
74   *   + test.resources: All other resources needed by the tests.  We
75   *           consider a resource any non-java file in ${base.test.dir}. 
76   *           Obviously CVS dirs and files are excluded.
77   *   + test.compile.classpath: The classpath used to compile the tests.
78   *           Set to include all libraries required by the app, the app
79   *           compiled classes, and finally all libraries required for
80   *           testing.
81   *   + test.classpath: The classpath used to run the test.  Set to
82   *           include the test compile-classpath as well as all compiled
83   *           test classes.
84   *   + test.ds.suite: All test case files that make up the Data Services test
85   *           suite.  These are all .java files under ${base.test.dir} that
86   *           start with 'Test' and belong in the env.data.t package or any of
87   *           its sub-packages.  These tests are run separately from the
88   *           main test suite because require a live connection to OMERO and
89   *           need to be run in the same JVM.  (So that the connection may be
90   *           recycled across tests.)
91   *   + test.ds.url: The URL to use in the Data Services tests to connect to
92   *           OMERO.  Should be set through the -D or -propertyfile option of
93   *           the Ant command line. 
94   *   + test.ds.user: The user name to use in the Data Services tests to
95   *           connect to OMERO.  Should be set through the -D or -propertyfile
96   *           option of the Ant command line.
97   *   + test.ds.pass: The password to use in the Data Services tests to
98   *           connect to OMERO.  Should be set through the -D or -propertyfile
99   *           option of the Ant command line.
100   *
101   *   NOTE: For further information about running Data Services test that
102   *         require a live connection to OMERO, you should refer to the
103   *         docs accompanying:
104   *            org.openmicroscopy.shoola.env.data.DataServicesTestCase
105  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--> 
106  <property name="test.dir" location="${build.dir}/test" />
107  <property name="test.compiled.dir" location="${test.dir}/compiled" /> 
108  <property name="test.lib.dir" location="${test.dir}/lib" />
109  <property name="test.reports.dir" location="${test.dir}/reports" />
110  <property name="test.reports.xml.dir" location="${test.reports.dir}/xml" />
111  <property name="test.reports.html.dir" location="${test.reports.dir}/html" /> 
112  <patternset id="test.sources">
113    <include name="**/*.java" />
114  </patternset> 
115  <property name="test.suite.include" value="**/Test*.java" /> 
116  <property name="test.suite.exclude" value="**/env/data/t/**/*" /> 
117  <fileset id="test.suite" dir="${base.test.dir}"> 
118    <include name="${test.suite.include}" />
119    <exclude name="${test.suite.exclude}" /> 
120  </fileset> 
121  <fileset id="test.libs" dir="${base.test.lib.dir}" includes="*.jar" />
122  <fileset id="test.resources" dir="${base.test.dir}">
123    <exclude name="**/*.java" />
124  </fileset>
125  <path id="test.compile.classpath">
126    <path refid="app.run.classpath" /> 
127    <fileset dir="${test.lib.dir}" includes="*.jar" /> 
128  </path> 
129  <path id="test.classpath">
130    <path refid="test.compile.classpath" />
131    <pathelement location="${test.compiled.dir}" />
132  </path>
133  <fileset id="test.ds.suite" dir="${base.test.dir}"> 
134      <include name="**/env/data/t/**/Test*.java" />
135  </fileset> 
136  <property name="test.ds.url" value="http://testhost/shoola/" /> 
137  <property name="test.ds.user" value="test-user" /> 
138  <property name="test.ds.pass" value="test-pass" /> 
139 
140 
141 
142  <!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
143   * Verify integrity of ${base.test.dir}, create and set up ${test.dir}.
144   * A pre-requisite to running the tests is that no file in ${base.test.dir}
145   * has the same name and relative path as existing files in ${base.src.dir}.
146   * As an example consider the files ${base.test.dir}/some/path/foo.bar and
147   * ${base.src.dir}/some/path/foo.bar.  In such cases, depending on how
148   * classpaths are scanned by classloaders, either file could become part of
149   * the runtime.  This could obviously cause insidious side-effects which may
150   * fake test results.  For this reason if the above pre-requisite is not met,
151   * the build will be failed.  Otherwise this target goes on by creating the
152   * test root dir and its sub-dirs.  Then all files needed to compile and run
153   * the tests are copied over from their original dirs.
154   * Note that if ${test.reports.dir} exists, it is first deleted and then
155   * replaced with a new dir.  This ensures the results of previous tests runs
156   * won't show up. (The test-reporting tasks generate reports by adding a
157   * report file for each test case output; so if a test case is removed, the
158   * report of any previous run wouldn't be deleted.)
159  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
160  <target name="test-init" depends="init">
161    <checkdup dir="${base.test.dir}" targetdir="${base.src.dir}" /> 
162    <mkdir dir="${test.dir}" />
163    <mkdir dir="${test.compiled.dir}" />
164    <mkdir dir="${test.lib.dir}" /> 
165    <delete dir="${test.reports.dir}" />
166    <mkdir dir="${test.reports.dir}" /> 
167    <mkdir dir="${test.reports.xml.dir}" /> 
168    <mkdir dir="${test.reports.html.dir}" /> 
169    <copy todir="${test.compiled.dir}">
170      <fileset refid="test.resources" />
171    </copy> 
172    <copy todir="${test.lib.dir}">
173      <fileset refid="test.libs" />
174    </copy> 
175  </target>
176
177  <!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
178   * Compile the test sources into ${test.compiled.dir}.
179   * The test sources is the set of all files within ${base.test.dir} that
180   * match the test.sources pattern.  The classpath is set to
181   * ${test.compile.classpath}.
182   *
183   * NOTE: We also verify that app.run.classpath has been defined.
184   * Because we turn this path ref into a string, we can only check for
185   * existence after all its path elements have been created (otherwise
186   * we get the empty string).  This happens in app-init; because compile
187   * depends on app-init, we defer this check until compile has been called.
188  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--> 
189  <target name="test-compile" depends="test-init,compile">
190    <checkdef ref="app.run.classpath" /> 
191    <javac srcdir="${base.test.dir}" 
192           destdir="${test.compiled.dir}"
193           includeantruntime="no" 
194           deprecation="yes"
195           debug="yes"
196           debuglevel="lines,vars,source">
197      <classpath refid="test.compile.classpath" />
198      <patternset refid="test.sources" /> 
199    </javac> 
200  </target> 
201   
202  <!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
203   * Run all tests, produce a report, and halt the build upon test failure.
204   * The test suite is specifed by the test.suite fileset.  Every test case
205   * is run in its own JVM so that a higher level of insulation is ensured by
206   * avoiding statics to propagate from the current JVM to the test case or
207   * among test cases.  The classpath of the forked JVM is set to the Ant's
208   * classpath and to ${test.classpath}.  (Ant's classpath is required because
209   * the forked JVM needs to load the junit and junitreport tasks.)
210   * After the tests run, an xml report is produced into
211   * ${test.reports.xml.dir}.  In turn, an html report is generated from
212   * those xml files and placed under ${test.reports.html.dir}.
213  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--> 
214  <target name="test" 
215          depends="test-compile"
216          description="Run all tests.">
217    <junit printsummary="yes" 
218           errorproperty="test.didnt.pass" 
219           failureproperty="test.didnt.pass"
220           fork="yes">
221      <classpath refid="test.classpath" /> 
222      <batchtest todir="${test.reports.xml.dir}">
223        <fileset refid="test.suite" />
224        <formatter type="brief" usefile="no" />
225        <formatter type="xml" /> 
226      </batchtest> 
227    </junit>
228    <junitreport todir="${test.reports.xml.dir}">
229      <fileset dir="${test.reports.xml.dir}" includes="TEST-*.xml" />
230      <report todir="${test.reports.html.dir}" 
231              format="frames"
232              styledir="${base.build.dir}/tools" /> 
233    </junitreport>
234    <fail if="test.didnt.pass">
235      Tests didn't pass.  See report details in ${test.reports.html.dir}.
236    </fail> 
237  </target>
238 
239  <!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
240   * Run all Data Services tests, produce a report, and halt the build upon
241   * test failure.
242   * The test suite is specifed by the test.ds.suite fileset.  Every test case
243   * is run in the same JVM so that the connection to OMEDS may be recycled.
244   * The classpath of the JVM is set to the Ant's classpath and to
245   * ${test.classpath}.  The system properties used by to establish a live
246   * connection to the server are set to the values of ${test.ds.url},
247   * ${test.ds.user}, and ${test.ds.pass}.
248   * After the tests run, an xml report is produced into
249   * ${test.reports.xml.dir}.  In turn, an html report is generated from
250   * those xml files and placed under ${test.reports.html.dir}.
251  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--> 
252  <target name="test-ds" 
253          depends="test-compile"
254          description="Run all Data Services tests.">
255    <junit printsummary="yes" 
256           errorproperty="test-ds.didnt.pass" 
257           failureproperty="test-ds.didnt.pass"
258           fork="no">
259      <classpath refid="test.classpath" />
260      <sysproperty key="omeds.url" value="${test.ds.url}"/>
261      <sysproperty key="omeds.user" value="${test.ds.user}"/>
262      <sysproperty key="omeds.pass" value="${test.ds.pass}"/> 
263      <batchtest todir="${test.reports.xml.dir}">
264        <fileset refid="test.ds.suite" />
265        <formatter type="brief" usefile="no" />
266        <formatter type="xml" /> 
267      </batchtest> 
268    </junit>
269    <junitreport todir="${test.reports.xml.dir}">
270      <fileset dir="${test.reports.xml.dir}" includes="TEST-*.xml" />
271      <report todir="${test.reports.html.dir}" 
272              format="frames"
273              styledir="${base.build.dir}/tools" /> 
274    </junitreport>
275    <fail if="test-ds.didnt.pass">
276      Tests didn't pass.  See report details in ${test.reports.html.dir}.
277    </fail> 
278  </target>
279 
280  <!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
281   * Remove all output generated by the targets within this file.
282   * This target simply deletes the ${test.dir}, relying on the fact that all
283   * other targets output under this dir.  As long as dir mapping props stick
284   * to this rule, new targets can be added without modifying this one.
285   * Should a target output dir need to be mapped to a dir outside of
286   * ${test.dir}, then an explicit delete has to be added here.
287  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
288  <target name="clean"
289          description="Remove all output generated by test targets.">
290    <delete dir="${test.dir}" />
291  </target>
292 
293  <!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
294   * Outputs a list of available targets.
295   * This is the list of all public targets exported by this file.
296  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
297  <target name="usage"
298          description="List available test targets.">
299    <echo level="info">
300Test targets:
301-------------
302  test: Run all the tests and output a report under ${test.reports.html.dir}.
303  test-ds: Run all the Data Services tests and output a report under
304           ${test.reports.html.dir}. 
305           Note that these tests require a live connection to OMEDS and extra
306           configuration.  Otherwise they will all fail.
307  test.clean: Remove ${test.dir}.
308    </echo> 
309  </target> 
310 
311</project> 
Note: See TracBrowser for help on using the browser.

Download in other formats:

  • Plain Text
  • Original Format

Trac Powered

Powered by Trac 0.11
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/