thrift-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ro...@apache.org
Subject svn commit: r1153673 - in /thrift/trunk/lib/js/test: build.xml jsTestDriver.conf json2.js test.html test.js
Date Wed, 03 Aug 2011 21:21:44 GMT
Author: roger
Date: Wed Aug  3 21:21:43 2011
New Revision: 1153673

URL: http://svn.apache.org/viewvc?rev=1153673&view=rev
Log:
THRIFT-1249 js-test-driver support (run unittests on multiple browsers and get XML test results)

additonal improvements
- unit test log in XML
- fetch local copy of jslibs to build/js/lib/
- remove unused json2.js
- some lint on test.js

Added:
    thrift/trunk/lib/js/test/jsTestDriver.conf   (with props)
Removed:
    thrift/trunk/lib/js/test/json2.js
Modified:
    thrift/trunk/lib/js/test/build.xml
    thrift/trunk/lib/js/test/test.html
    thrift/trunk/lib/js/test/test.js

Modified: thrift/trunk/lib/js/test/build.xml
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/js/test/build.xml?rev=1153673&r1=1153672&r2=1153673&view=diff
==============================================================================
--- thrift/trunk/lib/js/test/build.xml (original)
+++ thrift/trunk/lib/js/test/build.xml Wed Aug  3 21:21:43 2011
@@ -26,7 +26,7 @@
   <property name="genjava" location="gen-java" />
   <property name="genjs" location="gen-js" />
   <property name="build" location="build" />
-  <property name="jar.file" location="${basedir}/jstest.jar" /> 
+  <property name="jar.file" location="${build}/jstest.jar" />
 
   <!-- the root directory, where you unpack thrift distibution (e.g. thrift-0.x.x.tar.gz)
-->
   <property name="thrift.dir" location="../../../" />
@@ -85,26 +85,46 @@
   <target name="init" depends="dependencies">
     <tstamp />
     <mkdir dir="${build}"/>
+    <mkdir dir="${build}/js/lib"/>
     <mkdir dir="${build}/lib"/>
     <mkdir dir="${build}/log"/>
+    <mkdir dir="${build}/test"/>
+    <mkdir dir="${build}/test/log"/>
+  </target>
+
+  <target name="jslibs" depends="init, proxy">
+    <get src="http://code.jquery.com/jquery-1.5.2.js" dest="${build}/js/lib" usetimestamp="true"/>
+    <get src="http://js-test-driver.googlecode.com/svn/trunk/JsTestDriver/contrib/qunit/src/equiv.js"
dest="${build}/js/lib" usetimestamp="true"/>
+    <get src="http://js-test-driver.googlecode.com/svn/trunk/JsTestDriver/contrib/qunit/src/QUnitAdapter.js"
dest="${build}/js/lib" usetimestamp="true"/>
+
+    <get src="http://code.jquery.com/qunit/git/qunit.js" dest="${build}/js/lib" usetimestamp="true"/>
+    <get src="http://code.jquery.com/qunit/git/qunit.css" dest="${build}/js/lib" usetimestamp="true"/>
+    <!-- js-test-driver has issues with relative path...so we need a copy -->
+    <copy file="../thrift.js" todir="${build}/js/"/>
   </target>
 
   <target name="compile" description="compile the test suite" depends="init, generate,
resolve">
-    <javac srcdir="${genjava}" destdir="${build}" classpathref="libs.classpath" />
-    <javac srcdir="${src}" destdir="${build}" classpathref="libs.classpath" />
+    <!-- //TODO enable <compilerarg value="-Xlint"/>-->
+    <javac includeantruntime="false" srcdir="${genjava}" destdir="${build}/test" classpathref="libs.classpath"/>
+    <javac includeantruntime="false" srcdir="${src}" destdir="${build}/test" classpathref="libs.classpath"/>
   </target>
 
   <target name="jstest" description="create the test suite jar file" depends="compile">
-    <jar jarfile="${jar.file}" basedir="${build}"/>
+    <jar jarfile="${jar.file}" basedir="${build}/test"/>
   </target>
 
-  <target name="testserver" description="run the test server" depends="jstest">
+  <target name="testserver" description="run the test server" depends="jstest, jslibs">
     <java classname="test.Httpd" fork="true"
       classpathref="test.classpath" failonerror="true">
       <arg value="../" />
     </java>
   </target>
 
