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/06/19 21:43:26 UTC
svn commit: r956277 - in
/commons/sandbox/gsoc/2010/scxml-js/branches/browser-tests.1.ie: ./
src/javascript/scxml/cgf/backends/js/
Author: jbeard
Date: Sat Jun 19 19:43:26 2010
New Revision: 956277
URL: http://svn.apache.org/viewvc?rev=956277&view=rev
Log:
Intermediate commit. Fixed build script to accomodate compiler async API. Made js compiler backends use preprocessed xsl stylesheets. Will need to incorporate this into the build process later.
Modified:
commons/sandbox/gsoc/2010/scxml-js/branches/browser-tests.1.ie/build.js
commons/sandbox/gsoc/2010/scxml-js/branches/browser-tests.1.ie/src/javascript/scxml/cgf/backends/js/AbstractEnumeratedStatechartGenerator.js
commons/sandbox/gsoc/2010/scxml-js/branches/browser-tests.1.ie/src/javascript/scxml/cgf/backends/js/StateTableStatechartGenerator.js
commons/sandbox/gsoc/2010/scxml-js/branches/browser-tests.1.ie/src/javascript/scxml/cgf/backends/js/SwitchyardStatechartGenerator.js
Modified: commons/sandbox/gsoc/2010/scxml-js/branches/browser-tests.1.ie/build.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/browser-tests.1.ie/build.js?rev=956277&r1=956276&r2=956277&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/browser-tests.1.ie/build.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/browser-tests.1.ie/build.js Sat Jun 19 19:43:26 2010
@@ -185,20 +185,29 @@ require.def("build",
d.mkdir();
},
- genJavaScript : function(){
+ genJavaScript : function(compilerCallback){
this.init();
print("Compiling SCXML files...");
- for (var scxmlTest in scxmlTests){
- //run the build script on the test
- var pathToTest = scxmlTests[scxmlTest];
-
- for(var backend in backends){
+ var compileTargets = [{scxmlTest:scxmlTest,backend:backend}
+ for (scxmlTest in scxmlTests)
+ for (backend in backends)];
- var sc,fpath,label,name;
+ (function compileTarget(compileTargetsList){
+ var target = compileTargetsList.pop();
+ if(target){
+ //do action
- SCXMLCompiler.compile({
+ //run the build script on the test
+ var scxmlTest = target.scxmlTest;
+ var backend = target.backend;
+
+ var pathToTest = scxmlTests[scxmlTest];
+
+ var sc,fpath,label,name;
+
+ SCXMLCompiler.compile({
inFiles:[pathToTest].map(xmlUtil.parseFromPath),
backend:backend,
beautify:true,
@@ -260,53 +269,70 @@ require.def("build",
print("Writing statechart " + scxmlTest + " to " + fpath);
utilFile.writeFile(sc,fpath);
+
+ //recursive callback
+ compileTarget(compileTargetsList);
}
)
}
)
+ }else{
+ //base case
+ if(compilerCallback){
+ compilerCallback();
+ }
}
- }
+
+ })(compileTargets);
+
},
- _genHtml : function(testScripts,htmlGenFn,fileDescriptor,testsGeneratedCollection){
- this.genJavaScript();
+ _genHtml : function(testScripts,htmlGenFn,fileDescriptor,testsGeneratedCollection,callback){
+ this.genJavaScript(function(){
- print("Generating html test files...");
+ print("Generating html test files...");
- testScripts.forEach(function(testScript){
- var testScriptPath = testScript.path;
- var testScriptRelativePath = "../" + testScriptPath;
+ testScripts.forEach(function(testScript){
+ var testScriptPath = testScript.path;
+ var testScriptRelativePath = "../" + testScriptPath;
- scriptsGenerated.
- filter(function(s){return scxmlTests[s.scxmlTest] == testScript.scxmlTest}).
- forEach(function(generatedScript){
+ scriptsGenerated.
+ filter(function(s){return scxmlTests[s.scxmlTest] == testScript.scxmlTest}).
+ forEach(function(generatedScript){
- var testHtml = htmlGenFn(generatedScript.name,testScriptRelativePath);
+ var testHtml = htmlGenFn(generatedScript.name,testScriptRelativePath);
- //write testHtml
- var fpath = buildDir + "/" + fileDescriptor + "_" + generatedScript.scxmlTest + "_" + generatedScript.label + ".html";
+ //write testHtml
+ var fpath = buildDir + "/" + fileDescriptor + "_" + generatedScript.scxmlTest + "_" + generatedScript.label + ".html";
- print("Writing html test file " + fpath);
+ print("Writing html test file " + fpath);
- utilFile.writeFile(testHtml,fpath);
+ utilFile.writeFile(testHtml,fpath);
- //save the path to the html for running in selenium later
- testsGeneratedCollection.push({
- path : fpath,
- scxmlTest : generatedScript.scxmlTest,
- testCasePath : generatedScript.path,
- backend : generatedScript.backend,
- ie : generatedScript.ie
+ //save the path to the html for running in selenium later
+ testsGeneratedCollection.push({
+ path : fpath,
+ scxmlTest : generatedScript.scxmlTest,
+ testCasePath : generatedScript.path,
+ backend : generatedScript.backend,
+ ie : generatedScript.ie
+ });
});
});
+
+ callback();
});
-
+
},
- genPerformanceTestHtml : function(){
+ genPerformanceTestHtml : function(callback){
print("Generating html performance test files...");
- this._genHtml( performanceTestScripts, performanceTestHtmlTemplate,"performance",htmlPerformanceTestsGenerated);
+ this._genHtml( performanceTestScripts,
+ performanceTestHtmlTemplate,
+ "performance",
+ htmlPerformanceTestsGenerated,
+ callback);
},
@@ -391,121 +417,126 @@ require.def("build",
var f = new java.io.File(performanceResultsPath);
if(!f.exists()){
- this.runPerformanceTestsWithSelenium();
+ this.runPerformanceTestsWithSelenium(function(){
+ var analysisResults = PerformanceAnalyzer.generateReport(allPerformanceResults);
+ });
}else{
allPerformanceResults = JSON.parse(readFile(performanceResultsPath));
}
- var analysisResults = PerformanceAnalyzer.generateReport(allPerformanceResults);
},
- genUnitTestHtml : function(){
+ genUnitTestHtml : function(callback){
print("Generating html performance test files...");
- this._genHtml( unitTestScripts, unitTestHtmlTemplate,"unit",htmlUnitTestsGenerated);
+ this._genHtml( unitTestScripts,
+ unitTestHtmlTemplate,
+ "unit",
+ htmlUnitTestsGenerated,
+ callback);
},
runUnitTestsWithSelenium : function(){
- this.genUnitTestHtml();
+ this.genUnitTestHtml(function(){
+ print("Running Selenium unit tests...");
- print("Running Selenium unit tests...");
+ for(var browserName in browsers){
- for(var browserName in browsers){
+ print("Running test for " + browserName + "...");
- print("Running test for " + browserName + "...");
-
- var bSpec = browsers[browserName];
- var bSel = new DefaultSelenium(bSpec.host, bSpec.port, bSpec.browser, seleniumConf.rootUrl);
- bSel.start();
-
- htmlUnitTestsGenerated.forEach(function(htmlTest){
- //ensure we are not testing an ie html test
- //on a non-ie browser
- if(htmlTest.ie == bSpec.ie){
-
- var unitTestResult = unitTestWithSelenium(bSel,htmlTest.path);
-
- var unitTestResultObj = {
- data : unitTestResult,
- browser : browserName,
- scxmlTest : htmlTest.scxmlTest,
- backend : htmlTest.backend,
- };
-
- unitTestResults.push(unitTestResultObj);
-
- //report errors and failures that may occur
- if(unitTestResult.failCount || unitTestResult.errorCount){
- print("UNIT TEST ERROR");
- print(JSON.stringify(unitTestResultObj));
+ var bSpec = browsers[browserName];
+ var bSel = new DefaultSelenium(bSpec.host, bSpec.port, bSpec.browser, seleniumConf.rootUrl);
+ bSel.start();
+
+ htmlUnitTestsGenerated.forEach(function(htmlTest){
+ //ensure we are not testing an ie html test
+ //on a non-ie browser
+ if(htmlTest.ie == bSpec.ie){
+
+ var unitTestResult = unitTestWithSelenium(bSel,htmlTest.path);
+
+ var unitTestResultObj = {
+ data : unitTestResult,
+ browser : browserName,
+ scxmlTest : htmlTest.scxmlTest,
+ backend : htmlTest.backend,
+ };
+
+ unitTestResults.push(unitTestResultObj);
+
+ //report errors and failures that may occur
+ if(unitTestResult.failCount || unitTestResult.errorCount){
+ print("UNIT TEST ERROR");
+ print(JSON.stringify(unitTestResultObj));
+ }
}
- }
- });
-
- bSel.stop();
- }
-
- //make one big, self-describing data structure
- //this is what analyze uses to do its analyses
- allUnitTestResults = {
- //FIXME: maybe make this an obj, so that we can add more info to it (for reports, etc.)
- data : unitTestResults,
- browsers : browsers,
- backends : backends,
- scxmlTests : scxmlTests
- };
-
- //stringify it, and serialize it for posterity
- var allUnitTestResultsString =
- JSON.stringify(allUnitTestResults)
-
+ });
- //print report that says whether all tests passed
- 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);
-
- var unitTestResultsPath = "build/allUnitTestResults.json";
- print("writing a summary of performance results to " + unitTestResultsPath);
- utilFile.writeFile(allUnitTestResultsString, unitTestResultsPath);
+ bSel.stop();
+ }
+ //make one big, self-describing data structure
+ //this is what analyze uses to do its analyses
+ allUnitTestResults = {
+ //FIXME: maybe make this an obj, so that we can add more info to it (for reports, etc.)
+ data : unitTestResults,
+ browsers : browsers,
+ backends : backends,
+ scxmlTests : scxmlTests
+ };
+
+ //stringify it, and serialize it for posterity
+ var allUnitTestResultsString =
+ JSON.stringify(allUnitTestResults)
+
+
+ //print report that says whether all tests passed
+ 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);
+
+ var unitTestResultsPath = "build/allUnitTestResults.json";
+ print("writing a summary of performance results to " + unitTestResultsPath);
+ utilFile.writeFile(allUnitTestResultsString, unitTestResultsPath);
+ });
},
runUnitTestsWithRhino : function(){
- this.genJavaScript();
+ this.genJavaScript(function(){
+ //FIXME: load dojo here instead of using RequireJS?
+ //FIXME: should only need to load doh
+
+ //unit tests have a doh dependency, so load doh with dojo.require
+ dojo.require("doh.runner");
- //FIXME: load dojo here instead of using RequireJS?
- //FIXME: should only need to load doh
-
- //unit tests have a doh dependency, so load doh with dojo.require
- dojo.require("doh.runner");
+ unitTestScripts.forEach(function(unitTestScript){
- unitTestScripts.forEach(function(unitTestScript){
+ scriptsGenerated.
+ filter(function(s){return scxmlTests[s.scxmlTest] == unitTestScript.scxmlTest}).
+ filter(function(s){return !s.ie}).
+ forEach(function(generatedScript){
- scriptsGenerated.
- filter(function(s){return scxmlTests[s.scxmlTest] == unitTestScript.scxmlTest}).
- filter(function(s){return !s.ie}).
- forEach(function(generatedScript){
+ load(generatedScript.path);
- load(generatedScript.path);
+ load(unitTestScript.path);
- load(unitTestScript.path);
+ delete StatechartExecutionContext;
+ });
- delete StatechartExecutionContext;
});
+ doh.run();
});
- doh.run();
},
Modified: commons/sandbox/gsoc/2010/scxml-js/branches/browser-tests.1.ie/src/javascript/scxml/cgf/backends/js/AbstractEnumeratedStatechartGenerator.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/browser-tests.1.ie/src/javascript/scxml/cgf/backends/js/AbstractEnumeratedStatechartGenerator.js?rev=956277&r1=956276&r2=956277&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/browser-tests.1.ie/src/javascript/scxml/cgf/backends/js/AbstractEnumeratedStatechartGenerator.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/browser-tests.1.ie/src/javascript/scxml/cgf/backends/js/AbstractEnumeratedStatechartGenerator.js Sat Jun 19 19:43:26 2010
@@ -1,6 +1,6 @@
require.def(
- "src/javascript/scxml/cgf/backends/js/StatePatternStatechartGenerator",
+ "src/javascript/scxml/cgf/backends/js/AbstractEnumeratedStatechartGenerator",
[
"src/javascript/scxml/cgf/backends/js/AbstractStatechartGenerator",
@@ -9,7 +9,6 @@ require.def(
AbstractStatechartGenerator,
appendTransitionInformation
){
-
return {
"transformations" : AbstractStatechartGenerator.transformations.concat( appendTransitionInformation )
};
Modified: commons/sandbox/gsoc/2010/scxml-js/branches/browser-tests.1.ie/src/javascript/scxml/cgf/backends/js/StateTableStatechartGenerator.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/browser-tests.1.ie/src/javascript/scxml/cgf/backends/js/StateTableStatechartGenerator.js?rev=956277&r1=956276&r2=956277&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/browser-tests.1.ie/src/javascript/scxml/cgf/backends/js/StateTableStatechartGenerator.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/browser-tests.1.ie/src/javascript/scxml/cgf/backends/js/StateTableStatechartGenerator.js Sat Jun 19 19:43:26 2010
@@ -3,7 +3,8 @@ require.def(
"src/javascript/scxml/cgf/backends/js/StateTableStatechartGenerator",
[ "src/javascript/scxml/cgf/backends/js/AbstractEnumeratedStatechartGenerator",
- "xml!src/xslt/backends/js/StateTableStatechartGenerator.xsl" ],
+ // "xml!src/xslt/backends/js/StateTableStatechartGenerator.xsl"
+ "xml!src/xslt/backends/js/StateTableStatechartGenerator_combined.xsl" ],
function(AbstractEnumeratedStatechartGenerator,StateTableStatechartGenerator){
Modified: commons/sandbox/gsoc/2010/scxml-js/branches/browser-tests.1.ie/src/javascript/scxml/cgf/backends/js/SwitchyardStatechartGenerator.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/branches/browser-tests.1.ie/src/javascript/scxml/cgf/backends/js/SwitchyardStatechartGenerator.js?rev=956277&r1=956276&r2=956277&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/branches/browser-tests.1.ie/src/javascript/scxml/cgf/backends/js/SwitchyardStatechartGenerator.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/branches/browser-tests.1.ie/src/javascript/scxml/cgf/backends/js/SwitchyardStatechartGenerator.js Sat Jun 19 19:43:26 2010
@@ -3,7 +3,8 @@ require.def(
"src/javascript/scxml/cgf/backends/js/SwitchyardStatechartGenerator",
[ "src/javascript/scxml/cgf/backends/js/AbstractEnumeratedStatechartGenerator",
- "xml!src/xslt/backends/js/SwitchyardStatechartGenerator.xsl" ],
+ // "xml!src/xslt/backends/js/SwitchyardStatechartGenerator.xsl"
+ "xml!src/xslt/backends/js/SwitchyardStatechartGenerator_combined.xsl" ],
function(AbstractEnumeratedStatechartGenerator,SwitchyardStatechartGenerator){