flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From josebarra...@apache.org
Subject [10/26] git commit: [flex-falcon] [refs/heads/experimental/VF2JS] - Prepare to handle MXML files as test subjects.
Date Thu, 10 Jul 2014 16:04:48 GMT
Prepare to handle MXML files as test subjects.

Signed-off-by: Erik de Bruin <erik@ixsoftware.nl>


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

Branch: refs/heads/experimental/VF2JS
Commit: f6b36c709d0bfa160b5ff57b73e98df1e905cb98
Parents: 395084c
Author: Erik de Bruin <erik@ixsoftware.nl>
Authored: Mon Jun 30 13:22:51 2014 +0200
Committer: Jose Barragan <josebarragan@apache.org>
Committed: Thu Jul 10 18:03:29 2014 +0200

----------------------------------------------------------------------
 .../compiler/internal/test/VF2JSTestBase.java   | 63 ++++++++++++++++----
 1 file changed, 53 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/f6b36c70/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/VF2JSTestBase.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/VF2JSTestBase.java
b/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/VF2JSTestBase.java
index 0b08818..1655663 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/VF2JSTestBase.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/test/VF2JSTestBase.java
@@ -24,8 +24,9 @@ import java.util.List;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.flex.compiler.driver.IBackend;
-import org.apache.flex.compiler.internal.driver.mxml.MXMLBackend;
+import org.apache.flex.compiler.internal.driver.mxml.flexjs.MXMLFlexJSBackend;
 import org.apache.flex.compiler.internal.mxml.MXMLNamespaceMapping;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
 import org.apache.flex.compiler.mxml.IMXMLNamespaceMapping;
 import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLNode;
@@ -39,6 +40,7 @@ public class VF2JSTestBase extends TestBase
     @Override
     public void setUp()
     {
+        project = new FlexJSProject(workspace);
         super.setUp();
 
         asEmitter = backend.createEmitter(writer);
@@ -81,9 +83,41 @@ public class VF2JSTestBase extends TestBase
     }
 
     @Override
+    protected void addSourcePaths(List<File> sourcePaths)
+    {
+        sourcePaths.add(new File(FilenameNormalization.normalize("test-files/vf2js/files")));
+
+        super.addSourcePaths(sourcePaths);
+    }
+
+    @Override
     protected IBackend createBackend()
     {
-        return new MXMLBackend();
+        return new MXMLFlexJSBackend();
+    }
+    
+    @Override
+    protected IMXMLFileNode compileMXML(String input, boolean isFileName,
+            String inputDir, boolean useTempFile)
+    {
+        File intermediateFile = new File(
+                inputDir + File.separator + input + inputFileExtension);
+        
+        File tmpFile = createTempFileWithVF2JSNamespace(intermediateFile, input,
+                false);
+        
+        String fileName = tmpFile.getName();
+        String onlyName = fileName.substring(0, fileName.lastIndexOf('.'));
+        String filePath = tmpFile.getAbsolutePath();
+        String onlyPath = filePath.substring(0,
+                filePath.lastIndexOf(File.separator));
+        
+        IMXMLFileNode result = 
+                (IMXMLFileNode) compile(onlyName, isFileName, onlyPath, useTempFile);
+        
+        tmpFile.delete();
+        
+        return result;
     }
 
     //--------------------------------------------------------------------------
@@ -106,7 +140,10 @@ public class VF2JSTestBase extends TestBase
                     + code + "\n"
                     + "</vf2js:Application>";
         
-        File tmpFile = createTempFileWithVF2JSNamespace(code);
+        File intermediateFile = writeCodeToTempFile(code, false, "");
+
+        File tmpFile = createTempFileWithVF2JSNamespace(intermediateFile,
+                getClass().getSimpleName(), true);
         
         String fileName = tmpFile.getName();
         String onlyName = fileName.substring(0, fileName.lastIndexOf('.'));
@@ -115,7 +152,6 @@ public class VF2JSTestBase extends TestBase
                 filePath.lastIndexOf(File.separator));
         
         IMXMLFileNode node = compileMXML(onlyName, true, onlyPath, false);
-        System.out.println(node);
 
         if (wrapLevel >= WRAP_LEVEL_NODE) // for now: attributes
         {
@@ -131,19 +167,26 @@ public class VF2JSTestBase extends TestBase
         }
     }
 
-    private File createTempFileWithVF2JSNamespace(String code)
+    private File createTempFileWithVF2JSNamespace(File intermediateFile,
+            String tempFileName, boolean createTempFile)
     {
-        File intermediateFile = writeCodeToTempFile(code, false, "");
-        
         File tempFile = null;
-
+        
         try 
         {
             String content = FileUtils.readFileToString(intermediateFile, "UTF-8");
             content = content.replace("<s:", "<vf2js:");
             content = content.replace("</s:", "</vf2js:");
-            tempFile = File.createTempFile(getClass().getSimpleName(),
-                    inputFileExtension, tempDir);
+            if (createTempFile)
+            {
+                tempFile = File.createTempFile(tempFileName, inputFileExtension,
+                        tempDir);
+                tempFile.deleteOnExit();
+            }
+            else
+            {
+                tempFile = new File(tempDir.getAbsolutePath(), tempFileName + inputFileExtension);
+            }
             FileUtils.writeStringToFile(tempFile, content, "UTF-8");
         } 
         catch (IOException e) 


Mime
View raw message