Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 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 | |
Jake Farrell | ad6426c | 2011-04-20 16:35:20 +0000 | [diff] [blame] | 10 | http://www.apache.org/licenses/LICENSE-2.0 |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 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="." |
Roger Meier | da6e6ae | 2011-03-15 09:55:33 +0000 | [diff] [blame] | 20 | xmlns:artifact="antlib:org.apache.maven.artifact.ant" |
| 21 | xmlns:jsl="antlib:com.googlecode.jslint4java"> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 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" /> |
Roger Meier | edf0d1d | 2011-08-03 21:21:43 +0000 | [diff] [blame] | 29 | <property name="jar.file" location="${build}/jstest.jar" /> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 30 | |
Mustafa Senol Cosar | f86845e | 2018-12-05 17:50:18 +0300 | [diff] [blame^] | 31 | <!-- the root directory, where you unpack thrift distibution (e.g.: thrift-0.x.x.tar.gz) --> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 32 | <property name="thrift.dir" location="../../../" /> |
| 33 | <property name="thrift.java.dir" location="${thrift.dir}/lib/java" /> |
Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 34 | <property name="build.tools.dir" location="${thrift.java.dir}/build/tools/"/> |
| 35 | <property file="${basedir}/build.properties"/> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 36 | |
Mustafa Senol Cosar | f86845e | 2018-12-05 17:50:18 +0300 | [diff] [blame^] | 37 | <!-- Include the base Java properties file --> |
Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 38 | <property file="${thrift.java.dir}/gradle.properties" /> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 39 | |
Jake Farrell | ad6426c | 2011-04-20 16:35:20 +0000 | [diff] [blame] | 40 | <property name="thrift.compiler" location="${thrift.dir}/compiler/cpp/thrift" /> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 41 | |
| 42 | <path id="libs.classpath"> |
Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 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" /> |
Roger Meier | 2fdf05c | 2011-03-25 11:37:16 +0000 | [diff] [blame] | 47 | </fileset> |
Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 48 | <fileset dir="${thrift.java.dir}/build/deps"> |
Roger Meier | 2fdf05c | 2011-03-25 11:37:16 +0000 | [diff] [blame] | 49 | <include name="*.jar" /> |
| 50 | </fileset> |
Jake Farrell | ad6426c | 2011-04-20 16:35:20 +0000 | [diff] [blame] | 51 | <fileset dir="${build}/lib"> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 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> |
Roger Meier | 2fdf05c | 2011-03-25 11:37:16 +0000 | [diff] [blame] | 65 | <resourcecount count="2"> |
Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 66 | <fileset id="fs" dir="${thrift.java.dir}/build/libs"> |
Roger Meier | a35944b | 2011-07-15 20:16:43 +0000 | [diff] [blame] | 67 | <include name="libthrift*.jar" /> |
| 68 | <exclude name="libthrift*javadoc.jar" /> |
Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 69 | <exclude name="libthrift*sources.jar" /> |
Roger Meier | a35944b | 2011-07-15 20:16:43 +0000 | [diff] [blame] | 70 | </fileset> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 71 | </resourcecount> |
| 72 | </not> |
| 73 | </condition> |
Roger Meier | 2fdf05c | 2011-03-25 11:37:16 +0000 | [diff] [blame] | 74 | You need libthrift*.jar and libthrift*test.jar located at |
James E. King III | 2b09dfe | 2018-03-13 10:11:25 -0400 | [diff] [blame] | 75 | ${thrift.java.dir}/build/libs |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 76 | Did you compile Thrift Java library and its test suite by "ant compile-test"? |
| 77 | </fail> |
| 78 | <fail> |
| 79 | <condition> |
| 80 | <not> |
| 81 | <resourcecount count="1"> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 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 /> |
Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 92 | <mkdir dir="${build.tools.dir}"/> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 93 | <mkdir dir="${build}"/> |
Roger Meier | edf0d1d | 2011-08-03 21:21:43 +0000 | [diff] [blame] | 94 | <mkdir dir="${build}/js/lib"/> |
Jake Farrell | ad6426c | 2011-04-20 16:35:20 +0000 | [diff] [blame] | 95 | <mkdir dir="${build}/lib"/> |
Roger Meier | 0b26725 | 2011-07-29 21:08:04 +0000 | [diff] [blame] | 96 | <mkdir dir="${build}/log"/> |
Roger Meier | edf0d1d | 2011-08-03 21:21:43 +0000 | [diff] [blame] | 97 | <mkdir dir="${build}/test"/> |
| 98 | <mkdir dir="${build}/test/log"/> |
| 99 | </target> |
| 100 | |
Philip Frank | 5066eb4 | 2018-03-07 20:49:25 +0100 | [diff] [blame] | 101 | <target name="download_jslibs"> |
Nobuaki Sukegawa | 63b5120 | 2015-05-10 23:35:07 +0900 | [diff] [blame] | 102 | <get src="http://code.jquery.com/jquery-1.11.3.min.js" dest="${build}/js/lib/jquery.js" usetimestamp="true"/> |
Brian Forbis | b5d6ea3 | 2018-08-25 23:39:29 -0400 | [diff] [blame] | 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"/> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 105 | </target> |
| 106 | |
Philip Frank | 5066eb4 | 2018-03-07 20:49:25 +0100 | [diff] [blame] | 107 | <target name="jslibs" depends="init, proxy, download_jslibs"> |
| 108 | </target> |
| 109 | |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 110 | <target name="compile" description="compile the test suite" depends="init, generate, resolve"> |
Roger Meier | edf0d1d | 2011-08-03 21:21:43 +0000 | [diff] [blame] | 111 | <!-- //TODO enable <compilerarg value="-Xlint"/>--> |
James E. King, III | cf25489 | 2017-01-25 20:34:04 -0500 | [diff] [blame] | 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"/> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 114 | </target> |
| 115 | |
Roger Meier | 0b26725 | 2011-07-29 21:08:04 +0000 | [diff] [blame] | 116 | <target name="jstest" description="create the test suite jar file" depends="compile"> |
Roger Meier | edf0d1d | 2011-08-03 21:21:43 +0000 | [diff] [blame] | 117 | <jar jarfile="${jar.file}" basedir="${build}/test"/> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 118 | </target> |
| 119 | |
Roger Meier | edf0d1d | 2011-08-03 21:21:43 +0000 | [diff] [blame] | 120 | <target name="testserver" description="run the test server" depends="jstest, jslibs"> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 121 | <java classname="test.Httpd" fork="true" |
| 122 | classpathref="test.classpath" failonerror="true"> |
| 123 | <arg value="../" /> |
| 124 | </java> |
| 125 | </target> |
| 126 | |
Roger Meier | edf0d1d | 2011-08-03 21:21:43 +0000 | [diff] [blame] | 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 | |
Roger Meier | 0b26725 | 2011-07-29 21:08:04 +0000 | [diff] [blame] | 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 | |
Roger Meier | edf0d1d | 2011-08-03 21:21:43 +0000 | [diff] [blame] | 146 | <target name="unittest" description="do unit tests with headless browser phantomjs" depends="init, phantomjs, jstest, jslibs" if="phantomjs.present"> |
Roger Meier | 0b26725 | 2011-07-29 21:08:04 +0000 | [diff] [blame] | 147 | <parallel> |
| 148 | <exec executable="Xvfb" spawn="true" failonerror="false"> |
| 149 | <arg line=":99" /> |
| 150 | </exec> |
Roger Meier | 4f8a523 | 2011-09-09 08:17:02 +0000 | [diff] [blame] | 151 | <java classname="test.Httpd" fork="true" timeout="10000" |
Roger Meier | 0b26725 | 2011-07-29 21:08:04 +0000 | [diff] [blame] | 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 | |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 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"> |
Roger Meier | 08b3099 | 2011-04-06 21:30:53 +0000 | [diff] [blame] | 171 | <arg line="--gen js:jquery ${thrift.dir}/test/ThriftTest.thrift" /> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 172 | </exec> |
Ozan Can Altiok | e46419b | 2018-03-20 15:02:28 +0300 | [diff] [blame] | 173 | <exec executable="${thrift.compiler}" failonerror="true"> |
| 174 | <arg line="--gen js:jquery ${thrift.dir}/test/DoubleConstantsTest.thrift" /> |
| 175 | </exec> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 176 | </target> |
| 177 | |
Roger Meier | edf0d1d | 2011-08-03 21:21:43 +0000 | [diff] [blame] | 178 | <target name="test" description="run test suite (lint, unittest)" depends="lint, unittest"/> |
Roger Meier | f249576 | 2011-03-17 19:13:36 +0000 | [diff] [blame] | 179 | |
Roger Meier | edf0d1d | 2011-08-03 21:21:43 +0000 | [diff] [blame] | 180 | <target name="lint" description="code quality checks (jslint and gjslint if available)" depends="generate, gjslint, jslint"/> |
Roger Meier | da6e6ae | 2011-03-15 09:55:33 +0000 | [diff] [blame] | 181 | |
Roger Meier | edf0d1d | 2011-08-03 21:21:43 +0000 | [diff] [blame] | 182 | <target name="jslint" depends="resolve"> |
Roger Meier | 42a6fa4 | 2011-03-21 21:26:35 +0000 | [diff] [blame] | 183 | <taskdef uri="antlib:com.googlecode.jslint4java" resource="com/googlecode/jslint4java/antlib.xml" classpathref="libs.classpath" /> |
Roger Meier | da6e6ae | 2011-03-15 09:55:33 +0000 | [diff] [blame] | 184 | <!-- |
| 185 | the following options would probably make sense in the future: |
| 186 | browser,undef,eqeqeq,plusplus,bitwise,regexp,strict,newcap,immed |
| 187 | --> |
Roger Meier | edf0d1d | 2011-08-03 21:21:43 +0000 | [diff] [blame] | 188 | <jsl:jslint options="evil,forin,browser,bitwise,regexp,newcap,immed" encoding="UTF-8"> |
Roger Meier | da6e6ae | 2011-03-15 09:55:33 +0000 | [diff] [blame] | 189 | <formatter type="plain" /> |
Henrique Mendonça | 095ddb7 | 2013-09-20 19:38:03 +0200 | [diff] [blame] | 190 | <fileset dir="../src" includes="thrift.js" /> |
Roger Meier | edf0d1d | 2011-08-03 21:21:43 +0000 | [diff] [blame] | 191 | |
| 192 | <!-- issues with unsafe character --> |
| 193 | <!-- fileset dir="." includes="*test*.js" /> --> |
Roger Meier | da6e6ae | 2011-03-15 09:55:33 +0000 | [diff] [blame] | 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> |
Jake Farrell | ad6426c | 2011-04-20 16:35:20 +0000 | [diff] [blame] | 203 | |
Roger Meier | da6e6ae | 2011-03-15 09:55:33 +0000 | [diff] [blame] | 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"/> |
Henrique Mendonça | 095ddb7 | 2013-09-20 19:38:03 +0200 | [diff] [blame] | 208 | <arg line="../src/thrift.js"/> |
Roger Meier | edf0d1d | 2011-08-03 21:21:43 +0000 | [diff] [blame] | 209 | |
| 210 | <!-- issues with unsafe character, etc. --> |
| 211 | <!-- <arg line="*test*.js"/> --> |
Roger Meier | da6e6ae | 2011-03-15 09:55:33 +0000 | [diff] [blame] | 212 | </exec> |
| 213 | </target> |
| 214 | |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 215 | <target name="clean"> |
| 216 | <delete dir="${build}" /> |
| 217 | <delete dir="${genjava}" /> |
| 218 | <delete dir="${genjs}" /> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 219 | </target> |
| 220 | |
Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 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"> |
Jake Farrell | ad6426c | 2011-04-20 16:35:20 +0000 | [diff] [blame] | 232 | <typedef uri="antlib:org.apache.maven.artifact.ant" classpath="${thrift.java.dir}/build/tools/${mvn.ant.task.jar}"/> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 233 | |
Jake Farrell | ad6426c | 2011-04-20 16:35:20 +0000 | [diff] [blame] | 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"/> |
Roger Meier | c8d5d4d | 2012-01-07 20:32:24 +0000 | [diff] [blame] | 237 | <dependency groupId="eu.medsea.mimeutil" artifactId="mime-util" version="2.1.3"/> |
Jake Farrell | ad6426c | 2011-04-20 16:35:20 +0000 | [diff] [blame] | 238 | </artifact:dependencies> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 239 | |
Jake Farrell | ad6426c | 2011-04-20 16:35:20 +0000 | [diff] [blame] | 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> |
Roger Meier | 0856273 | 2015-06-14 22:30:22 +0200 | [diff] [blame] | 245 | |
Jake Farrell | ad6426c | 2011-04-20 16:35:20 +0000 | [diff] [blame] | 246 | <property name="mvn.finished" value="true"/> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 247 | </target> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 248 | </project> |