You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cz...@apache.org on 2012/12/11 11:14:28 UTC

svn commit: r1420067 - in /incubator/flex/falcon/trunk/compiler.tests: ./ feature-tests/mxml/tags/ functional-tests/f/ src/ src/utils/ unit-tests/org/apache/flex/compiler/internal/tree/mxml/

Author: czadra
Date: Tue Dec 11 10:14:26 2012
New Revision: 1420067

URL: http://svn.apache.org/viewvc?rev=1420067&view=rev
Log:
properties handling for unit-, functional- and feature-tests  - added template-unittest.properties

Added:
    incubator/flex/falcon/trunk/compiler.tests/src/
    incubator/flex/falcon/trunk/compiler.tests/src/utils/
    incubator/flex/falcon/trunk/compiler.tests/src/utils/EnvProperties.java   (with props)
    incubator/flex/falcon/trunk/compiler.tests/template-unittest.properties   (with props)
Modified:
    incubator/flex/falcon/trunk/compiler.tests/.classpath
    incubator/flex/falcon/trunk/compiler.tests/build.xml
    incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLFeatureTestsBase.java
    incubator/flex/falcon/trunk/compiler.tests/functional-tests/f/SDKSWCTests.java
    incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLNodeBaseTests.java

Modified: incubator/flex/falcon/trunk/compiler.tests/.classpath
URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/.classpath?rev=1420067&r1=1420066&r2=1420067&view=diff
==============================================================================
--- incubator/flex/falcon/trunk/compiler.tests/.classpath (original)
+++ incubator/flex/falcon/trunk/compiler.tests/.classpath Tue Dec 11 10:14:26 2012
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
 	<classpathentry excluding="**/.svn/*" kind="src" path="unit-tests"/>
+	<classpathentry kind="src" path="src"/>
 	<classpathentry excluding="**/.svn/*" kind="src" path="functional-tests"/>
 	<classpathentry kind="src" path="feature-tests"/>
 	<classpathentry kind="lib" path="lib/junit-4.10.jar"/>

Modified: incubator/flex/falcon/trunk/compiler.tests/build.xml
URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/build.xml?rev=1420067&r1=1420066&r2=1420067&view=diff
==============================================================================
--- incubator/flex/falcon/trunk/compiler.tests/build.xml (original)
+++ incubator/flex/falcon/trunk/compiler.tests/build.xml Tue Dec 11 10:14:26 2012
@@ -25,12 +25,15 @@
         <path location="${basedir}"/>
     </pathconvert>
 
-    <property name="compiler" value="${compiler.tests}/../compiler"/>
     <property environment="env"/>
-    <property name="sdk" value="${env.FLEX_HOME}" />
-    <property name="sdk" value="${compiler}/generated/dist/sdk"/>
+	<property file="unittest.properties" />
+	
+	<condition property="sdk" value="${FLEX_HOME}" else="${env.FLEX_HOME}">
+	    <isset property="FLEX_HOME" />
+	</condition>
+	
+    <property name="compiler" value="${compiler.tests}/../compiler"/>
     <property name="falcon" value="${compiler}/generated/dist/sdk"/>
-    <property name="fpsdk" value="${env.PLAYERGLOBAL_HOME}" />
 
     <target name="download" description="Downloads third-party JARs">
         <ant antfile="${compiler.tests}/downloads.xml" dir="${compiler.tests}"/>
@@ -62,9 +65,11 @@
     </target>
 
     <target name="compile.unit.tests">
+    	<delete dir="${compiler.tests}/classes"/>
         <mkdir dir="${compiler.tests}/classes"/>
         <javac debug="${javac.debug}" deprecation="${javac.deprecation}" destdir="${compiler.tests}/classes" includeAntRuntime="true">
             <src path="${compiler.tests}/unit-tests"/>
+        	<src path="${compiler.tests}/src"/>
             <compilerarg value="-Xlint:all,-path"/>
             <classpath>
                 <fileset dir="${compiler}/lib" includes="**/*.jar"/>
@@ -82,8 +87,44 @@
                printsummary="true" showoutput="true"
                haltonerror="false" haltonfailure="false"
                failureproperty="tests.unit.failed">