+  <target name="proxy" if="proxy.enabled">
+    <setproxy proxyhost="${proxy.host}" proxyport="${proxy.port}"
+      proxyuser="${proxy.user}" proxypassword="${proxy.pass}"/>
+  </target>
+
   <target name="xvfb">
     <echo>check if Xvfb is available:</echo>
     <exec executable="Xvfb" failifexecutionfails="no" resultproperty="xvfb.present" failonerror="false"
output="${build}/log/xvfb.log">
@@ -119,7 +139,7 @@
     </exec>
   </target>
 
-  <target name="unittest" description="do unit tests with headless browser phantomjs"
depends="init, phantomjs, jstest" if="phantomjs.present">
+  <target name="unittest" description="do unit tests with headless browser phantomjs"
depends="init, phantomjs, jstest, jslibs" if="phantomjs.present">
     <parallel>
       <exec executable="Xvfb" spawn="true" failonerror="false">
         <arg line=":99" />
@@ -139,6 +159,41 @@
     </parallel>
   </target>
 
+  <target name="jstestdriver-server" description="start the js-test-driver server" depends="init,
resolve">
+    <echo>Starting js-test-driver Server...</echo>
+    <java jar="${build}/lib/jstestdriver-1.3.2.jar" dir="." fork="true"
+            failonerror="true" output="${build}/log/jstestdriver-server.log">
+      <arg line="--port 9876"/>
+    </java>
+  </target>
+
+  <target name="jstestdriver" description="do unit tests with js-test-driver" depends="init,
jstest, jslibs">
+    <parallel>
+      <java classname="test.Httpd" fork="true" timeout="10000"
+        classpathref="test.classpath" failonerror="false" output="${build}/log/unittest.log">
+        <arg value="../" />
+      </java>
+      <sequential>
+        <sleep seconds="2"/>
+        <echo>Running Unit Tests with js-test-driver</echo>
+          <java jar="${build}/lib/jstestdriver-1.3.2.jar" dir="." fork="true" 
+            failonerror="true" output="${build}/log/jstestdriver.log">
+            <arg value="--config" />
+            <arg value="jsTestDriver.conf" />
+
+            <arg value="--reset" />
+            <arg value="--verbose" />
+
+            <arg value="--tests" />
+            <arg value="all" />
+
+            <arg value="--testOutput" />
+            <arg value="${build}/test/log/" />
+        </java>
+      </sequential>
+    </parallel>
+  </target>
+
   <target name="generate">
     <exec executable="${thrift.compiler}" failonerror="true">
       <arg line="--gen java ${thrift.dir}/test/ThriftTest.thrift" />
@@ -148,20 +203,23 @@
     </exec>
   </target>
 
-  <target name="test" description="run test suite" depends="init, generate, resolve, lint,
jstest, unittest"/>
+  <target name="test" description="run test suite (lint, unittest)" depends="lint, unittest"/>
 
-  <target name="lint" description="code quality checks" depends="generate, gjslint, jslint"/>
+  <target name="lint" description="code quality checks (jslint and gjslint if available)"
depends="generate, gjslint, jslint"/>
 
-  <target name="jslint">
+  <target name="jslint" depends="resolve">
     <taskdef uri="antlib:com.googlecode.jslint4java" resource="com/googlecode/jslint4java/antlib.xml"
classpathref="libs.classpath" />
     <!--
          the following options would probably make sense in the future:
          browser,undef,eqeqeq,plusplus,bitwise,regexp,strict,newcap,immed
     -->
-    <jsl:jslint options="evil,forin,browser,bitwise,regexp,newcap,immed">
+    <jsl:jslint options="evil,forin,browser,bitwise,regexp,newcap,immed" encoding="UTF-8">
       <formatter type="plain" />
       <fileset dir="${genjs}" includes="**/*.js" />
       <fileset dir=".." includes="thrift.js" />
+
+      <!-- issues with unsafe character -->
+      <!-- fileset dir="." includes="*test*.js" /> -->
     </jsl:jslint>
   </target>
 
@@ -177,6 +235,9 @@
       <arg line="--nojsdoc"/>
       <arg line="${genjs}/*.js"/>
       <arg line="../thrift.js"/>
+
+      <!-- issues with unsafe character, etc. -->
+      <!-- <arg line="*test*.js"/> -->
     </exec>
   </target>
 
