flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [12/18] git commit: [flex-falcon] [refs/heads/develop] - refactor tests so more of them don't require flex-sdk
Date Mon, 12 Oct 2015 20:37:08 GMT
refactor tests so more of them don't require flex-sdk


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/559238d8
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/559238d8
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/559238d8

Branch: refs/heads/develop
Commit: 559238d8100bfc0f3d666567770173d73389a7d7
Parents: 77f997b
Author: Alex Harui <aharui@apache.org>
Authored: Mon Oct 12 13:08:53 2015 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Mon Oct 12 13:08:53 2015 -0700

----------------------------------------------------------------------
 .../tree/mxml/MXMLDesignLayerNodeTests.java     |  2 +-
 .../tree/mxml/MXMLHTTPServiceNodeTests.java     |  2 +-
 .../internal/tree/mxml/MXMLNodeBaseTests.java   | 56 ++++++++++++++++++--
 .../tree/mxml/MXMLRemoteObjectNodeTests.java    |  2 +-
 .../internal/tree/mxml/MXMLStateNodeTests.java  |  2 +-
 .../tree/mxml/MXMLWebServiceNodeTests.java      |  2 +-
 6 files changed, 56 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/559238d8/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLDesignLayerNodeTests.java
----------------------------------------------------------------------
diff --git a/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLDesignLayerNodeTests.java
b/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLDesignLayerNodeTests.java
index 995f6ff..420475e 100644
--- a/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLDesignLayerNodeTests.java
+++ b/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLDesignLayerNodeTests.java
@@ -37,7 +37,7 @@ public class MXMLDesignLayerNodeTests extends MXMLInstanceNodeTests
 {
 	private IMXMLDesignLayerNode getMXMLDesignLayerNode(String[] code)
 	{
-		IMXMLFileNode fileNode = getMXMLFileNode(code);
+		IMXMLFileNode fileNode = getMXMLFileNodeWithFlex(code);
 		IMXMLDesignLayerNode node = (IMXMLDesignLayerNode)findFirstDescendantOfType(fileNode, IMXMLDesignLayerNode.class);
 		assertThat("getNodeID", node.getNodeID(), is(ASTNodeID.MXMLDesignLayerID));
 		assertThat("getName", node.getName(), is("DesignLayer"));

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/559238d8/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLHTTPServiceNodeTests.java
----------------------------------------------------------------------
diff --git a/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLHTTPServiceNodeTests.java
b/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLHTTPServiceNodeTests.java
index 90c73b3..26b9ef7 100644
--- a/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLHTTPServiceNodeTests.java
+++ b/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLHTTPServiceNodeTests.java
@@ -38,7 +38,7 @@ public class MXMLHTTPServiceNodeTests extends MXMLInstanceNodeTests
 {
 	private IMXMLHTTPServiceNode getMXMLHTTPServiceNode(String[] code)
 	{
-		IMXMLFileNode fileNode = getMXMLFileNode(code);
+		IMXMLFileNode fileNode = getMXMLFileNodeWithFlex(code);
 		IMXMLHTTPServiceNode node = (IMXMLHTTPServiceNode)findFirstDescendantOfType(fileNode, IMXMLHTTPServiceNode.class);
 		assertThat("getNodeID", node.getNodeID(), is(ASTNodeID.MXMLHTTPServiceID));
 		assertThat("getName", node.getName(), is("mx.rpc.http.mxml.HTTPService"));

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/559238d8/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLNodeBaseTests.java
----------------------------------------------------------------------
diff --git a/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLNodeBaseTests.java
b/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLNodeBaseTests.java
index 06293f4..048b44c 100644
--- a/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLNodeBaseTests.java
+++ b/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLNodeBaseTests.java
@@ -35,9 +35,11 @@ import org.apache.flex.compiler.internal.projects.FlexProjectConfigurator;
 import org.apache.flex.compiler.internal.units.SourceCompilationUnitFactory;
 import org.apache.flex.compiler.internal.workspaces.Workspace;
 import org.apache.flex.compiler.mxml.IMXMLNamespaceMapping;
+import org.apache.flex.compiler.problems.ICompilerProblem;
 import org.apache.flex.compiler.tree.as.IASNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
 import org.apache.flex.compiler.units.ICompilationUnit;
+import org.apache.flex.compiler.units.requests.ISyntaxTreeRequestResult;
 import org.apache.flex.utils.EnvProperties;
 import org.apache.flex.utils.FilenameNormalization;
 import org.apache.flex.utils.StringUtils;
@@ -66,6 +68,21 @@ public class MXMLNodeBaseTests
 		return new String[] 
 		{
 		    "<d:Sprite xmlns:fx='http://ns.adobe.com/mxml/2009'",
+		    "          xmlns:d='flash.display.*'>",
+			"    %1",
+		    "</d:Sprite>"
+		};
+    };
+	
+ 	protected String[] getTemplateWithFlex()
+	{
+ 		// Tests of nodes for class-definition-level tags like <Declarations>,
+ 		// <Library>,  <Metadata>, <Script>, and <Style> use this document
template.
+ 		// Tests for nodes produced by tags that appear at other locations
+ 		// override getTemplate() and getMXML().
+		return new String[] 
+		{
+		    "<d:Sprite xmlns:fx='http://ns.adobe.com/mxml/2009'",
 		    "          xmlns:d='flash.display.*'",
 		    "          xmlns:s='library://ns.adobe.com/flex/spark'",
 		    "          xmlns:mx='library://ns.adobe.com/flex/mx'>",
@@ -81,15 +98,34 @@ public class MXMLNodeBaseTests
         return mxml;
     }
 	    
+	protected String getMXMLWithFlex(String[] code)
+    {
+        String mxml = StringUtils.join(getTemplateWithFlex(), "\n");
+        mxml = mxml.replace("%1", StringUtils.join(code, "\n    "));
+        return mxml;
+    }
+	    
     protected IMXMLFileNode getMXMLFileNode(String[] code)
     {
     	String mxml = getMXML(code);
-    	return getMXMLFileNode(mxml);
+    	return getMXMLFileNode(mxml, false);
+    }
+
+    protected IMXMLFileNode getMXMLFileNodeWithFlex(String[] code)
+    {
+    	String mxml = getMXMLWithFlex(code);
+    	return getMXMLFileNode(mxml, true);
     }
 
     protected IMXMLFileNode getMXMLFileNode(String mxml)
 	{
-		assertNotNull("Environment variable FLEX_HOME is not set", env.SDK);
+    	return getMXMLFileNode(mxml, false);
+	}
+    
+    protected IMXMLFileNode getMXMLFileNode(String mxml, boolean withFlex)
+	{
+    	if (withFlex)
+    		assertNotNull("Environment variable FLEX_HOME is not set", env.SDK);
 		assertNotNull("Environment variable PLAYERGLOBAL_HOME is not set", env.FPSDK);
 		
 		project = new FlexProject(workspace);
@@ -119,9 +155,12 @@ public class MXMLNodeBaseTests
 		// Compile the code against playerglobal.swc.
 		List<File> libraries = new ArrayList<File>();
 		libraries.add(new File(FilenameNormalization.normalize(env.FPSDK + "\\" + env.FPVER + "\\playerglobal.swc")));
-		libraries.add(new File(FilenameNormalization.normalize(env.SDK + "\\frameworks\\libs\\framework.swc")));
-		libraries.add(new File(FilenameNormalization.normalize(env.SDK + "\\frameworks\\libs\\rpc.swc")));
-		libraries.add(new File(FilenameNormalization.normalize(env.SDK + "\\frameworks\\libs\\spark.swc")));
+		if (withFlex)
+		{
+			libraries.add(new File(FilenameNormalization.normalize(env.SDK + "\\frameworks\\libs\\framework.swc")));
+			libraries.add(new File(FilenameNormalization.normalize(env.SDK + "\\frameworks\\libs\\rpc.swc")));
+			libraries.add(new File(FilenameNormalization.normalize(env.SDK + "\\frameworks\\libs\\spark.swc")));
+		}
 		project.setLibraries(libraries);
 		
 		// Use the MXML 2009 manifest.
@@ -151,6 +190,13 @@ public class MXMLNodeBaseTests
 		try
 		{
 			fileNode = (IMXMLFileNode)cu.getSyntaxTreeRequest().get().getAST();
+			ISyntaxTreeRequestResult result = cu.getSyntaxTreeRequest().get();
+			ICompilerProblem[] problems = result.getProblems();
+			if (problems != null && problems.length > 0)
+			{
+				for (ICompilerProblem problem : problems)
+					System.out.printf("%s(%d): %s\n", problem.getSourcePath(), problem.getLine(), problem.toString());
+			}
 		}
 		catch (InterruptedException e)
 		{

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/559238d8/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLRemoteObjectNodeTests.java
----------------------------------------------------------------------
diff --git a/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLRemoteObjectNodeTests.java
b/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLRemoteObjectNodeTests.java
index 0da8482..e5dfa9c 100644
--- a/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLRemoteObjectNodeTests.java
+++ b/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLRemoteObjectNodeTests.java
@@ -38,7 +38,7 @@ public class MXMLRemoteObjectNodeTests extends MXMLInstanceNodeTests
 {
 	private IMXMLRemoteObjectNode getMXMLRemoteObjectNode(String[] code)
 	{
-		IMXMLFileNode fileNode = getMXMLFileNode(code);
+		IMXMLFileNode fileNode = getMXMLFileNodeWithFlex(code);
 		IMXMLRemoteObjectNode node = (IMXMLRemoteObjectNode)findFirstDescendantOfType(fileNode,
IMXMLRemoteObjectNode.class);
 		assertThat("getNodeID", node.getNodeID(), is(ASTNodeID.MXMLRemoteObjectID));
 		assertThat("getName", node.getName(), is("mx.rpc.remoting.mxml.RemoteObject"));

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/559238d8/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLStateNodeTests.java
----------------------------------------------------------------------
diff --git a/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLStateNodeTests.java
b/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLStateNodeTests.java
index fa4d923..5ed44c8 100644
--- a/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLStateNodeTests.java
+++ b/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLStateNodeTests.java
@@ -51,7 +51,7 @@ public class MXMLStateNodeTests extends MXMLInstanceNodeTests
 	
 	private IMXMLStateNode getMXMLStateNode(String[] code)
 	{
-		IMXMLFileNode fileNode = getMXMLFileNode(code);
+		IMXMLFileNode fileNode = getMXMLFileNodeWithFlex(code);
 		IMXMLStateNode node = (IMXMLStateNode)findFirstDescendantOfType(fileNode, IMXMLStateNode.class);
 		assertThat("getNodeID", node.getNodeID(), is(ASTNodeID.MXMLStateID));
 		assertThat("getName", node.getName(), is("mx.states.State"));

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/559238d8/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLWebServiceNodeTests.java
----------------------------------------------------------------------
diff --git a/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLWebServiceNodeTests.java
b/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLWebServiceNodeTests.java
index 1d665fc..7efcddc 100644
--- a/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLWebServiceNodeTests.java
+++ b/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLWebServiceNodeTests.java
@@ -38,7 +38,7 @@ public class MXMLWebServiceNodeTests extends MXMLInstanceNodeTests
 {	
 	private IMXMLWebServiceNode getMXMLWebServiceNode(String[] code)
 	{
-		IMXMLFileNode fileNode = getMXMLFileNode(code);
+		IMXMLFileNode fileNode = getMXMLFileNodeWithFlex(code);
 		IMXMLWebServiceNode node = (IMXMLWebServiceNode)findFirstDescendantOfType(fileNode, IMXMLWebServiceNode.class);
 		assertThat("getNodeID", node.getNodeID(), is(ASTNodeID.MXMLWebServiceID));
 		assertThat("getName", node.getName(), is("mx.rpc.soap.mxml.WebService"));


Mime
View raw message