-            <sysproperty key="FLEX_HOME" value="${sdk}" />
-            <sysproperty key="PLAYERGLOBAL_HOME" value="${fpsdk}" />
+            <classpath>
+                <pathelement location="${compiler.tests}/classes"/>
+                <fileset dir="${compiler}/lib" includes="**/*.jar"/>
+                <fileset dir="${compiler.tests}/lib" includes="**/*.jar"/>
+                <pathelement location="${falcon}/lib/compiler.jar"/>
+            </classpath>
+            <batchtest todir="${compiler.tests}/results">
+                <fileset dir="${compiler.tests}/classes">
+                    <include name="**/*Tests.class"/>
+                </fileset>
+            </batchtest>
+            <formatter type="xml"/>
+        </junit>
+    </target>
+	
+    <target name="compile.functional.tests">
+    	<delete dir="${compiler.tests}/classes" />
+        <mkdir dir="${compiler.tests}/classes"/>
+        <javac debug="${javac.debug}" deprecation="${javac.deprecation}" destdir="${compiler.tests}/classes" includeAntRuntime="true">
+        	<src path="${compiler.tests}/src"/>
+        	<src path="${compiler.tests}/functional-tests"/>
+            <compilerarg value="-Xlint:all,-path"/>
+            <classpath>
+                <fileset dir="${compiler}/lib" includes="**/*.jar"/>
+                <fileset dir="${compiler.tests}/lib" includes="**/*.jar"/>
+                <pathelement location="${falcon}/lib/compiler.jar"/>
+            </classpath>
+        </javac>
+    </target>
+	
+    <target name="functional.tests" depends="download, compile.functional.tests">
+        <mkdir dir="${compiler.tests}/results"/>
+        <mkdir dir="${compiler.tests}/temp"/>
+        <junit dir="${compiler.tests}"
+               fork="yes" forkMode="perBatch" maxmemory="256m" timeout="300000"
+               printsummary="true" showoutput="true"
+               haltonerror="false" haltonfailure="false"
+               failureproperty="tests.functional.failed">
             <classpath>
                 <pathelement location="${compiler.tests}/classes"/>
                 <fileset dir="${compiler}/lib" includes="**/*.jar"/>
@@ -99,7 +140,7 @@
         </junit>
     </target>
 
-    <target name="main" depends="unit.tests, jar.tests, ant.tests"/>
+    <target name="main" depends="unit.tests, functional.tests, jar.tests, ant.tests"/>
 
     <target name="clean">
         <delete dir="${compiler.tests}/bin"/>

Modified: incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLFeatureTestsBase.java
URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLFeatureTestsBase.java?rev=1420067&r1=1420066&r2=1420067&view=diff
==============================================================================
--- incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLFeatureTestsBase.java (original)
+++ incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLFeatureTestsBase.java Tue Dec 11 10:14:26 2012
@@ -32,6 +32,8 @@ import org.apache.flex.compiler.clients.
 import org.apache.flex.compiler.problems.ICompilerProblem;
 import org.apache.flex.utils.FilenameNormalization;
 