@@ -184,7 +245,6 @@
     <delete dir="${build}" />
     <delete dir="${genjava}" />
     <delete dir="${genjs}" />
-    <delete file="${jar.file}" />
   </target>
 
   <target name="resolve" unless="mvn.finished">
@@ -193,6 +253,9 @@
     <artifact:dependencies filesetId="js.test.dependency.jars">
       <dependency groupId="org.apache.httpcomponents" artifactId="httpclient" version="4.0.1"/>
       <dependency groupId="com.googlecode.jslint4java" artifactId="jslint4java-ant" version="1.4.6"/>
+      <!-- get jstestdriver.jar via maven-->
+      <remoteRepository id="jstd-maven-plugin google code repo" url="http://jstd-maven-plugin.googlecode.com/svn/maven2"/>
+      <dependency groupId="com.google.jstestdriver" artifactId="maven-jstestdriver-plugin"
version="1.3.2.3"/>
     </artifact:dependencies>
 
     <!-- Copy the dependencies to the build/lib dir -->

Added: thrift/trunk/lib/js/test/jsTestDriver.conf
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/js/test/jsTestDriver.conf?rev=1153673&view=auto
==============================================================================
--- thrift/trunk/lib/js/test/jsTestDriver.conf (added)
+++ thrift/trunk/lib/js/test/jsTestDriver.conf Wed Aug  3 21:21:43 2011
@@ -0,0 +1,17 @@
+server: http://localhost:9876
+
+load:
+# Qunit adapter
+  - build/js/lib/equiv.js
+  - build/js/lib/QUnitAdapter.js
+# dependencies
+  - build/js/lib/jquery-1.5.2.js
+  - build/js/thrift.js
+  - gen-js/ThriftTest_types.js
+  - gen-js/ThriftTest.js
+# the test suite
+  - test.js
+
+# redirect to the Java based Thrift testserver
+proxy:
+ - {matcher: "*", server: " http://localhost:8088"}

Propchange: thrift/trunk/lib/js/test/jsTestDriver.conf
------------------------------------------------------------------------------
    svn:executable = *

Modified: thrift/trunk/lib/js/test/test.html
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/js/test/test.html?rev=1153673&r1=1153672&r2=1153673&view=diff
==============================================================================
--- thrift/trunk/lib/js/test/test.html (original)
+++ thrift/trunk/lib/js/test/test.html Wed Aug  3 21:21:43 2011
@@ -27,11 +27,11 @@
   <script src="gen-js/ThriftTest.js"       type="text/javascript" charset="utf-8"></script>
 
   <!-- jQuery -->
-  <script type="text/javascript" src="http://code.jquery.com/jquery-1.5.2.js" charset="utf-8"></script>
+  <script type="text/javascript" src="build/js/lib/jquery-1.5.2.js" charset="utf-8"></script>
   
   <!-- QUnit Test framework-->
-  <script type="text/javascript" src="http://code.jquery.com/qunit/git/qunit.js" charset="utf-8"></script>
-  <link rel="stylesheet" href="http://code.jquery.com/qunit/git/qunit.css" type="text/css"
media="screen" />
+  <script type="text/javascript" src="build/js/lib/qunit.js" charset="utf-8"></script>
+  <link rel="stylesheet" href="build/js/lib/qunit.css" type="text/css" media="screen"
/>
   
   <!-- the Test Suite-->
   <script type="text/javascript" src="test.js" charset="utf-8"></script>

