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:45:21 UTC
svn commit: r988278 - /commons/sandbox/gsoc/2010/scxml-js/trunk/build.xml
Author: jbeard
Date: Mon Aug 23 19:45:20 2010
New Revision: 988278
URL: http://svn.apache.org/viewvc?rev=988278&view=rev
Log:
Added task generate-in-browser-unit-tests-html to generate html files for running in-browser unit tests.
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=988278&r1=988277&r2=988278&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:45:20 2010
@@ -221,6 +221,92 @@
</macrodef>
+ <macrodef name="generate-in-browser-unit-test-html-template">
+ <attribute name="testScriptModulePath"/>
+ <attribute name="out-path"/>
+ <attribute name="modulePathToXMLTest"/>
+ <attribute name="backendName"/>
+ <attribute name="is-ie"/>
+
+ <sequential>
+
+ <!-- map @{is-ie} to boolean values that generated js understands -->
+ <if>
+ <equals arg1="@{is-ie}" arg2="${is_for_ie}"/>
+ <then>
+ <property name="@{testScriptModulePath}-@{out-path}-@{modulePathToXMLTest}-@{backendName}-@{is-ie}" value="true"/>
+ </then>
+ <else>
+ <property name="@{testScriptModulePath}-@{out-path}-@{modulePathToXMLTest}-@{backendName}-@{is-ie}" value="false"/>
+ </else>
+ </if>
+
+ <echo file="@{out-path}"><![CDATA[
+ <html>
+ <head>
+ <script src="../../../../lib/js/requirejs/require.js" type="text/javascript">true;</script>
+ <script src="../../../../lib/js/requirejs/require/xml.js" type="text/javascript">true;</script>
+ <script src="../../../../lib/js/requirejs/require/text.js" type="text/javascript">true;</script>
+ <script djConfig="isDebug:true" src="../../../../lib/test-js/dojo-release-1.4.2-src/dojo/dojo.js" type="text/javascript">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 src="../test/testHelpers.js" type="text/javascript">true;</script>
+ <script>
+ var resultText;
+
+ require(
+ {
+ "baseUrl":"/"
+ },
+ [ "src/javascript/scxml/cgf/SCXMLCompiler",
+ "xml!@{modulePathToXMLTest}",
+ "@{testScriptModulePath}"],
+
+ function(compiler,documentToCompile,testScriptModule){
+ require( [window.DOMParser ?
+ "src/javascript/scxml/cgf/util/xsl/browser" :
+ "src/javascript/scxml/cgf/util/xsl/ie"],
+ function(transform){
+
+ var compileLog = true;
+
+ compiler.compile({
+ inFiles:[documentToCompile],
+ backend:"@{backendName}",
+ beautify:true,
+ verbose:false,
+ log:compileLog,
+ ie:${@{testScriptModulePath}-@{out-path}-@{modulePathToXMLTest}-@{backendName}-@{is-ie}}
+ }, function(scArr){
+ var transformedJs = scArr[0];
+
+ console.log(transformedJs);
+
+ //eval
+ eval(transformedJs);
+
+ testScriptModule.register(StatechartExecutionContext);
+
+ dojo.require("doh.runner");
+ doh.run();
+ },transform);
+ });
+ });
+
+ </script>
+ </head>
+ <body>
+ </body>
+ </html>
+ ]]></echo>
+ </sequential>
+
+ </macrodef>
+
<target name="preprocess-stylesheets" depends="init">
<xslt
classpathref="xslt-processor-classpath"
@@ -270,8 +356,30 @@
</chainedmapper>
</pathconvert>
- <echo>@{test-path}-unit-test-js-module</echo>
- <echo>${@{test-path}-unit-test-js-module}</echo>
+
+ <!-- these properties are for generate-in-browser-unit-test-html -->
+
+ <!-- module path to the xml -->
+ <pathconvert property="@{test-path}-unit-test-xml-module">
+ <path location="@{test-path}"/>
+ <chainedmapper>
+ <globmapper from="${basedir}*" to="*"/>
+ <scriptmapper language="javascript">
+ self.addMappedName(source[0] == project.getProperty("file.separator") ?
+ source.slice(1):
+ source);
+ </scriptmapper>
+ <scriptmapper language="javascript">
+ self.addMappedName(source.replace("\\","/","g"));
+ </scriptmapper>
+ </chainedmapper>
+ </pathconvert>
+
+ <!--
+ <echo>@{test-path}-unit-test-xml-module</echo>
+ <echo>${@{test-path}-unit-test-xml-module}</echo>
+ -->
+
</sequential>
</for>
@@ -295,8 +403,10 @@
</chainedmapper>
</pathconvert>
+ <!--
<echo>@{for-ie}-@{backend}-@{test-path}-target-test-path</echo>
<echo>${@{for-ie}-@{backend}-@{test-path}-target-test-path}</echo>
+ -->
<dirname property="@{for-ie}-@{backend}-@{test-path}-target-test-path-dir" file="${@{for-ie}-@{backend}-@{test-path}-target-test-path}"/>
@@ -319,8 +429,10 @@
</chainedmapper>
</pathconvert>
+ <!--
<echo>@{for-ie}-@{backend}-@{test-path}-unit-test-html-location</echo>
<echo>${@{for-ie}-@{backend}-@{test-path}-unit-test-html-location}</echo>
+ -->
<!-- compute relative path to js from html unit test folder -->
<pathconvert property="@{for-ie}-@{backend}-@{test-path}-target-test-relative-path">
@@ -339,12 +451,39 @@
</chainedmapper>
</pathconvert>
+ <!--
<echo>@{for-ie}-@{backend}-@{test-path}-target-test-relative-path</echo>
<echo>${@{for-ie}-@{backend}-@{test-path}-target-test-relative-path}</echo>
+ -->
<!-- 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}"/>
+
+ <!-- these properties are for generate-in-browser-unit-test-html -->
+ <pathconvert property="@{for-ie}-@{backend}-@{test-path}-in-browser-unit-test-html-location">
+ <path location="${@{for-ie}-@{backend}-@{test-path}-target-test-path}"/>
+ <chainedmapper>
+ <globmapper from="${basedir}*" to="*"/>
+ <scriptmapper language="javascript">
+ self.addMappedName(source[0] == project.getProperty("file.separator") ?
+ source.slice(1):
+ source);
+ </scriptmapper>
+ <scriptmapper language="javascript">
+ self.addMappedName(source.replace("\\","/","g"));
+ </scriptmapper>
+ <globmapper from="build/generate-javascript/*.js" to="build/generate-in-browser-unit-tests-html/*.html" handledirsep="true"/>
+ </chainedmapper>
+ </pathconvert>
+
+ <dirname property="@{for-ie}-@{backend}-@{test-path}-in-browser-unit-test-html-target-dir" file="${@{for-ie}-@{backend}-@{test-path}-in-browser-unit-test-html-location}"/>
+
+ <!--
+ <echo>@{for-ie}-@{backend}-@{test-path}-in-browser-unit-test-html-location</echo>
+ <echo>${@{for-ie}-@{backend}-@{test-path}-in-browser-unit-test-html-location}</echo>
+ -->
+
</sequential>
</for>
</sequential>
@@ -421,6 +560,35 @@
</for>
</target>
+
+ <target name="generate-in-browser-unit-test-html" depends="setup-properties">
+ <mkdir dir="build/generate-in-browser-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>
+
+ <!-- execute some tasks -->
+ <mkdir dir="${@{for-ie}-@{backend}-@{test-path}-in-browser-unit-test-html-target-dir}"/>
+
+ <generate-in-browser-unit-test-html-template
+ testScriptModulePath="${@{test-path}-unit-test-js-module}"
+ out-path="${@{for-ie}-@{backend}-@{test-path}-in-browser-unit-test-html-location}"
+ backendName="@{backend}"
+ is-ie="@{for-ie}"
+ modulePathToXMLTest="${@{test-path}-unit-test-xml-module}" />
+ </sequential>
+ </for>
+ </sequential>
+ </for>
+ </sequential>
+ </for>
+ </target>
+
<target name="run-unit-tests-with-selenium" depends="generate-unit-test-html,generate-javascript">
<rhinoscript><![CDATA[
function unitTestWithSelenium(sel,url,timeout){