You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by jb...@apache.org on 2010/08/23 21:44:25 UTC
svn commit: r988271 - /commons/sandbox/gsoc/2010/scxml-js/trunk/build.xml
Author: jbeard
Date: Mon Aug 23 19:44:25 2010
New Revision: 988271
URL: http://svn.apache.org/viewvc?rev=988271&view=rev
Log:
build.xml now generates unit test html files which work correctly.
Modified:
commons/sandbox/gsoc/2010/scxml-js/trunk/build.xml
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/build.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/build.xml?rev=988271&r1=988270&r2=988271&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/build.xml (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/build.xml Mon Aug 23 19:44:25 2010
@@ -6,10 +6,20 @@
</classpath>
</taskdef>
+ <!--
<property name="backends" value="switch,table,state"/>
+ -->
+ <property name="backends" value="switch"/>
<property name="browsers" value="firefox,ie,chrome"/>
<property name="for-ie" value="is-for-ie,is-not-for-ie"/>
+ <path id="rhino-classpath">
+ </path>
+
+ <path id="xslt-processor-classpath">
+ <pathelement location="lib/java/xalan.jar"/>
+ </path>
+
<path id="scxml-js-compiler-classpath">
<pathelement location="lib/java/js.jar"/>
<pathelement location="lib/java/commons-cli.jar"/>
@@ -20,19 +30,30 @@
<pathelement location="build/scxml-js.jar"/>
</path>
+ <fileset id="stylesheets-to-preprocess" dir="src/xslt/backends/js">
+ <include name="StatePatternStatechartGenerator.xsl"/>
+ <include name="StateTableStatechartGenerator.xsl"/>
+ <include name="SwitchyardStatechartGenerator.xsl"/>
+ </fileset>
+
<path id="scxml-tests-xml">
<pathelement location="test/kitchen_sink/KitchenSink.xml"/>
+ <!--
<pathelement location="test/kitchen_sink/KitchenSink_dataModule.xml"/>
<pathelement location="test/kitchen_sink/KitchenSink_performance.xml"/>
<pathelement location="test/kitchen_sink/KitchenSink_executableContent.xml"/>
+ -->
+ <!--
<pathelement location="test/conditional_transition/TestConditionalTransition.xml"/>
<pathelement location="test/in_predicate/TestInPredicate.xml"/>
<pathelement location="test/event_system_properties/TestEventSystemProperties.xml"/>
<pathelement location="test/prefix_events/TestPrefixEvents.xml"/>
<pathelement location="test/parallel/TestParallel.xml"/>
+ -->
</path>
<target name="clean">
+ <delete dir="build"/>
</target>
<target name="init">
@@ -88,9 +109,69 @@
</sequential>
</macrodef>
+ <macrodef name="generate-unit-test-html-template">
+ <attribute name="generatedJsCodeRelativePath"/>
+ <attribute name="testScriptModulePath"/>
+ <attribute name="out-path"/>
+
+ <sequential>
+ <echo file="@{out-path}"><![CDATA[
+ <html>
+ <head>
+ <script src="../../../../lib/js/requirejs/require.js" type="text/javascript">true;</script>
+ <script type="text/javascript" src="../../../../lib/test-js/dojo-release-1.4.2-src/dojo/dojo.js" djConfig="isDebug:true">true;</script>
+ <script type="text/javascript">
+ dojo.require("doh.runner");
+ window.dohIsComplete = false;
+ window.oldDohOnEnd = window.doh._onEnd;
+ window.doh._onEnd = function() { window.dohIsComplete = true; window.oldDohOnEnd.apply(window.doh); };
+ </script>
+ <script type="text/javascript" src="../../../../test/testHelpers.js">true;</script>
+ <script type="text/javascript" src="@{generatedJsCodeRelativePath}">true;</script>
+ <script type="text/javascript">
+ require(
+ { baseUrl : "/" },
+ ["@{testScriptModulePath}"],
+ function(unitTestModule){
+ unitTestModule.register(StatechartExecutionContext);
+
+ dojo.require("doh.runner");
+ doh.run();
+ });
+ </script>
+ </head>
+ <body>
+ <h1>Test</h1>
+ </body>
+ </html>
+ ]]></echo>
+ </sequential>
+
+ </macrodef>
+
+ <target name="preprocess-stylesheets" depends="init">
+ <xslt
+ classpathref="xslt-processor-classpath"
+ style="src/xslt/util/preprocess_import.xsl"
+ destdir="build"
+ scanincludeddirectories="false"
+ useImplicitFileset="false">
+
+ <fileset refid="stylesheets-to-preprocess"/>
+
+ <mapper>
+ <chainedmapper>
+ <flattenmapper/>
+ <globmapper from="*.xsl" to="*_combined.xsl"/>
+ </chainedmapper>
+ </mapper>
+ </xslt>
+
+ </target>
+
<!-- run unit and performance tests -->
- <target name="generate-javascript">
- <!-- TODO: compile ie and non-ie versions -->
+ <target name="generate-javascript" depends="preprocess-stylesheets">
+ <mkdir dir="build/generate-javascript"/>
<for list="${for-ie}" param="for-ie">
<sequential>
@@ -108,7 +189,7 @@
<path path="@{test-path}"/>
<chainedmapper>
<flattenmapper/>
- <globmapper from="*.xml" to="build/@{for-ie}/@{backend}/*.js"/>
+ <globmapper from="*.xml" to="build/generate-javascript/@{for-ie}/@{backend}/*.js"/>
</chainedmapper>
</pathconvert>
@@ -143,7 +224,60 @@
</for>
</target>
- <target name="generate-unit-tests-html">
+ <target name="generate-unit-tests-html" depends="generate-javascript">
+ <mkdir dir="build/generate-unit-tests-html"/>
+
+ <for list="${for-ie}" param="for-ie">
+ <sequential>
+ <for list="${backends}" param="backend">
+ <sequential>
+ <for param="test-path">
+ <path refid="scxml-tests-xml"/>
+ <sequential>
+
+
+
+ <!-- compute unit test module location -->
+ <!-- to simplify, we expect it to be in a particular location -->
+ <dirname property="@{test-path}-dir" file="@{test-path}"/>
+
+ <!-- convert to relative path -->
+ <pathconvert property="@{for-ie}-@{backend}-@{test-path}-unit-test-js-module">
+ <path location="${@{test-path}-dir}"/>
+ <globmapper from="${basedir}/*" to="*/scripts/unitTest"/>
+ </pathconvert>
+
+ <!-- compute unit test html target location -->
+ <pathconvert property="@{for-ie}-@{backend}-@{test-path}-unit-test-html-location">
+ <path location="${@{for-ie}-@{backend}-@{test-path}-target-test-path}"/>
+ <globmapper from="${basedir}/build/generate-javascript/*.js" to="${basedir}/build/generate-unit-tests-html/*.html"/>
+ </pathconvert>
+
+ <!-- compute relative path to js from html unit test folder -->
+ <pathconvert property="@{for-ie}-@{backend}-@{test-path}-target-test-relative-path">
+ <path location="${@{for-ie}-@{backend}-@{test-path}-target-test-path}"/>
+ <globmapper from="${basedir}/build/*" to="../../../*"/>
+ </pathconvert>
+
+
+ <!-- get the dirname of the html target so we can make the directory structure -->
+ <dirname property="@{for-ie}-@{backend}-@{test-path}-unit-test-html-target-dir" file="${@{for-ie}-@{backend}-@{test-path}-unit-test-html-location}"/>
+
+ <echo>${@{for-ie}-@{backend}-@{test-path}-unit-test-js-module},${@{for-ie}-@{backend}-@{test-path}-unit-test-html-location},${@{for-ie}-@{backend}-@{test-path}-unit-test-html-target-dir},${@{for-ie}-@{backend}-@{test-path}-target-test-relative-path}</echo>
+
+ <!-- execute some tasks -->
+ <mkdir dir="${@{for-ie}-@{backend}-@{test-path}-unit-test-html-target-dir}"/>
+
+ <generate-unit-test-html-template
+ generatedJsCodeRelativePath="${@{for-ie}-@{backend}-@{test-path}-target-test-relative-path}"
+ testScriptModulePath="${@{for-ie}-@{backend}-@{test-path}-unit-test-js-module}"
+ out-path="${@{for-ie}-@{backend}-@{test-path}-unit-test-html-location}"/>
+ </sequential>
+ </for>
+ </sequential>
+ </for>
+ </sequential>
+ </for>
</target>
<target name="run-unit-tests-with-selenium">