Modified: thrift/trunk/lib/js/test/test.js
URL: http://svn.apache.org/viewvc/thrift/trunk/lib/js/test/test.js?rev=1153673&r1=1153672&r2=1153673&view=diff
==============================================================================
--- thrift/trunk/lib/js/test/test.js (original)
+++ thrift/trunk/lib/js/test/test.js Wed Aug  3 21:21:43 2011
@@ -1,4 +1,4 @@
-/*
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements. See the NOTICE file
  * distributed with this work for additional information
@@ -62,11 +62,11 @@ module("Base Types");
 module("Structured Types");
 
   test("Struct", function() {
-    var structTestInput = new ThriftTest.Xtruct()
-    structTestInput.string_thing = 'worked'
-    structTestInput.byte_thing = 0x01
-    structTestInput.i32_thing = Math.pow(2,30)
-    structTestInput.i64_thing = Math.pow(2,60)
+    var structTestInput = new ThriftTest.Xtruct();
+    structTestInput.string_thing = 'worked';
+    structTestInput.byte_thing = 0x01;
+    structTestInput.i32_thing = Math.pow(2,30);
+    structTestInput.i64_thing = Math.pow(2,60);
 
     var structTestOutput = client.testStruct(structTestInput);
 
@@ -75,20 +75,20 @@ module("Structured Types");
     equals(structTestOutput.i32_thing, structTestInput.i32_thing);
     equals(structTestOutput.i64_thing, structTestInput.i64_thing);
     
-    equals(JSON.stringify(structTestOutput), JSON.stringify(structTestInput))
+    equals(JSON.stringify(structTestOutput), JSON.stringify(structTestInput));
   });
 
   test("Nest", function() {
-    var xtrTestInput = new ThriftTest.Xtruct()
-    xtrTestInput.string_thing = 'worked'
-    xtrTestInput.byte_thing = 0x01
-    xtrTestInput.i32_thing = Math.pow(2,30)
-    xtrTestInput.i64_thing = Math.pow(2,60)
+    var xtrTestInput = new ThriftTest.Xtruct();
+    xtrTestInput.string_thing = 'worked';
+    xtrTestInput.byte_thing = 0x01;
+    xtrTestInput.i32_thing = Math.pow(2,30);
+    xtrTestInput.i64_thing = Math.pow(2,60);
     
-    var nestTestInput = new ThriftTest.Xtruct2()
-    nestTestInput.byte_thing = 0x02
-    nestTestInput.struct_thing = xtrTestInput
-    nestTestInput.i32_thing = Math.pow(2,15)
+    var nestTestInput = new ThriftTest.Xtruct2();
+    nestTestInput.byte_thing = 0x02;
+    nestTestInput.struct_thing = xtrTestInput;
+    nestTestInput.i32_thing = Math.pow(2,15);
     
     var nestTestOutput = client.testNest(nestTestInput);
     
@@ -99,13 +99,13 @@ module("Structured Types");
     equals(nestTestOutput.struct_thing.i64_thing, nestTestInput.struct_thing.i64_thing);
     equals(nestTestOutput.i32_thing, nestTestInput.i32_thing);
     
-    equals(JSON.stringify(nestTestOutput), JSON.stringify(nestTestInput))
+    equals(JSON.stringify(nestTestOutput), JSON.stringify(nestTestInput));
   });
 
   test("Map", function() {
     var mapTestInput = {7:77, 8:88, 9:99};
 
-    var mapTestOutput = client.testMap(mapTestInput)
+    var mapTestOutput = client.testMap(mapTestInput);
 
     for (var key in mapTestOutput) {
       equals(mapTestOutput[key], mapTestInput[key]);
@@ -118,7 +118,7 @@ module("Structured Types");
       "longValue":stringTest, stringTest:"long key"
     };
 
-    var mapTestOutput = client.testStringMap(mapTestInput)
+    var mapTestOutput = client.testStringMap(mapTestInput);
 
     for (var key in mapTestOutput) {
       equals(mapTestOutput[key], mapTestInput[key]);
@@ -126,12 +126,12 @@ module("Structured Types");
   });
 
   test("Set", function() {
-    var setTestInput = new Array(1,2,3)
+    var setTestInput = [1,2,3];
     ok(client.testSet(setTestInput), setTestInput);
   });
 
   test("List", function() {
-    var listTestInput = new Array(1,2,3)
+    var listTestInput = [1,2,3];
     ok(client.testList(listTestInput), listTestInput);
   });
 
@@ -161,7 +161,7 @@ module("deeper!");
       }
     }
     
-    equals(JSON.stringify(mapMapTestOutput), JSON.stringify(mapMapTestExpectedResult))
+    equals(JSON.stringify(mapMapTestOutput), JSON.stringify(mapMapTestExpectedResult));
   });
 
 
@@ -239,7 +239,7 @@ module("Insanity");
     var res = client.testInsanity("");
     ok(res, JSON.stringify(res));
     ok(insanity, JSON.stringify(insanity));
-    equals(JSON.stringify(res), JSON.stringify(insanity)) //TODO: read and compare maps recursively
+    equals(JSON.stringify(res), JSON.stringify(insanity)); //TODO: read and compare maps
recursively
   });
 
 



Mime
View raw message