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/09/08 04:09:55 UTC
svn commit: r993579 - in /commons/sandbox/gsoc/2010/scxml-js/trunk:
build-common.xml build.xml mvn-ant-build.xml pom.xml
Author: jbeard
Date: Wed Sep 8 02:09:55 2010
New Revision: 993579
URL: http://svn.apache.org/viewvc?rev=993579&view=rev
Log:
Intermediate commit. Adding ant unit testing capabilities back in. Build still works with maven.
Added:
commons/sandbox/gsoc/2010/scxml-js/trunk/build-common.xml
- copied, changed from r993181, commons/sandbox/gsoc/2010/scxml-js/trunk/mvn-ant-build.xml
Modified:
commons/sandbox/gsoc/2010/scxml-js/trunk/build.xml
commons/sandbox/gsoc/2010/scxml-js/trunk/mvn-ant-build.xml
commons/sandbox/gsoc/2010/scxml-js/trunk/pom.xml
Copied: commons/sandbox/gsoc/2010/scxml-js/trunk/build-common.xml (from r993181, commons/sandbox/gsoc/2010/scxml-js/trunk/mvn-ant-build.xml)
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/build-common.xml?p2=commons/sandbox/gsoc/2010/scxml-js/trunk/build-common.xml&p1=commons/sandbox/gsoc/2010/scxml-js/trunk/mvn-ant-build.xml&r1=993181&r2=993579&rev=993579&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/mvn-ant-build.xml (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/build-common.xml Wed Sep 8 02:09:55 2010
@@ -15,11 +15,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
-->
-<project name="scxml-js" basedir="." default="run-all-unit-tests">
+<project name="scxml-js-common" basedir=".">
+ <!-- compile_classpath and plugin_classpath properties get provided by maven or ant,
+ depending on whether maven is used as the entry point, or ant is -->
+ <!-- TODO: refactor path id maven.compile.classpath to maven.runtime.classpath -->
<path location="${compile_classpath}" id="maven.compile.classpath"/>
- <path location="${runtime_classpath}" id="maven.runtime.classpath"/>
- <path location="${test_classpath}" id="maven.test.classpath"/>
<path location="${plugin_classpath}" id="maven.plugin.classpath"/>
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
@@ -541,7 +542,7 @@
<target name="preprocess-stylesheets" depends="init">
<xslt
- classpathref="maven.compile.classpath"
+ classpathref="maven.plugin.classpath"
style="${src}/xslt/util/preprocess_import.xsl"
destdir="${build}"
scanincludeddirectories="false"
@@ -721,297 +722,6 @@
</target>
- <!-- run unit and performance tests -->
- <target name="generate-javascript" depends="preprocess-stylesheets,setup-properties">
- <mkdir dir="${build}/generate-javascript"/>
-
- <for list="${for-ie}" param="for-ie">
- <sequential>
- <for list="${backends}" param="backend">
- <sequential>
- <for param="test-path">
- <path refid="scxml_tests_xml"/>
- <sequential>
-
- <echo>${@{for-ie}-@{backend}-@{test-path}-target-test-path}, ${@{for-ie}-@{backend}-@{test-path}-target-test-path-dir}</echo>
-
- <mkdir dir="${@{for-ie}-@{backend}-@{test-path}-target-test-path-dir}"/>
-
- <if>
- <equals arg1="@{for-ie}" arg2="is-for-ie"/>
- <then>
- <compile-with-scxml-js-ie
- test-path="@{test-path}"
- backend="@{backend}"
- out-path="${@{for-ie}-@{backend}-@{test-path}-target-test-path}"/>
- </then>
- <else>
- <compile-with-scxml-js-no-ie
- test-path="@{test-path}"
- backend="@{backend}"
- out-path="${@{for-ie}-@{backend}-@{test-path}-target-test-path}"/>
- </else>
- </if>
- </sequential>
- </for>
- </sequential>
- </for>
- </sequential>
- </for>
- </target>
-
- <target name="generate-unit-test-html" depends="setup-properties">
- <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>
-
- <echo>${@{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="${@{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="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">
- <run-unit-tests-with-selenium-macro
- unit-tests-html-property-name="unit-test-html-location"/>
- </target>
-
-
- <target name="run-in-browser-unit-tests-with-selenium" depends="preprocess-stylesheets,generate-in-browser-unit-test-html">
- <run-unit-tests-with-selenium-macro
- unit-tests-html-property-name="in-browser-unit-test-html-location"/>
- </target>
-
- <target name="run-unit-tests-with-rhino" depends="generate-javascript">
- <rhinoscript><![CDATA[
- //load requirejs
- Array.prototype.slice.call(requirejs_bootstrap_paths.list()).forEach(function(requireJsPath){
- load(requireJsPath);
- });
-
-
- //this is a bit weird, but we define this here in case we need to load dojo later using the RequireJS loader
- djConfig = {
- "baseUrl" : path_to_dojo_base+"/"
- }
-
- function tailRecurse(list,stepCallback,baseCaseCallback){
- var target = list.pop();
-
- if(target){
- stepCallback(target,
- function(){tailRecurse(list,stepCallback,baseCaseCallback)});
- }else{
- if(baseCaseCallback) baseCaseCallback();
- }
- }
-
- var isComplete = false;
-
- require(
- {baseUrl:basedir},
- [path_to_dojo,
- "lib/test-js/env.js",
- "test/testHelpers.js"],
- function(){
-
- dojo.require("doh.runner");
-
- var forIE = "is-for-ie";
- var scxmlXmlTestPathList = Array.prototype.slice.call(scxml_tests_xml.list());
- var backendsList = backends.split(",");
-
- var oldDohOnEnd = doh._onEnd;
- doh._onEnd = function() { isComplete = true; oldDohOnEnd.apply(doh); };
-
- //we use tailRecurse function because of asynchronous RequireJS call used to load the unit test module
- tailRecurse(scxmlXmlTestPathList,
- function(scxmlXmlTestPath,step){
- var jsUnitTestPathPropertyName = scxmlXmlTestPath + "-" + "unit-test-js-module";
- var jsUnitTestPath = project.getProperty(jsUnitTestPathPropertyName);
-
- require([jsUnitTestPath],
- function(unitTestModule){
-
- var jsUnitTestPathPropertyNames =
- [{forIE:forIE, backend:backend,test_path:scxmlXmlTestPath}
- for each (backend in backendsList)];
-
- jsUnitTestPathPropertyNames.forEach(function(target){
-
- var jsTargetTestPathPropertyName =
- target.forIE + "-" + target.backend + "-" + target.test_path + "-" + "target-test-path";
- var jsTargetTestPath = project.getProperty(jsTargetTestPathPropertyName);
-
- //load and register
- load(jsTargetTestPath);
-
- unitTestModule.register(StatechartExecutionContext)
- delete StatechartExecutionContext;
- })
-
- step();
- });
- },
- function(){
- //run with dojo
- doh.run();
- }
- );
-
- }
- );
-
- //hold up execution until doh completes
- while(!isComplete){
- java.lang.Thread.sleep(20);
- }
-
- ]]></rhinoscript>
- </target>
-
- <target name="run-all-unit-tests"
- depends="run-unit-tests-with-selenium,run-in-browser-unit-tests-with-selenium,run-unit-tests-with-rhino" />
-
-
- <!-- build standalone executable -->
-
- <property name="build-js-main" location="${build-js}/main-built.js"/>
- <property name="build-class-main-name" value="SCXMLCompiler"/>
- <property name="build-class-main" location="${build-class}/${build-class-main-name}.class"/>
- <property name="build-jar-main" location="${build-jar}/scxml-js.jar"/>
-
- <property name="build-js-main-rhino-frontend-module" value="${src}/javascript/scxml/cgf/build/rhino"/>
-
- <property name="js-build-script" location="${lib-js}/requirejs/build/build.js"/>
- <property name="js-build-dir" location="${lib-js}/requirejs/build"/>
-
- <property name="test" location="test"/>
-
- <target name="compile-single-js" depends="preprocess-stylesheets">
- <mkdir dir="${build-js}"/>
-
- <java classname="org.mozilla.javascript.tools.shell.Main">
- <classpath>
- <path refid="rhino-classpath"/>
- <path refid="closure-classpath"/>
- </classpath>
- <arg value="${js-build-script}"/>
- <arg value="${js-build-dir}"/>
- <arg value="name=${build-js-main-rhino-frontend-module}"/>
- <arg value="out=${build-js-main}"/>
- <arg value="baseUrl=."/>
- <arg value="includeRequire=true"/>
- <arg value="inlineText=true"/>
- <arg value="optimize=none"/>
- </java>
- </target>
-
- <!-- normally dependency would be set here, but to better integrate with maven, it has been removed -->
- <!-- TODO: break this out into a macro to allow better code reuse for non-mave ant frontend -->
- <target name="compile-single-class">
- <mkdir dir="${build-class}"/>
-
- <!-- TODO: set -opt -->
- <java classname="org.mozilla.javascript.tools.jsc.Main">
- <classpath>
- <path refid="rhino-classpath"/>
- </classpath>
- <arg value="-opt"/>
- <arg value="9"/>
- <arg value="-o"/>
- <arg value="${build-class-main-name}.class"/>
- <arg value="${build-js-main}"/>
- </java>
- <move file="${build-js}/${build-class-main-name}.class" todir="${build-class}"/>
- </target>
-
- <!-- normally dependency would be set here, but to better integrate with maven, it has been removed -->
- <!-- TODO: break this out into a macro to allow better code reuse for non-mave ant frontend -->
- <target name="jar-single-class">
- <mkdir dir="${build-jar}"/>
-
- <jar destfile="${build-jar-main}"
- basedir="${build-class}"
- includes="${build-class-main-name}.class">
- <manifest>
- <attribute name="Main-Class" value="${build-class-main-name}" />
- </manifest>
- </jar>
- </target>
-
- <!-- these targets are here to do a simple test of the compiled jar and class-->
- <target name="run-single-class" depends="compile-single-class">
- <java classname="${build-class-main-name}" output="${build}/out.js">
- <classpath>
- <path refid="maven.compile.classpath"/>
- <pathelement location="${build-class}"/>
- </classpath>
- <arg value="--backend"/>
- <arg value="state"/>
- <arg value="--beautify"/>
- <arg value="test/parallel/TestParallel.xml"/>
- </java>
- </target>
-
- <target name="run-single-jar" depends="jar-single-class">
- <java classname="${build-class-main-name}" output="${build}/out.js">
- <classpath>
- <path refid="maven.compile.classpath"/>
- <pathelement location="${build-jar-main}"/>
- </classpath>
- <arg value="--backend"/>
- <arg value="state"/>
- <arg value="--beautify"/>
- <arg value="test/parallel/TestParallel.xml"/>
- </java>
- </target>
-
</project>
+
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=993579&r1=993578&r2=993579&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/build.xml (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/build.xml Wed Sep 8 02:09:55 2010
@@ -15,619 +15,50 @@
* See the License for the specific language governing permissions and
* limitations under the License.
-->
-<project name="scxml-js" basedir="." default="run-all-unit-tests">
- <taskdef resource="net/sf/antcontrib/antcontrib.properties">
- <classpath>
- <pathelement location="${basedir}/lib/build-java/ant-contrib-0.6.jar" />
- </classpath>
- </taskdef>
-
- <!-- location properties -->
- <property name="src" value="src"/>
-
- <property name="lib" location="lib"/>
- <property name="lib-java" location="${lib}/java"/>
- <property name="lib-js" location="${lib}/js"/>
- <property name="lib-test-java" location="${lib}/test-java"/>
- <property name="lib-test-js" location="${lib}/test-js"/>
-
- <property name="build" value="target"/>
- <property name="build-js" location="${build}/build-js"/>
- <property name="build-class" location="${build}/classes"/>
- <property name="build-jar" location="${build}/jar"/>
+<project name="scxml-js" basedir="." default="run-all-unit-tests"
+ xmlns:artifact="antlib:org.apache.maven.artifact.ant">
-
- <property name="ie_browser_name" value="ie"/>
-
- <property name="is_for_ie" value="is-for-ie"/>
- <property name="is_not_for_ie" value="is-not-for-ie"/>
-
- <property name="backends" value="switch,table,state"/>
- <!--
- <property name="backends" value="switch"/>
- -->
- <property name="browsers" value="firefox,chrome"/>
- <!--
- <property name="browsers" value="firefox,${ie_browser_name},chrome"/>
- -->
- <property name="for-ie" value="${is_for_ie},${is_not_for_ie}"/>
-
- <!-- selenium configuration options -->
- <property name="selenium_host" value="localhost"/>
- <property name="selenium_port" value="4444"/>
- <property name="selenium_root_url" value="http://localhost:8081/"/>
- <property name="selenium_timeout" value="20000"/>
-
- <property name="selenium_firefox_id" value="*firefox"/>
- <property name="selenium_ie_id" value="*iexplore"/>
- <property name="selenium_chrome_id" value="*googlechrome"/>
- <property name="selenium_safari_id" value="*safari"/>
-
- <!-- classpath configuration stuff -->
- <path id="rhino-classpath" location="${lib-java}/js.jar"/>
- <path id="closure-classpath" location="${lib-js}/requirejs/build/lib/closure/compiler.jar"/>
-
- <path id="xslt-processor-classpath" location="${lib-java}/xalan.jar"/>
-
- <path id="requirejs_bootstrap_paths">
- <pathelement location="${lib-js}/requirejs/require.js"/>
- <pathelement location="${lib-js}/requirejs/require/rhino.js"/>
- <pathelement location="${lib-js}/requirejs/require/text.js"/>
- <pathelement location="${lib-js}/requirejs/require/xml.js"/>
- </path>
-
- <property name="path_to_dojo_base" location="${lib-test-js}/dojo-release-1.4.2-src/dojo"/>
- <property name="path_to_dojo" value="${path_to_dojo_base}/dojo.js"/>
-
- <path id="scxml-js-compiler-classpath">
- <path refid="rhino-classpath"/>
- <pathelement location="${lib-java}/commons-cli.jar"/>
- <pathelement location="${lib-java}/serializer.jar"/>
- <pathelement location="${lib-java}/xalan.jar"/>
- <pathelement location="${lib-java}/xercesImpl.jar"/>
- <pathelement location="${lib-java}/xml-apis.jar"/>
- <pathelement location="build/scxml-js.jar"/><!--FIXME-->
- </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">
- <mkdir dir="${build}"/>
- </target>
-
- <macrodef name="rhinoscript">
- <text name="text"/>
-
- <sequential>
- <!-- TODO: update classpath here -->
- <script language="javascript" manager="bsf">
- <classpath>
- <fileset dir="${lib-java}/" includes="js.jar"/>
- <fileset dir="lib/build-java/" includes="*.jar"></fileset>
- <fileset dir="${lib-test-java}/" includes="*.jar"></fileset>
- </classpath><![CDATA[
- var shell = org.mozilla.javascript.tools.shell.Main;
- var args = ["-e","var a='STRING';"];
- shell.exec(args);
-
- var shellGlobal = shell.global;
-
- //grab functions from shell global and place in current global
- var load=shellGlobal.load;
- var print=shellGlobal.print;
- var defineClass=shellGlobal.defineClass;
- var deserialize=shellGlobal.deserialize;
- var doctest=shellGlobal.doctest;
- var gc=shellGlobal.gc;
- var help=shellGlobal.help;
- var loadClass=shellGlobal.loadClass;
- var quit=shellGlobal.quit;
- var readFile=shellGlobal.readFile;
- var readUrl=shellGlobal.readUrl;
- var runCommand=shellGlobal.runCommand;
- var seal=shellGlobal.seal;
- var serialize=shellGlobal.serialize;
- var spawn=shellGlobal.spawn;
- var sync=shellGlobal.sync;
- var toint32=shellGlobal.toint32;
- var version=shellGlobal.version;
- var environment=shellGlobal.environment;
-
- var console ={
- log : print,
- debug : print
- }
-
- @{text}
- ]]></script>
- </sequential>
- </macrodef>
-
- <macrodef name="compile-with-scxml-js-ie">
- <attribute name="backend"/>
- <attribute name="test-path"/>
- <attribute name="out-path"/>
-
- <sequential>
- <echo>Compiling @{test-path} to @{out-path} with backend @{backend} and flags for IE...</echo>
-
- <java classname="org.mozilla.javascript.tools.shell.Main" output="@{out-path}">
- <classpath>
- <path refid="scxml-js-compiler-classpath"/>
- </classpath>
-
- <arg value="${basedir}/runner.js"/>
- <arg value="${basedir}"/>
- <arg value="src/javascript/scxml/cgf/main"/>
-
- <arg value="--backend=@{backend}"/>
- <arg value="--beautify"/>
- <arg value="--ie"/>
- <arg value="@{test-path}"/>
- </java>
- </sequential>
- </macrodef>
-
- <macrodef name="compile-with-scxml-js-no-ie">
- <attribute name="backend"/>
- <attribute name="test-path"/>
- <attribute name="out-path"/>
-
- <sequential>
- <echo>Compiling @{test-path} to @{out-path} with backend @{backend}...</echo>
-
- <java classname="org.mozilla.javascript.tools.shell.Main" output="@{out-path}">
- <classpath>
- <path refid="scxml-js-compiler-classpath"/>
- </classpath>
-
- <arg value="${basedir}/runner.js"/>
- <arg value="${basedir}"/>
- <arg value="src/javascript/scxml/cgf/main"/>
-
- <arg value="--backend=@{backend}"/>
- <arg value="--beautify"/>
- <arg value="@{test-path}"/>
- </java>
- </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>
-
- <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>
+ <!-- we could be given this as a parameter -->
+ <property name="maven.ant.tasks.jar" location="lib/java/maven-ant-tasks-2.1.1.jar"/>
- <macrodef name="run-unit-tests-with-selenium-macro">
- <attribute name="unit-tests-html-property-name"/>
-
- <sequential>
- <rhinoscript><![CDATA[
- //TODO: consolidate this code
- function unitTestWithSelenium(sel,url,timeout){
- sel.open(url);
-
- sel.waitForPageToLoad("5000");
-
- // wait for all the tests to finish
- sel.waitForCondition("window.dohIsComplete", timeout );
-
- // get the results
- var testCount = Number(sel.getEval("window.doh._testCount"));
- var failCount = Number(sel.getEval("window.doh._failureCount"));
- var errorCount = Number(sel.getEval("window.doh._errorCount"));
-
- return {
- testCount:testCount,
- failCount:failCount,
- errorCount:errorCount,
- testsPassed:(testCount - failCount - errorCount)
- };
- }
-
- print("Running Selenium unit tests...");
-
- var unitTestResults = [];
-
- browsers.split(",").forEach(function(browserName){
-
- print("Running test for " + browserName + "...");
-
- var browserId = project.getProperty("selenium_" + browserName + "_id");
-
- var bSel = new Packages.com.thoughtworks.selenium.DefaultSelenium(selenium_host, selenium_port, browserId, selenium_root_url);
-
- print("bSel",bSel);
-
- bSel.start();
-
- //list comprehension to get the cartesian product
- var configurations = [{forIE:forIE,backend:backend,testPath:testPath}
- for each (forIE in project.getProperty("for-ie").split(','))
- for each (backend in backends.split(','))
- for each (testPath in Array.prototype.slice.call(scxml_tests_xml.list()))];
-
- //use pattern matching in the parameter
- configurations.forEach(function({forIE:forIE,backend:backend,testPath:testPath}){
-
- print("forIE:"+forIE+","+"backend:"+backend+","+"testPath:"+testPath);
-
- //get path to html test
- //@{for-ie}-@{backend}-@{test-path}-unit-test-html-location
- var unitTestHtmlLocationPropertyName=forIE + "-" + backend + "-" + testPath + "-@{unit-tests-html-property-name}";
- var unitTestHtmlLocation = project.getProperty(unitTestHtmlLocationPropertyName);
-
- print("unitTestHtmlLocation:"+unitTestHtmlLocation);
-
- //ensure we are not testing an ie html test
- //on a non-ie browser
- if(browserName==ie_browser_name && forIE==is_for_ie ||
- browserName!=ie_browser_name && forIE==is_not_for_ie){
-
- var unitTestResult = unitTestWithSelenium(bSel,unitTestHtmlLocation,selenium_timeout);
-
- print("unitTestResult:" + unitTestResult);
-
- var unitTestResultObj = {
- data : unitTestResult,
- browser : browserName,
- scxmlTest : testPath,
- backend : backend
- };
-
- unitTestResults.push(unitTestResultObj);
-
- //report errors and failures that may occur
- if(unitTestResult.failCount || unitTestResult.errorCount){
- print("UNIT TEST ERROR");
- //TODO: add better error handling here that integrates with Ant
- }
-
- }
- });
+ <path id="path-to-maven-ant-tasks" path="${maven.ant.tasks.jar}"/>
- bSel.stop();
- });
+ <!-- oh shit. we can't use the typdef if we don't know th epath to the jar
+ and we can't know the path to the jar without the typdef. therefore we are screwed...
+ I think we must take it as an argument. No other way to bootstrap it. That is, if we want to download
+ it with maven, which I think that we do... -->
+ <typedef resource="org/apache/maven/artifact/ant/antlib.xml"
+ uri="antlib:org.apache.maven.artifact.ant"
+ classpathref="path-to-maven-ant-tasks" />
+
+ <artifact:pom id="mypom" file="pom.xml" />
+ <artifact:dependencies pathId="maven.compile.classpath" pomRefId="mypom" />
+
+ <!-- TODO: try and read the plugin dependencies -->
+ <artifact:dependencies pathId="maven.plugin.classpath">
+ <artifact:dependency groupId="bsf" artifactId="bsf" version="2.4.0"/>
+ <artifact:dependency groupId="commons-logging" artifactId="commons-logging" version="1.1.1"/>
+ <artifact:dependency groupId="ant-contrib" artifactId="ant-contrib" version="1.0b3">
+ <artifact:exclusion groupId="ant" artifactId="ant"/>
+ </artifact:dependency>
+ <!--<artifact:dependency groupId="org.apache.maven" artifactId="maven-ant-tasks" version="2.1.1"/>-->
+ <artifact:dependency groupId="xalan" artifactId="xalan" version="2.7.0"/>
+ </artifact:dependencies>
+
+ <!-- this is how we get data in. kind of weird -->
+ <property name="compile_classpath" refid="maven.compile.classpath"/>
+ <property name="plugin_classpath" refid="maven.plugin.classpath"/>
- var totalTests = unitTestResults.reduce(function(a,b){return a + b.data.testCount},0);
- var totalTestsFailed = unitTestResults.reduce(function(a,b){return a + b.data.errorCount},0);
- var totalTestsErrored = unitTestResults.reduce(function(a,b){return a + b.data.failCount},0);
- var totalTestsPassed = unitTestResults.reduce(function(a,b){return a + b.data.testsPassed},0);
-
- print("Test Results:");
- print("Total Tests: " + totalTests);
- print("Total Tests Failed: " + totalTestsFailed);
- print("Total Tests Errored: " + totalTestsErrored);
- print("Total Tests Passed: " + totalTestsPassed);
- ]]></rhinoscript>
- </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>
-
- <target name="setup-properties">
-
- <for param="test-path">
- <path refid="scxml_tests_xml"/>
- <sequential>
- <!-- for generate-unit-tests-html task -->
-
- <!-- 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 -->
- <!-- remove basedir, then remove first slash if there is one, then do other manipulations -->
- <pathconvert property="@{test-path}-unit-test-js-module">
- <path location="${@{test-path}-dir}"/>
- <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="*" to="*/scripts/unitTest"/>
- </chainedmapper>
- </pathconvert>
-
-
- <!-- 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>
-
-
- <for list="${for-ie}" param="for-ie">
- <sequential>
- <for list="${backends}" param="backend">
- <sequential>
- <for param="test-path">
- <path refid="scxml_tests_xml"/>
- <sequential>
-
- <!-- for generate-javascript task -->
-
- <!-- do some manipulation -->
- <pathconvert property="@{for-ie}-@{backend}-@{test-path}-target-test-path">
- <path path="@{test-path}"/>
- <chainedmapper>
- <flattenmapper/>
- <globmapper from="*.xml" to="${build}${file.separator}generate-javascript${file.separator}@{for-ie}${file.separator}@{backend}${file.separator}*.js" handledirsep="true"/>
- </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}"/>
-
- <!-- for generate-unit-tests-html task -->
-
- <!-- 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}"/>
- <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-unit-tests-html/*.html" handledirsep="true"/>
- </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">
- <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}/*" to="../../../*" handledirsep="true"/>
- </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>
- </for>
- </sequential>
- </for>
+ <import file="mvn-ant-build.xml"/>
+ <!--
+ <target name="test">
+ <property name="test.plugin.classpath" refid="maven.plugin.classpath"/>
+ <echo>${test.plugin.classpath}</echo>
+ <property name="test.compile.classpath" refid="maven.compile.classpath"/>
+ <echo>${test.compile.classpath}</echo>
</target>
+ -->
<!-- run unit and performance tests -->
<target name="generate-javascript" depends="preprocess-stylesheets,setup-properties">
@@ -736,6 +167,7 @@
unit-tests-html-property-name="in-browser-unit-test-html-location"/>
</target>
+ <!-- TODO: move rhino unit tests up -->
<target name="run-unit-tests-with-rhino" depends="generate-javascript">
<rhinoscript><![CDATA[
//load requirejs
@@ -829,52 +261,10 @@
<!-- build standalone executable -->
+ <!-- delegate appropriately to the standalone maven tasks -->
+ <target name="compile-single-js" depends="compile-single-js-mvn"/>
- <property name="build-js-main" location="${build-js}/main-built.js"/>
- <property name="build-class-main-name" value="SCXMLCompiler"/>
- <property name="build-class-main" location="${build-class}/${build-class-main-name}.class"/>
- <property name="build-jar-main" location="${build-jar}/scxml-js.jar"/>
-
- <property name="build-js-main-rhino-frontend-module" value="${src}/javascript/scxml/cgf/build/rhino"/>
-
- <property name="js-build-script" location="${lib-js}/requirejs/build/build.js"/>
- <property name="js-build-dir" location="${lib-js}/requirejs/build"/>
-
- <property name="test" location="test"/>
-
- <target name="compile-single-js" depends="preprocess-stylesheets">
- <mkdir dir="${build-js}"/>
-
- <java classname="org.mozilla.javascript.tools.shell.Main">
- <classpath>
- <path refid="rhino-classpath"/>
- <path refid="closure-classpath"/>
- </classpath>
- <arg value="${js-build-script}"/>
- <arg value="${js-build-dir}"/>
- <arg value="name=${build-js-main-rhino-frontend-module}"/>
- <arg value="out=${build-js-main}"/>
- <arg value="baseUrl=."/>
- <arg value="includeRequire=true"/>
- <arg value="inlineText=true"/>
- <arg value="optimize=none"/>
- </java>
- </target>
-
- <target name="compile-single-class" depends="compile-single-js">
- <mkdir dir="${build-class}"/>
-
- <!-- TODO: set -opt -->
- <java classname="org.mozilla.javascript.tools.jsc.Main">
- <classpath>
- <path refid="rhino-classpath"/>
- </classpath>
- <arg value="-o"/>
- <arg value="${build-class-main-name}.class"/>
- <arg value="${build-js-main}"/>
- </java>
- <move file="${build-js}/${build-class-main-name}.class" todir="${build-class}"/>
- </target>
+ <target name="compile-single-class" depends="compile-single-js,compile-single-class-mvn"/>
<target name="jar-single-class" depends="compile-single-class">
<mkdir dir="${build-jar}"/>
@@ -888,32 +278,5 @@
</jar>
</target>
- <!-- these targets are here to do a simple test of the compiled jar and class-->
- <target name="run-single-class" depends="compile-single-class">
- <java classname="${build-class-main-name}" output="${build}/out.js">
- <classpath>
- <path refid="scxml-js-compiler-classpath"/>
- <pathelement location="${build-class}"/>
- </classpath>
- <arg value="--backend"/>
- <arg value="state"/>
- <arg value="--beautify"/>
- <arg value="test/parallel/TestParallel.xml"/>
- </java>
- </target>
-
- <target name="run-single-jar" depends="jar-single-class">
- <java classname="${build-class-main-name}" output="${build}/out.js">
- <classpath>
- <path refid="scxml-js-compiler-classpath"/>
- <pathelement location="${build-jar-main}"/>
- </classpath>
- <arg value="--backend"/>
- <arg value="state"/>
- <arg value="--beautify"/>
- <arg value="test/parallel/TestParallel.xml"/>
- </java>
- </target>
-
</project>
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/mvn-ant-build.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/mvn-ant-build.xml?rev=993579&r1=993578&r2=993579&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/mvn-ant-build.xml (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/mvn-ant-build.xml Wed Sep 8 02:09:55 2010
@@ -15,910 +15,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
-->
-<project name="scxml-js" basedir="." default="run-all-unit-tests">
-
- <path location="${compile_classpath}" id="maven.compile.classpath"/>
- <path location="${runtime_classpath}" id="maven.runtime.classpath"/>
- <path location="${test_classpath}" id="maven.test.classpath"/>
- <path location="${plugin_classpath}" id="maven.plugin.classpath"/>
-
- <taskdef resource="net/sf/antcontrib/antcontrib.properties">
- <classpath>
- <path refid="maven.plugin.classpath" />
- </classpath>
- </taskdef>
-
- <!-- location properties -->
- <property name="src" value="src"/>
-
- <property name="lib" location="lib"/>
- <property name="lib-java" location="${lib}/java"/>
- <property name="lib-js" location="${lib}/js"/>
- <property name="lib-test-java" location="${lib}/test-java"/>
- <property name="lib-test-js" location="${lib}/test-js"/>
-
- <property name="build" value="target"/>
- <property name="build-js" location="${build}/build-js"/>
- <property name="build-class" location="${build}/classes"/>
- <property name="build-jar" location="${build}/jar"/>
-
-
- <property name="ie_browser_name" value="ie"/>
-
- <property name="is_for_ie" value="is-for-ie"/>
- <property name="is_not_for_ie" value="is-not-for-ie"/>
-
- <property name="backends" value="switch,table,state"/>
- <!--
- <property name="backends" value="switch"/>
- -->
- <property name="browsers" value="firefox,chrome"/>
- <!--
- <property name="browsers" value="firefox,${ie_browser_name},chrome"/>
- -->
- <property name="for-ie" value="${is_for_ie},${is_not_for_ie}"/>
-
- <!-- selenium configuration options -->
- <property name="selenium_host" value="localhost"/>
- <property name="selenium_port" value="4444"/>
- <property name="selenium_root_url" value="http://localhost:8081/"/>
- <property name="selenium_timeout" value="20000"/>
-
- <property name="selenium_firefox_id" value="*firefox"/>
- <property name="selenium_ie_id" value="*iexplore"/>
- <property name="selenium_chrome_id" value="*googlechrome"/>
- <property name="selenium_safari_id" value="*safari"/>
-
- <!-- classpath configuration stuff -->
- <property name="lib-rhino" location="${lib-java}/js.jar"/>
- <path id="rhino-classpath" location="${lib-rhino}" />
- <path id="closure-classpath" location="${lib-js}/requirejs/build/lib/closure/compiler.jar"/>
-
- <path id="requirejs_bootstrap_paths">
- <pathelement location="${lib-js}/requirejs/require.js"/>
- <pathelement location="${lib-js}/requirejs/require/rhino.js"/>
- <pathelement location="${lib-js}/requirejs/require/text.js"/>
- <pathelement location="${lib-js}/requirejs/require/xml.js"/>
- </path>
-
- <property name="path_to_dojo_base" location="${lib-test-js}/dojo-release-1.4.2-src/dojo"/>
- <property name="path_to_dojo" value="${path_to_dojo_base}/dojo.js"/>
-
- <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>
-
- <property name="drawing-tool-lib" value="demo/drawing-tool/lib"/>
- <property name="tmp-dir" value="tmp"/>
-
- <property name="require-js-lib" value="${lib-js}/requirejs"/>
- <property name="dojo-js-lib" value="${lib-test-js}/dojo-release-1.4.2-src"/>
- <property name="jquery-svg-js-lib" value="${drawing-tool-lib}/jquery.svg.js"/>
-
- <!--
- <available property="require-js-lib-available" file="${require-js-lib}" type="dir"/>
- <available property="dojo-js-lib-available" file="${dojo-js-lib}" type="dir"/>
- <available property="jquery-svg-js-lib-available" file="${jquery-svg-js-lib}" type="file"/>
- <available property="rhino-available" filepath="rhino-classpath"/>
- -->
-
-
- <target name="download-dependencies">
- <mkdir dir="${tmp-dir}"/>
-
- <if>
- <not>
- <available file="${require-js-lib}/require.js" type="file"/>
- </not>
-
- <then>
- <echo>Downloading RequireJS...</echo>
-
- <get dest="${tmp-dir}/requirejs-0.11.0.zip" usetimestamp="true" ignoreerrors="true" src="http://requirejs.org/docs/release/0.11.0/requirejs-0.11.0.zip"/>
- <unzip src="${tmp-dir}/requirejs-0.11.0.zip" dest="${lib-js}"/>
- <move file="${lib-js}/requirejs-0.11.0" tofile="${lib-js}/requirejs"/>
- <delete file="${lib-js}/requirejs-0.11.0.zip"/>
- </then>
- <else>
- <echo>RequireJS up-to-date</echo>
- </else>
- </if>
-
-
- <if>
- <not>
- <available file="${dojo-js-lib}" type="dir"/>
- </not>
-
- <then>
- <echo>Downloading dojo...</echo>
-
- <get dest="${tmp-dir}/dojo-release-1.4.2-src.zip" usetimestamp="true" ignoreerrors="true" src="http://download.dojotoolkit.org/release-1.4.2/dojo-release-1.4.2-src.zip"/>
- <unzip src="${tmp-dir}/dojo-release-1.4.2-src.zip" dest="${lib-test-js}"/>
- </then>
- <else>
- <echo>Dojo up-to-date</echo>
- </else>
- </if>
-
-
-
- <if>
- <not>
- <available file="${jquery-svg-js-lib}" type="file"/>
- </not>
-
- <then>
- <echo>Downloading jQuery SVG...</echo>
-
- <delete dir="${drawing-tool-lib}" failonerror="false"/>
- <mkdir dir="${drawing-tool-lib}"/>
- <get dest="${drawing-tool-lib}/jquery-1.4.2.js" usetimestamp="true" ignoreerrors="true" src="http://code.jquery.com/jquery-1.4.2.js"/>
- <get dest="${tmp-dir}/jquery.svg.package-1.4.3.zip" usetimestamp="true" ignoreerrors="true" src="http://keith-wood.name/zip/jquery.svg.package-1.4.3.zip"/>
- <unzip src="${tmp-dir}/jquery.svg.package-1.4.3.zip" dest="${drawing-tool-lib}"/>
- </then>
- <else>
- <echo>jQuery SVG up to date</echo>
- </else>
- </if>
-
-
-
- <!-- latest rhino -->
- <if>
- <not>
- <available file="${lib-rhino}"/>
- </not>
-
- <then>
- <echo>Downloading Rhino...</echo>
- <get dest="${tmp-dir}/rhino1_7R3pre.zip" usetimestamp="true" ignoreerrors="true" src="ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino1_7R3pre.zip"/>
- <unzip src="${tmp-dir}/rhino1_7R3pre.zip" dest="${tmp-dir}"/>
- <copy file="${tmp-dir}/rhino1_7R3pre/js.jar" tofile="${lib-java}/js.jar"/>
- </then>
- <else>
- <echo>Rhino up-to-date</echo>
- </else>
- </if>
-
- <delete dir="${tmp-dir}"/>
- </target>
-
- <target name="clean">
- <delete dir="${build}"/>
- </target>
-
- <target name="init">
- <mkdir dir="${build}"/>
- </target>
-
- <macrodef name="rhinoscript">
- <text name="text"/>
-
- <sequential>
- <!-- TODO: update classpath here -->
- <script language="javascript" manager="bsf">
- <classpath>
- <path refid="rhino-classpath"/>
- <path refid="maven.plugin.classpath"/>
- </classpath><![CDATA[
- var shell = org.mozilla.javascript.tools.shell.Main;
- var args = ["-e","var a='STRING';"];
- shell.exec(args);
-
- var shellGlobal = shell.global;
-
- //grab functions from shell global and place in current global
- var load=shellGlobal.load;
- var print=shellGlobal.print;
- var defineClass=shellGlobal.defineClass;
- var deserialize=shellGlobal.deserialize;
- var doctest=shellGlobal.doctest;
- var gc=shellGlobal.gc;
- var help=shellGlobal.help;
- var loadClass=shellGlobal.loadClass;
- var quit=shellGlobal.quit;
- var readFile=shellGlobal.readFile;
- var readUrl=shellGlobal.readUrl;
- var runCommand=shellGlobal.runCommand;
- var seal=shellGlobal.seal;
- var serialize=shellGlobal.serialize;
- var spawn=shellGlobal.spawn;
- var sync=shellGlobal.sync;
- var toint32=shellGlobal.toint32;
- var version=shellGlobal.version;
- var environment=shellGlobal.environment;
-
- var console ={
- log : print,
- debug : print
- }
-
- @{text}
- ]]></script>
- </sequential>
- </macrodef>
-
- <macrodef name="compile-with-scxml-js-ie">
- <attribute name="backend"/>
- <attribute name="test-path"/>
- <attribute name="out-path"/>
-
- <sequential>
- <echo>Compiling @{test-path} to @{out-path} with backend @{backend} and flags for IE...</echo>
-
- <java classname="org.mozilla.javascript.tools.shell.Main" output="@{out-path}">
- <classpath>
- <path refid="rhino-classpath"/>
- <path refid="maven.compile.classpath"/>
- </classpath>
-
- <arg value="${basedir}/runner.js"/>
- <arg value="${basedir}"/>
- <arg value="src/javascript/scxml/cgf/main"/>
-
- <arg value="--backend=@{backend}"/>
- <arg value="--beautify"/>
- <arg value="--ie"/>
- <arg value="@{test-path}"/>
- </java>
- </sequential>
- </macrodef>
-
- <macrodef name="compile-with-scxml-js-no-ie">
- <attribute name="backend"/>
- <attribute name="test-path"/>
- <attribute name="out-path"/>
-
- <sequential>
- <echo>Compiling @{test-path} to @{out-path} with backend @{backend}...</echo>
-
- <java classname="org.mozilla.javascript.tools.shell.Main" output="@{out-path}">
- <classpath>
- <path refid="rhino-classpath"/>
- <path refid="maven.compile.classpath"/>
- </classpath>
-
- <arg value="${basedir}/runner.js"/>
- <arg value="${basedir}"/>
- <arg value="src/javascript/scxml/cgf/main"/>
-
- <arg value="--backend=@{backend}"/>
- <arg value="--beautify"/>
- <arg value="@{test-path}"/>
- </java>
- </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>
-
- <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>
-
- <macrodef name="run-unit-tests-with-selenium-macro">
- <attribute name="unit-tests-html-property-name"/>
-
- <sequential>
- <rhinoscript><![CDATA[
- //TODO: consolidate this code
- function unitTestWithSelenium(sel,url,timeout){
- sel.open(url);
-
- sel.waitForPageToLoad("5000");
-
- // wait for all the tests to finish
- sel.waitForCondition("window.dohIsComplete", timeout );
-
- // get the results
- var testCount = Number(sel.getEval("window.doh._testCount"));
- var failCount = Number(sel.getEval("window.doh._failureCount"));
- var errorCount = Number(sel.getEval("window.doh._errorCount"));
-
- return {
- testCount:testCount,
- failCount:failCount,
- errorCount:errorCount,
- testsPassed:(testCount - failCount - errorCount)
- };
- }
-
- print("Running Selenium unit tests...");
-
- var unitTestResults = [];
-
- browsers.split(",").forEach(function(browserName){
-
- print("Running test for " + browserName + "...");
-
- var browserId = project.getProperty("selenium_" + browserName + "_id");
-
- var bSel = new Packages.com.thoughtworks.selenium.DefaultSelenium(selenium_host, selenium_port, browserId, selenium_root_url);
-
- print("bSel",bSel);
-
- bSel.start();
-
- //list comprehension to get the cartesian product
- var configurations = [{forIE:forIE,backend:backend,testPath:testPath}
- for each (forIE in project.getProperty("for-ie").split(','))
- for each (backend in backends.split(','))
- for each (testPath in Array.prototype.slice.call(scxml_tests_xml.list()))];
-
- //use pattern matching in the parameter
- configurations.forEach(function({forIE:forIE,backend:backend,testPath:testPath}){
-
- print("forIE:"+forIE+","+"backend:"+backend+","+"testPath:"+testPath);
-
- //get path to html test
- //@{for-ie}-@{backend}-@{test-path}-unit-test-html-location
- var unitTestHtmlLocationPropertyName=forIE + "-" + backend + "-" + testPath + "-@{unit-tests-html-property-name}";
- var unitTestHtmlLocation = project.getProperty(unitTestHtmlLocationPropertyName);
-
- print("unitTestHtmlLocation:"+unitTestHtmlLocation);
-
- //ensure we are not testing an ie html test
- //on a non-ie browser
- if(browserName==ie_browser_name && forIE==is_for_ie ||
- browserName!=ie_browser_name && forIE==is_not_for_ie){
-
- var unitTestResult = unitTestWithSelenium(bSel,unitTestHtmlLocation,selenium_timeout);
-
- print("unitTestResult:" + unitTestResult);
-
- var unitTestResultObj = {
- data : unitTestResult,
- browser : browserName,
- scxmlTest : testPath,
- backend : backend
- };
-
- unitTestResults.push(unitTestResultObj);
-
- //report errors and failures that may occur
- if(unitTestResult.failCount || unitTestResult.errorCount){
- print("UNIT TEST ERROR");
- //TODO: add better error handling here that integrates with Ant
- }
-
- }
- });
-
- bSel.stop();
- });
-
- var totalTests = unitTestResults.reduce(function(a,b){return a + b.data.testCount},0);
- var totalTestsFailed = unitTestResults.reduce(function(a,b){return a + b.data.errorCount},0);
- var totalTestsErrored = unitTestResults.reduce(function(a,b){return a + b.data.failCount},0);
- var totalTestsPassed = unitTestResults.reduce(function(a,b){return a + b.data.testsPassed},0);
-
- print("Test Results:");
- print("Total Tests: " + totalTests);
- print("Total Tests Failed: " + totalTestsFailed);
- print("Total Tests Errored: " + totalTestsErrored);
- print("Total Tests Passed: " + totalTestsPassed);
- ]]></rhinoscript>
- </sequential>
- </macrodef>
-
- <target name="preprocess-stylesheets" depends="init">
- <xslt
- classpathref="maven.compile.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>
-
- <target name="setup-properties">
-
- <for param="test-path">
- <path refid="scxml_tests_xml"/>
- <sequential>
- <!-- for generate-unit-tests-html task -->
-
- <!-- 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 -->
- <!-- remove basedir, then remove first slash if there is one, then do other manipulations -->
- <pathconvert property="@{test-path}-unit-test-js-module">
- <path location="${@{test-path}-dir}"/>
- <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="*" to="*/scripts/unitTest"/>
- </chainedmapper>
- </pathconvert>
-
-
- <!-- 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>
-
-
- <for list="${for-ie}" param="for-ie">
- <sequential>
- <for list="${backends}" param="backend">
- <sequential>
- <for param="test-path">
- <path refid="scxml_tests_xml"/>
- <sequential>
-
- <!-- for generate-javascript task -->
-
- <!-- do some manipulation -->
- <pathconvert property="@{for-ie}-@{backend}-@{test-path}-target-test-path">
- <path path="@{test-path}"/>
- <chainedmapper>
- <flattenmapper/>
- <globmapper from="*.xml" to="${build}${file.separator}generate-javascript${file.separator}@{for-ie}${file.separator}@{backend}${file.separator}*.js" handledirsep="true"/>
- </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}"/>
-
- <!-- for generate-unit-tests-html task -->
-
- <!-- 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}"/>
- <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-unit-tests-html/*.html" handledirsep="true"/>
- </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">
- <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}/*" to="../../../*" handledirsep="true"/>
- </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>
- </for>
- </sequential>
- </for>
-
- </target>
-
- <!-- run unit and performance tests -->
- <target name="generate-javascript" depends="preprocess-stylesheets,setup-properties">
- <mkdir dir="${build}/generate-javascript"/>
-
- <for list="${for-ie}" param="for-ie">
- <sequential>
- <for list="${backends}" param="backend">
- <sequential>
- <for param="test-path">
- <path refid="scxml_tests_xml"/>
- <sequential>
-
- <echo>${@{for-ie}-@{backend}-@{test-path}-target-test-path}, ${@{for-ie}-@{backend}-@{test-path}-target-test-path-dir}</echo>
-
- <mkdir dir="${@{for-ie}-@{backend}-@{test-path}-target-test-path-dir}"/>
-
- <if>
- <equals arg1="@{for-ie}" arg2="is-for-ie"/>
- <then>
- <compile-with-scxml-js-ie
- test-path="@{test-path}"
- backend="@{backend}"
- out-path="${@{for-ie}-@{backend}-@{test-path}-target-test-path}"/>
- </then>
- <else>
- <compile-with-scxml-js-no-ie
- test-path="@{test-path}"
- backend="@{backend}"
- out-path="${@{for-ie}-@{backend}-@{test-path}-target-test-path}"/>
- </else>
- </if>
- </sequential>
- </for>
- </sequential>
- </for>
- </sequential>
- </for>
- </target>
-
- <target name="generate-unit-test-html" depends="setup-properties">
- <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>
-
- <echo>${@{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="${@{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="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">
- <run-unit-tests-with-selenium-macro
- unit-tests-html-property-name="unit-test-html-location"/>
- </target>
-
-
- <target name="run-in-browser-unit-tests-with-selenium" depends="preprocess-stylesheets,generate-in-browser-unit-test-html">
- <run-unit-tests-with-selenium-macro
- unit-tests-html-property-name="in-browser-unit-test-html-location"/>
- </target>
-
- <target name="run-unit-tests-with-rhino" depends="generate-javascript">
- <rhinoscript><![CDATA[
- //load requirejs
- Array.prototype.slice.call(requirejs_bootstrap_paths.list()).forEach(function(requireJsPath){
- load(requireJsPath);
- });
-
-
- //this is a bit weird, but we define this here in case we need to load dojo later using the RequireJS loader
- djConfig = {
- "baseUrl" : path_to_dojo_base+"/"
- }
-
- function tailRecurse(list,stepCallback,baseCaseCallback){
- var target = list.pop();
-
- if(target){
- stepCallback(target,
- function(){tailRecurse(list,stepCallback,baseCaseCallback)});
- }else{
- if(baseCaseCallback) baseCaseCallback();
- }
- }
-
- var isComplete = false;
-
- require(
- {baseUrl:basedir},
- [path_to_dojo,
- "lib/test-js/env.js",
- "test/testHelpers.js"],
- function(){
-
- dojo.require("doh.runner");
-
- var forIE = "is-for-ie";
- var scxmlXmlTestPathList = Array.prototype.slice.call(scxml_tests_xml.list());
- var backendsList = backends.split(",");
-
- var oldDohOnEnd = doh._onEnd;
- doh._onEnd = function() { isComplete = true; oldDohOnEnd.apply(doh); };
-
- //we use tailRecurse function because of asynchronous RequireJS call used to load the unit test module
- tailRecurse(scxmlXmlTestPathList,
- function(scxmlXmlTestPath,step){
- var jsUnitTestPathPropertyName = scxmlXmlTestPath + "-" + "unit-test-js-module";
- var jsUnitTestPath = project.getProperty(jsUnitTestPathPropertyName);
-
- require([jsUnitTestPath],
- function(unitTestModule){
-
- var jsUnitTestPathPropertyNames =
- [{forIE:forIE, backend:backend,test_path:scxmlXmlTestPath}
- for each (backend in backendsList)];
-
- jsUnitTestPathPropertyNames.forEach(function(target){
-
- var jsTargetTestPathPropertyName =
- target.forIE + "-" + target.backend + "-" + target.test_path + "-" + "target-test-path";
- var jsTargetTestPath = project.getProperty(jsTargetTestPathPropertyName);
-
- //load and register
- load(jsTargetTestPath);
-
- unitTestModule.register(StatechartExecutionContext)
- delete StatechartExecutionContext;
- })
-
- step();
- });
- },
- function(){
- //run with dojo
- doh.run();
- }
- );
-
- }
- );
-
- //hold up execution until doh completes
- while(!isComplete){
- java.lang.Thread.sleep(20);
- }
-
- ]]></rhinoscript>
- </target>
-
- <target name="run-all-unit-tests"
- depends="run-unit-tests-with-selenium,run-in-browser-unit-tests-with-selenium,run-unit-tests-with-rhino" />
+<project name="scxml-js-mvn" basedir=".">
+ <import file="build-common.xml"/>
<!-- build standalone executable -->
@@ -934,7 +33,7 @@
<property name="test" location="test"/>
- <target name="compile-single-js" depends="preprocess-stylesheets">
+ <target name="compile-single-js-mvn" depends="preprocess-stylesheets">
<mkdir dir="${build-js}"/>
<java classname="org.mozilla.javascript.tools.shell.Main">
@@ -955,7 +54,7 @@
<!-- normally dependency would be set here, but to better integrate with maven, it has been removed -->
<!-- TODO: break this out into a macro to allow better code reuse for non-mave ant frontend -->
- <target name="compile-single-class">
+ <target name="compile-single-class-mvn">
<mkdir dir="${build-class}"/>
<!-- TODO: set -opt -->
@@ -972,46 +71,6 @@
<move file="${build-js}/${build-class-main-name}.class" todir="${build-class}"/>
</target>
- <!-- normally dependency would be set here, but to better integrate with maven, it has been removed -->
- <!-- TODO: break this out into a macro to allow better code reuse for non-mave ant frontend -->
- <target name="jar-single-class">
- <mkdir dir="${build-jar}"/>
-
- <jar destfile="${build-jar-main}"
- basedir="${build-class}"
- includes="${build-class-main-name}.class">
- <manifest>
- <attribute name="Main-Class" value="${build-class-main-name}" />
- </manifest>
- </jar>
- </target>
-
- <!-- these targets are here to do a simple test of the compiled jar and class-->
- <target name="run-single-class" depends="compile-single-class">
- <java classname="${build-class-main-name}" output="${build}/out.js">
- <classpath>
- <path refid="maven.compile.classpath"/>
- <pathelement location="${build-class}"/>
- </classpath>
- <arg value="--backend"/>
- <arg value="state"/>
- <arg value="--beautify"/>
- <arg value="test/parallel/TestParallel.xml"/>
- </java>
- </target>
-
- <target name="run-single-jar" depends="jar-single-class">
- <java classname="${build-class-main-name}" output="${build}/out.js">
- <classpath>
- <path refid="maven.compile.classpath"/>
- <pathelement location="${build-jar-main}"/>
- </classpath>
- <arg value="--backend"/>
- <arg value="state"/>
- <arg value="--beautify"/>
- <arg value="test/parallel/TestParallel.xml"/>
- </java>
- </target>
</project>
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/pom.xml?rev=993579&r1=993578&r2=993579&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/pom.xml (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/pom.xml Wed Sep 8 02:09:55 2010
@@ -198,7 +198,7 @@
<property name="test_classpath" refid="maven.test.classpath"/>
<property name="plugin_classpath" refid="maven.plugin.classpath"/>
- <ant target="compile-single-js" inheritRefs="true" antfile="mvn-ant-build.xml"/>
+ <ant target="compile-single-js-mvn" inheritRefs="true" antfile="mvn-ant-build.xml"/>
</tasks>
</configuration>
<goals>
@@ -215,7 +215,7 @@
<property name="test_classpath" refid="maven.test.classpath"/>
<property name="plugin_classpath" refid="maven.plugin.classpath"/>
- <ant target="compile-single-class" inheritRefs="true" antfile="mvn-ant-build.xml"/>
+ <ant target="compile-single-class-mvn" inheritRefs="true" antfile="mvn-ant-build.xml"/>
</tasks>
</configuration>
<goals>
@@ -245,6 +245,14 @@
</exclusion>
</exclusions>
</dependency>
+ <!-- FIXME: this dependency was breaking the build somehow -->
+ <!--
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-ant-tasks</artifactId>
+ <version>2.1.1</version>
+ </dependency>
+ -->
<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>