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:04 UTC

svn commit: r988275 - /commons/sandbox/gsoc/2010/scxml-js/trunk/build.xml

Author: jbeard
Date: Mon Aug 23 19:45:04 2010
New Revision: 988275

URL: http://svn.apache.org/viewvc?rev=988275&view=rev
Log:
Fixed previous check-in. Asynchronous behaviour required blocking while loop.

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=988275&r1=988274&r2=988275&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:04 2010
@@ -223,6 +223,21 @@
 	</target>
 
 	<target name="setup-properties">
+
+		<for param="test-path">
+			<path refid="scxml_tests_xml"/>
+			<sequential>
+				<dirname property="@{test-path}-dir" file="@{test-path}"/>
+
+				<!-- convert to relative path -->
+				<pathconvert property="@{test-path}-unit-test-js-module">
+					<path location="${@{test-path}-dir}"/>
+					<globmapper from="${basedir}/*" to="*/scripts/unitTest"/>
+				</pathconvert>
+			</sequential>
+		</for>
+
+
 		<for list="${for-ie}" param="for-ie">
 			<sequential>
 				<for list="${backends}" param="backend">
@@ -248,7 +263,6 @@
 
 								<!-- 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">
@@ -351,7 +365,7 @@
 	<target name="run-unit-tests-with-selenium">
 	</target>
 
-	<target name="run-unit-tests-with-rhino" depends="setup-properties">
+	<target name="run-unit-tests-with-rhino" depends="generate-javascript">
 		<rhinoscript>
 			//load requirejs
 			Array.prototype.slice.call(requirejs_bootstrap_paths.list()).forEach(function(requireJsPath){
@@ -364,9 +378,6 @@
 				"baseUrl" : path_to_dojo_base+"/"
 			}
 
-			//load testing library dependencies
-
-
 			function tailRecurse(list,stepCallback,baseCaseCallback){
 				var target = list.pop();
 				
@@ -378,14 +389,7 @@
 				}
 			}
 
-
-			var forIE = "is-for-ie";
-			var scxmlXmlTestPathList = Array.prototype.slice.call(scxml_tests_xml.list());
-			var backendsList = backends.split(",");
-
-			var jsUnitTestPathPropertyNames = [{forIE:forIE, backend:backend,test_path:test_path}
-								for each (backend in backendsList)
-								for each (test_path in scxmlXmlTestPathList)];
+			var isComplete = false;
 
 			require(
 				{baseUrl:basedir},
@@ -396,35 +400,43 @@
 
 					dojo.require("doh.runner");	
 
-					//we use tailRecurse function because of asynchronous RequireJS call used to load the unit test module
-					tailRecurse(jsUnitTestPathPropertyNames,
-						function(target,step){
+					var forIE = "is-for-ie";
+					var scxmlXmlTestPathList = Array.prototype.slice.call(scxml_tests_xml.list());
+					var backendsList = backends.split(",");
 
-							//get the path to the generated javascript test
-							var jsTargetTestPathPropertyName =  target.forIE + "-" + target.backend + "-" + target.test_path + "-" + "target-test-path";
-							var jsTargetTestPath = project.getProperty(jsTargetTestPathPropertyName);
-						
-							//get the corresponding unit test
-							var jsUnitTestPathPropertyName = target.forIE + "-" + target.backend + "-" + target.test_path + "-" + "unit-test-js-module";
-							var jsUnitTestPath = project.getProperty(jsUnitTestPathPropertyName); 
+					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);
 
-							print(jsTargetTestPath + "," + jsUnitTestPath) 
+							require([jsUnitTestPath],
+								function(unitTestModule){
 
-							//load and register
+									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;
+									}) 
 
-							require(
-								[jsUnitTestPath],
-								function(unitTestModule){
-									load(jsTargetTestPath);
-									unitTestModule.register(StatechartExecutionContext)
-									delete StatechartExecutionContext;
 									step();
-								}) 
-							
+								});
 						},
 						function(){
-							print("here");
 							//run with dojo
 							doh.run();
 						}
@@ -433,6 +445,11 @@
 				}
 			);
 
+			//hold up execution until doh completes
+			while(!isComplete){
+				java.lang.Thread.sleep(20);
+			}
+
 		</rhinoscript>
 	</target>