]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/thrift/lib/js/test/build.xml
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / jaegertracing / thrift / lib / js / test / build.xml
1 <!--
2 Licensed to the Apache Software Foundation (ASF) under one
3 or more contributor license agreements. See the NOTICE file
4 distributed with this work for additional information
5 regarding copyright ownership. The ASF licenses this file
6 to you under the Apache License, Version 2.0 (the
7 "License"); you may not use this file except in compliance
8 with the License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing,
13 software distributed under the License is distributed on an
14 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 KIND, either express or implied. See the License for the
16 specific language governing permissions and limitations
17 under the License.
18 -->
19 <project name="Java Script Test" default="test" basedir="."
20 xmlns:artifact="antlib:org.apache.maven.artifact.ant"
21 xmlns:jsl="antlib:com.googlecode.jslint4java">
22
23 <description>Java Script Test based on Thrift Java Library</description>
24
25 <property name="src" location="src" />
26 <property name="genjava" location="gen-java" />
27 <property name="genjs" location="gen-js" />
28 <property name="build" location="build" />
29 <property name="jar.file" location="${build}/jstest.jar" />
30
31 <!-- the root directory, where you unpack thrift distibution (e.g.: thrift-0.x.x.tar.gz) -->
32 <property name="thrift.dir" location="../../../" />
33 <property name="thrift.java.dir" location="${thrift.dir}/lib/java" />
34 <property name="build.tools.dir" location="${thrift.java.dir}/build/tools/"/>
35 <property file="${basedir}/build.properties"/>
36
37 <!-- Include the base Java properties file -->
38 <property file="${thrift.java.dir}/gradle.properties" />
39
40 <property name="thrift.compiler" location="${thrift.dir}/compiler/cpp/thrift" />
41
42 <path id="libs.classpath">
43 <fileset dir="${thrift.java.dir}/build/libs">
44 <include name="libthrift*.jar" />
45 <exclude name="libthrift*javadoc.jar" />
46 <exclude name="libthrift*sources.jar" />
47 </fileset>
48 <fileset dir="${thrift.java.dir}/build/deps">
49 <include name="*.jar" />
50 </fileset>
51 <fileset dir="${build}/lib">
52 <include name="*.jar" />
53 </fileset>
54 </path>
55
56 <path id="test.classpath">
57 <path refid="libs.classpath" />
58 <pathelement location="${jar.file}" />
59 </path>
60
61 <target name="dependencies">
62 <fail>
63 <condition>
64 <not>
65 <resourcecount count="2">
66 <fileset id="fs" dir="${thrift.java.dir}/build/libs">
67 <include name="libthrift*.jar" />
68 <exclude name="libthrift*javadoc.jar" />
69 <exclude name="libthrift*sources.jar" />
70 </fileset>
71 </resourcecount>
72 </not>
73 </condition>
74 You need libthrift*.jar and libthrift*test.jar located at
75 ${thrift.java.dir}/build/libs
76 Did you compile Thrift Java library and its test suite by "make check"?
77 </fail>
78 <fail>
79 <condition>
80 <not>
81 <resourcecount count="1">
82 <fileset id="fs" dir="${thrift.dir}" includes="compiler/cpp/thrift"/>
83 </resourcecount>
84 </not>
85 </condition>
86 Thrift compiler is missing !
87 </fail>
88 </target>
89
90 <target name="init" depends="dependencies">
91 <tstamp />
92 <mkdir dir="${build.tools.dir}"/>
93 <mkdir dir="${build}"/>
94 <mkdir dir="${build}/js/lib"/>
95 <mkdir dir="${build}/lib"/>
96 <mkdir dir="${build}/log"/>
97 <mkdir dir="${build}/test"/>
98 <mkdir dir="${build}/test/log"/>
99 </target>
100
101 <target name="download_jslibs">
102 <get src="http://code.jquery.com/jquery-1.11.3.min.js" dest="${build}/js/lib/jquery.js" usetimestamp="true"/>
103 <get src="http://code.jquery.com/qunit/qunit-2.6.2.js" dest="${build}/js/lib/qunit.js" usetimestamp="true"/>
104 <get src="http://code.jquery.com/qunit/qunit-2.6.2.css" dest="${build}/js/lib/qunit.css" usetimestamp="true"/>
105 </target>
106
107 <target name="jslibs" depends="init, proxy, download_jslibs">
108 </target>
109
110 <target name="compile" description="compile the test suite" depends="init, generate, resolve">
111 <!-- //TODO enable <compilerarg value="-Xlint"/>-->
112 <javac compiler="modern" includeantruntime="false" srcdir="${genjava}" destdir="${build}/test" classpathref="libs.classpath"/>
113 <javac compiler="modern" includeantruntime="false" srcdir="${src}" destdir="${build}/test" classpathref="libs.classpath"/>
114 </target>
115
116 <target name="jstest" description="create the test suite jar file" depends="compile">
117 <jar jarfile="${jar.file}" basedir="${build}/test"/>
118 </target>
119
120 <target name="testserver" description="run the test server" depends="jstest, jslibs">
121 <java classname="test.Httpd" fork="true"
122 classpathref="test.classpath" failonerror="true">
123 <arg value="../" />
124 </java>
125 </target>
126
127 <target name="proxy" if="proxy.enabled">
128 <setproxy proxyhost="${proxy.host}" proxyport="${proxy.port}"
129 proxyuser="${proxy.user}" proxypassword="${proxy.pass}"/>
130 </target>
131
132 <target name="xvfb">
133 <echo>check if Xvfb is available:</echo>
134 <exec executable="Xvfb" failifexecutionfails="no" resultproperty="xvfb.present" failonerror="false" output="${build}/log/xvfb.log">
135 <arg line="--version"/>
136 </exec>
137 </target>
138
139 <target name="phantomjs" depends="xvfb" if="xvfb.present">
140 <echo>check if phantomjs is available:</echo>
141 <exec executable="phantomjs" failifexecutionfails="no" resultproperty="phantomjs.present" failonerror="false" output="${build}/log/phantomjs.log">
142 <arg line="--version"/>
143 </exec>
144 </target>
145
146 <target name="unittest" description="do unit tests with headless browser phantomjs" depends="init, phantomjs, jstest, jslibs" if="phantomjs.present">
147 <parallel>
148 <exec executable="Xvfb" spawn="true" failonerror="false">
149 <arg line=":99" />
150 </exec>
151 <java classname="test.Httpd" fork="true" timeout="10000"
152 classpathref="test.classpath" failonerror="false" output="${build}/log/unittest.log">
153 <arg value="../" />
154 </java>
155 <sequential>
156 <sleep seconds="2"/>
157 <echo>Running Unit Tests with headless browser!</echo>
158 <exec executable="phantomjs" failonerror="true">
159 <env key="DISPLAY" value=":99"/>
160 <arg line="phantomjs-qunit.js http://localhost:8088/test/test.html" />
161 </exec>
162 </sequential>
163 </parallel>
164 </target>
165
166 <target name="generate">
167 <exec executable="${thrift.compiler}" failonerror="true">
168 <arg line="--gen java ${thrift.dir}/test/ThriftTest.thrift" />
169 </exec>
170 <exec executable="${thrift.compiler}" failonerror="true">
171 <arg line="--gen js:jquery ${thrift.dir}/test/ThriftTest.thrift" />
172 </exec>
173 <exec executable="${thrift.compiler}" failonerror="true">
174 <arg line="--gen js:jquery ${thrift.dir}/test/DoubleConstantsTest.thrift" />
175 </exec>
176 </target>
177
178 <target name="test" description="run test suite (lint, unittest)" depends="lint, unittest"/>
179
180 <target name="lint" description="code quality checks (jslint and gjslint if available)" depends="generate, gjslint, jslint"/>
181
182 <target name="jslint" depends="resolve">
183 <taskdef uri="antlib:com.googlecode.jslint4java" resource="com/googlecode/jslint4java/antlib.xml" classpathref="libs.classpath" />
184 <!--
185 the following options would probably make sense in the future:
186 browser,undef,eqeqeq,plusplus,bitwise,regexp,strict,newcap,immed
187 -->
188 <jsl:jslint options="evil,forin,browser,bitwise,regexp,newcap,immed" encoding="UTF-8">
189 <formatter type="plain" />
190 <fileset dir="../src" includes="thrift.js" />
191
192 <!-- issues with unsafe character -->
193 <!-- fileset dir="." includes="*test*.js" /> -->
194 </jsl:jslint>
195 </target>
196
197 <target name="check-gjslint">
198 <echo>check if gjslint is available:</echo>
199 <exec executable="gjslint" failifexecutionfails="no" resultproperty="gjslint.present" failonerror="false">
200 <arg line="--helpshort"/>
201 </exec>
202 </target>
203
204 <target name="gjslint" depends="check-gjslint" if="gjslint.present">
205 <exec executable="gjslint" failifexecutionfails="no">
206 <arg line="--nojsdoc"/>
207 <arg line="${genjs}/*.js"/>
208 <arg line="../src/thrift.js"/>
209
210 <!-- issues with unsafe character, etc. -->
211 <!-- <arg line="*test*.js"/> -->
212 </exec>
213 </target>
214
215 <target name="clean">
216 <delete dir="${build}" />
217 <delete dir="${genjava}" />
218 <delete dir="${genjs}" />
219 </target>
220
221 <target name="mvn.ant.tasks.download" depends="init,mvn.ant.tasks.check" unless="mvn.ant.tasks.found">
222 <get src="${mvn.ant.task.url}/${mvn.ant.task.jar}" dest="${build.tools.dir}/${mvn.ant.task.jar}" usetimestamp="true"/>
223 </target>
224
225 <target name="mvn.ant.tasks.check">
226 <condition property="mvn.ant.tasks.found">
227 <typefound uri="antlib:org.apache.maven.artifact.ant" name="artifact"/>
228 </condition>
229 </target>
230
231 <target name="resolve" depends="mvn.ant.tasks.download" unless="mvn.finished">
232 <typedef uri="antlib:org.apache.maven.artifact.ant" classpath="${thrift.java.dir}/build/tools/${mvn.ant.task.jar}"/>
233
234 <artifact:dependencies filesetId="js.test.dependency.jars">
235 <dependency groupId="org.apache.httpcomponents" artifactId="httpclient" version="4.0.1"/>
236 <dependency groupId="com.googlecode.jslint4java" artifactId="jslint4java-ant" version="1.4.6"/>
237 <dependency groupId="eu.medsea.mimeutil" artifactId="mime-util" version="2.1.3"/>
238 </artifact:dependencies>
239
240 <!-- Copy the dependencies to the build/lib dir -->
241 <copy todir="${build}/lib">
242 <fileset refid="js.test.dependency.jars"/>
243 <mapper type="flatten"/>
244 </copy>
245
246 <property name="mvn.finished" value="true"/>
247 </target>
248 </project>