root/gs3-extensions/testing/trunk/src/build.xml @ 32705

Revision 32705, 5.6 KB (checked in by ak19, 18 months ago)

1. Implemented (and testing as I implement) more of the GSGUITestingUtil helper functions. Most of the File Menu is done. Unfortunately can't yet commit the EDT corrections in GLI as at least one of them requires a more complex solution, possibly with a SwingWorker? as there's conflict with the ProgressBar?. 2. infrastructure for JUnit reports. Not working yet despite the inclusion of necessary jar, will investigate this later.

  • Property svn:executable set to *
Line 
1<?xml version="1.0"?>
2<project name="Greenstone3 Testing Extension" default="build-util-jar" basedir=".">
3 
4  <property environment="env"/> <!-- get properties from the environment -->
5  <property name="compile.includeantruntime" value="false"/> <!-- to get rid of annoying 'ant' warning -->
6
7  <property name="gli.home" value="${env.GSDL3SRCHOME}/gli"/>
8
9  <!-- define ext.test.folder so we can move some targets into toplevel GS3 ant build file -->
10  <property name="ext.test.folder" value="${basedir}" />
11 
12  <!-- where the reports will go -->
13  <property name="test.reports" value="${ext.test.folder}/reports" />
14 
15  <target name="build-util-jar" depends="needs-gs3-setup, needs-make-gli-jar">
16    <mkdir dir="${ext.test.folder}/build"/>
17    <javac srcdir="${ext.test.folder}/src"
18       destdir="${ext.test.folder}/build"
19       includeantruntime="${compile.includeantruntime}">
20      <classpath>
21    <fileset dir="${ext.test.folder}/lib/java">
22      <include name="*.jar"/>
23    </fileset>
24    <fileset dir="${gli.home}">
25    <include name="GLI.jar"/>
26      </fileset>
27      </classpath>
28      <include name="org/greenstone/gsdl3/testing/*.java"/>         
29    </javac>
30    <jar destfile="${ext.test.folder}/lib/java/GSTestingUtil.jar">
31      <fileset dir="${ext.test.folder}/build">
32    <include name="org/greenstone/gsdl3/testing/**"/>             
33      </fileset>
34      <manifest>
35    <attribute name="Built-By" value="Greenstone" />
36      </manifest>
37    </jar>
38  </target>
39 
40<!-- +++++++++++++ TUTORIAL TESTING TARGETS ++++++++++++++ -->
41<target name="needs-make-gli-jar"> 
42  <condition property="gli-jar-missing">
43    <not>
44      <available file="${gli.home}/GLI.jar"/>
45    </not>
46    </condition>
47   
48    <fail if="gli-jar-missing" message="Run the makegli followed by makejar scripts in the gli folder before starting the Greenstone server."/>
49</target>
50
51<target name="needs-gs3-setup">
52    <!-- has the gs3-setup script been run?? -->
53    <condition property="gs3-setup-not-done">
54      <not>
55    <isset property="env.GSDL3HOME"/>
56      </not>
57    </condition>
58
59    <fail if="gs3-setup-not-done" message="Please run 'gs3-setup' (Windows) or 'source gs3-setup.sh' (Linux/Mac) before starting the Greenstone server."/>
60
61    <echo>GLI HOME: ${gli.home}</echo>
62  </target>
63
64<target name="compile-tutorials-tests" depends="needs-gs3-setup, needs-make-gli-jar">
65
66  <mkdir dir="${ext.test.folder}/build"/>
67  <javac
68      srcdir="${ext.test.folder}/src"
69      destdir="${ext.test.folder}/build"
70      includeantruntime="${compile.includeantruntime}">
71    <classpath>
72      <fileset dir="${ext.test.folder}/lib/java">
73    <include name="*.jar"/>
74      </fileset>
75      <fileset dir="${gli.home}">
76    <include name="GLI.jar"/>
77      </fileset>
78    </classpath>           
79    <include name="gstests/tutorials/*.java"/>
80  </javac>
81  <jar destfile="${ext.test.folder}/tutorial-tests.jar">
82    <fileset dir="${ext.test.folder}/build">
83      <include name="gstests/tutorials/**"/>
84    </fileset>
85    <manifest>
86      <attribute name="Built-By" value="greenstone" />
87    </manifest>
88  </jar>
89</target>
90
91<!-- https://stackoverflow.com/questions/10704324/how-to-add-to-classpath-all-classes-from-set-of-directories-in-ant -->
92<path id="tutorials.path">
93
94  <!-- Includes ant-nodeps-1.8.1 from 2010 that replaces 2005's optional.jar of ant
95       for generating reports -->
96  <fileset dir="${ext.test.folder}/lib/java">
97    <include name="*.jar"/>
98  </fileset>
99  <!--<fileset dir="${ext.test.folder}/build">     
100    <include name="gstests/tutorials/**/*.class"/>
101  </fileset>-->
102  <files includes="${ext.test.folder}/tutorial-tests.jar"/>
103
104  <!-- To run GLI, need GLI.jar and its help jars and folder: classes folder, apache.jar, jna.jar, jna-platform.jar, qfslib.jar, rsyntaxtextarea.jar -->
105  <fileset dir="${gli.home}">
106    <include name="GLI.jar"/>
107  </fileset>
108  <pathelement path="${gli.home}/classes"/>
109  <fileset dir="${gli.home}/lib">
110    <include name="*.jar"/>
111  </fileset> 
112</path>
113
114<!-- TODO: for darwin, need to set custom_vm_args, see gli.sh
115TODO: Launching GLI for GS2 is also different -->
116
117<!-- JUnit must run in GLI folder to mimic how GLI is run.
118     One reason why this is necessary is that GLI then won't display parsing issues with GLI class HelpFrame -->
119<!-- http://ant.1045680.n5.nabble.com/How-to-increase-memory-used-by-JVM-in-Ant-td1355370.html -->
120<target name="run-tutorials-tests" depends="needs-gs3-setup, needs-make-gli-jar">
121  <echo>Tutorial tests</echo>
122  <echo>GSDLHOME: ${env.GSDLHOME}</echo> 
123  <java classname="org.junit.runner.JUnitCore" dir="${gli.home}" fork="true" maxmemory="256m" classpathref="tutorials.path">
124    <!--https://stackoverflow.com/questions/38676719/selenium-using-java-the-path-to-the-driver-executable-must-be-set-by-the-webdr-->
125    <sysproperty key="webdriver.gecko.driver" path="${ext.test.folder}/geckodriver"/>
126    <arg value="gstests.tutorials.RunGLITest"/>
127    <!-- TODO: for now hardcoding the GS3 URL. Toplevel build.xml can properly construct this
128     URL, but hard to do so quickly here -->
129    <jvmarg value="-DSERVERURL=http://127.0.0.1:8383/greenstone3/library "/>
130  </java>
131
132  <!-- create reports dir if it doesn't exist -->
133  <mkdir dir="${test.reports}"/>
134  <!--
135      https://junit.org/junit4/faq.html#running_6
136      How do I use Ant to create HTML test reports?
137  -->
138  <junitreport todir="${test.reports}">
139    <fileset dir="${test.reports}">
140      <include name="TEST-*.xml" />
141    </fileset>
142    <report todir="${test.reports}" />
143  </junitreport>
144</target>
145
146<!-- TODO: check if after testing GLI we may need to ensure tomcat stopped? -->
147
148</project>
149
Note: See TracBrowser for help on using the browser.