+import utils.EnvProperties;
+
 /**
  * Base class for MXML feature tests which compile MXML code with MXMLC and run it in the standalone Flash Player.
  * 
@@ -39,10 +41,11 @@ import org.apache.flex.utils.FilenameNor
  */
 public class MXMLFeatureTestsBase
 {
-	private static final String SDK = FilenameNormalization.normalize("../compiler/generated/dist/sdk");
-	private static final String PLAYERGLOBAL_SWC = FilenameNormalization.normalize(SDK + "\\frameworks\\libs\\player\\11.1\\playerglobal.swc");
+	private static EnvProperties env = EnvProperties.initiate();
+	
+	private static final String PLAYERGLOBAL_SWC = FilenameNormalization.normalize(env.FPSDK + "\\11.1\\playerglobal.swc");
 	private static final String NAMESPACE_2009 = "http://ns.adobe.com/mxml/2009";
-    private static final String MANIFEST_2009 = FilenameNormalization.normalize(SDK + "\\frameworks\\mxml-2009-manifest.xml");
+    private static final String MANIFEST_2009 = FilenameNormalization.normalize(env.SDK + "\\frameworks\\mxml-2009-manifest.xml");
     
     // The Ant script for compiler.tests copies a standalone player to the temp directory.
     private static final String FLASHPLAYER = FilenameNormalization.normalize("temp/FlashPlayer.exe");

Modified: incubator/flex/falcon/trunk/compiler.tests/functional-tests/f/SDKSWCTests.java
URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/functional-tests/f/SDKSWCTests.java?rev=1420067&r1=1420066&r2=1420067&view=diff
==============================================================================
--- incubator/flex/falcon/trunk/compiler.tests/functional-tests/f/SDKSWCTests.java (original)
+++ incubator/flex/falcon/trunk/compiler.tests/functional-tests/f/SDKSWCTests.java Tue Dec 11 10:14:26 2012
@@ -19,8 +19,9 @@
 
 package f;
 
-import static org.junit.Assert.*;
 import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
 
 import java.io.File;
 import java.io.IOException;
@@ -32,6 +33,8 @@ import org.apache.flex.compiler.problems
 import org.junit.Ignore;
 import org.junit.Test;
 
+import utils.EnvProperties;
+
 /**
  * JUnit tests to compile the SWCs of the Flex SDK.
  * <p>
@@ -43,17 +46,14 @@ import org.junit.Test;
  */
 public class SDKSWCTests
 {
+	private static EnvProperties env = EnvProperties.initiate();
+	
 	private void compileSWC(String projectName)
 	{
 		// Construct a command line which simply loads the project's config file.
-		String playerglobalHome = System.getenv("PLAYERGLOBAL_HOME");
-		assertNotNull("Environment variable PLAYERGLOBAL_HOME is not set", playerglobalHome);
-		
-		String flexHome = System.getenv("FLEX_HOME");
-		assertNotNull("Environment variable FLEX_HOME is not set", flexHome);
-		
-		String airHome = System.getenv("AIR_HOME");
-		assertNotNull("Environment variable AIR_HOME is not set", airHome);
+		assertNotNull("FLEX_HOME not set in unittest.properties", env.SDK);
+		assertNotNull("PLAYERGLOBAL_HOME not set in unittest.properties", env.FPSDK);
+		assertNotNull("AIR_HOME not set in unittest.properties", env.AIRSDK);
 		
 		String output = null;
 		String outputSwcName = projectName;
@@ -67,12 +67,12 @@ public class SDKSWCTests
 		{
 		}
 
-		String configFile = flexHome + "/frameworks/projects/" + projectName + "/compile-config.xml";
+		String configFile = env.SDK + "/frameworks/projects/" + projectName + "/compile-config.xml";
 		String[] args = new String[]
 		{
 			"-load-config=" + configFile,
-			"+env.PLAYERGLOBAL_HOME=" + playerglobalHome,
-			"+env.AIR_HOME=" + airHome,
+			"+env.PLAYERGLOBAL_HOME=" + env.FPSDK,
+			"+env.AIR_HOME=" + env.AIRSDK,
 			"+playerglobal.version=11.1",
 			"-ignore-problems=org.apache.flex.compiler.problems.DuplicateQNameInSourcePathProblem",
 			"-define=CONFIG::performanceInstrumentation,false",

Added: incubator/flex/falcon/trunk/compiler.tests/src/utils/EnvProperties.java
URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/src/utils/EnvProperties.java?rev=1420067&view=auto
==============================================================================
--- incubator/flex/falcon/trunk/compiler.tests/src/utils/EnvProperties.java (added)
+++ incubator/flex/falcon/trunk/compiler.tests/src/utils/EnvProperties.java Tue Dec 11 10:14:26 2012
@@ -0,0 +1,81 @@
+package utils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.apache.flex.utils.FilenameNormalization;
+
+
+/**
+ *  EnvProperties checks in following order for a value.
+ * 
+ *  1) unittest.properties 
+ *  2) environment variables
+ *  3) for key FLEX_HOME & PLAYERGLOBAL_HOME sets a default value.
+ */
+public class EnvProperties {
+	
+	/**
+	 * FLEX_HOME
+	 */
+	public String SDK;
+	
+	/**
+	 * PLAYERGLOBAL_HOME
+	 */
+	public String FPSDK;
+	
+	/**
+	 * AIR_HOME
+	 */
+	public String AIRSDK;
+	
+	/**
+	 * FLASHPLAYER_DEBUGGER
+	 */
+	public String FDBG;
+	
+	
+	private static EnvProperties propertyReader;
+	
+	public static EnvProperties initiate() {
+		if(propertyReader == null) {
+			propertyReader = new EnvProperties();
+			propertyReader.setup();
+		}
+		return propertyReader;
+	}
+	
+	private void setup()
+	{
+		Properties p = new Properties();
+		try {
+			File f = new File("unittest.properties");
+			p.load(new FileInputStream( f ));
+		} catch (FileNotFoundException e) {
+			System.out.println("unittest.properties not found");
+		} catch (IOException e) {
+		}
+		
+		SDK = p.getProperty("FLEX_HOME", System.getenv("FLEX_HOME"));
+		if(SDK == null)
+			SDK = FilenameNormalization.normalize("../compiler/generated/dist/sdk");		
+		System.out.println("Env - FLEX_HOME = " + SDK);
+		
+		FPSDK = p.getProperty("PLAYERGLOBAL_HOME", System.getenv("PLAYERGLOBAL_HOME"));
+		if(FPSDK == null)
+			FPSDK = FilenameNormalization.normalize("../compiler/generated/dist/sdk/frameworks/libs/player");
+		System.out.println("Env - PLAYERGLOBAL_HOME = " + FPSDK);
+
+		
+		AIRSDK = p.getProperty("AIR_HOME", System.getenv("AIR_HOME"));
+		System.out.println("Env - AIR_HOME = " + AIRSDK);
+		
+		FDBG = p.getProperty("FLASHPLAYER_DEBUGGER", System.getenv("FLASHPLAYER_DEBUGGER"));
+		System.out.println("Env - FLASHPLAYER_DEBUGGER = " + FDBG);
+	}
+
+}

Propchange: incubator/flex/falcon/trunk/compiler.tests/src/utils/EnvProperties.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/falcon/trunk/compiler.tests/template-unittest.properties
URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/template-unittest.properties?rev=1420067&view=auto
==============================================================================
--- incubator/flex/falcon/trunk/compiler.tests/template-unittest.properties (added)
+++ incubator/flex/falcon/trunk/compiler.tests/template-unittest.properties Tue Dec 11 10:14:26 2012
@@ -0,0 +1,22 @@
+# copy template-unittest.properties to unittest.properties
+#
+
+# Example  	(Windows) FLEX_HOME=C:\\dev\\apache-flex\\sdk
+#			(Mac Os X)
+# 
+# FLEX_HOME=
+
+# Example	(Windows) AIR_HOME=C://dev//air-sdk-3.4
+#			(Mac Os X)  
+#
+# AIR_HOME=
+
+# 
+# Example 	(Windows) PLAYERGLOBAL_HOME=C://dev//apache-flex-4.8.0//frameworks//libs//player
+# 			(Mac Os X) 
+# 
+# PLAYERGLOBAL_HOME=
+
+# Example	(Windows) FLASHPLAYER_DEBUGGER=C://Program Files//Adobe//Adobe Flash Builder//player//win//11.1//FlashPlayerDebugger.exe
+# 			(Mac Os X)
+# FLASHPLAYER_DEBUGGER=

Propchange: incubator/flex/falcon/trunk/compiler.tests/template-unittest.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLNodeBaseTests.java
URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLNodeBaseTests.java?rev=1420067&r1=1420066&r2=1420067&view=diff
==============================================================================
--- incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLNodeBaseTests.java (original)
+++ incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLNodeBaseTests.java Tue Dec 11 10:14:26 2012
@@ -19,16 +19,15 @@
 
 package org.apache.flex.compiler.internal.tree.mxml;
 
+import static org.junit.Assert.assertNotNull;
+
 import java.io.BufferedWriter;
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
-import java.util.Properties;
 
 import org.apache.flex.compiler.internal.projects.FlexProject;
 import org.apache.flex.compiler.internal.projects.FlexProjectConfigurator;
@@ -42,35 +41,17 @@ import org.apache.flex.compiler.units.IC
 import org.apache.flex.utils.FilenameNormalization;
 import org.junit.Test;
 
+import utils.EnvProperties;
+
 /**
  * JUnit tests for {@link MXMLNodeBase}.
  * 
  * @author Gordon Smith
  */
-public class MXMLNodeBaseTests
+public class MXMLNodeBaseTests 
 {
-	private static String SDK;
-	private static String FPSDK;	
-	private static boolean pathsSet = false;
-	private static void setPaths()
-	{
-		Properties p = new Properties();
-		try {
-			p.load(new FileInputStream( new File("unittest.properties")));
-			SDK = p.getProperty("FLEX_HOME",
-					FilenameNormalization.normalize("../compiler/generated/dist/sdk"));
-			FPSDK = p.getProperty("PLAYERGLOBAL_HOME",
-					FilenameNormalization.normalize("../compiler/generated/dist/sdk/frameworks/libs/player"));
-		} catch (FileNotFoundException e) {
-			SDK = FilenameNormalization.normalize("../compiler/generated/dist/sdk");
-			FPSDK = FilenameNormalization.normalize("../compiler/generated/dist/sdk/frameworks/libs/player");
-		} catch (IOException e) {
-			SDK = FilenameNormalization.normalize("../compiler/generated/dist/sdk");
-			FPSDK = FilenameNormalization.normalize("../compiler/generated/dist/sdk/frameworks/libs/player");
-		}
-		
-		pathsSet = true;
-	}
+	
+	private static EnvProperties env = EnvProperties.initiate();
 	
 	protected static Workspace workspace = new Workspace();
 	
@@ -95,11 +76,11 @@ public class MXMLNodeBaseTests
 	
 	protected IMXMLFileNode getMXMLFileNode(String code)
 	{
+		assertNotNull("Environment variable FLEX_HOME is not set", env.SDK);
+		assertNotNull("Environment variable PLAYERGLOBAL_HOME is not set", env.FPSDK);
+		
 		project = new FlexProject(workspace);
-		FlexProjectConfigurator.configure(project);
-
-		if (!pathsSet)
-			setPaths();
+		FlexProjectConfigurator.configure(project);		
 		
 		String tempDir = FilenameNormalization.normalize("temp"); // ensure this exists
 				
@@ -124,16 +105,16 @@ public class MXMLNodeBaseTests
 
 		// Compile the code against playerglobal.swc.
 		List<File> libraries = new ArrayList<File>();
-		libraries.add(new File(FilenameNormalization.normalize(FPSDK + "\\11.1\\playerglobal.swc")));
-		libraries.add(new File(FilenameNormalization.normalize(SDK + "\\frameworks\\libs\\framework.swc")));
-		libraries.add(new File(FilenameNormalization.normalize(SDK + "\\frameworks\\libs\\rpc.swc")));
-		libraries.add(new File(FilenameNormalization.normalize(SDK + "\\frameworks\\libs\\spark.swc")));
+		libraries.add(new File(FilenameNormalization.normalize(env.FPSDK + "\\11.1\\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")));
 		project.setLibraries(libraries);
 		
 		// Use the MXML 2009 manifest.
 		List<IMXMLNamespaceMapping> namespaceMappings = new ArrayList<IMXMLNamespaceMapping>();
 		IMXMLNamespaceMapping mxml2009 = new MXMLNamespaceMapping(
-		    "http://ns.adobe.com/mxml/2009", SDK + "\\frameworks\\mxml-2009-manifest.xml");
+		    "http://ns.adobe.com/mxml/2009", env.SDK + "\\frameworks\\mxml-2009-manifest.xml");
 		namespaceMappings.add(mxml2009);
 		project.setNamespaceMappings(namespaceMappings);