Return-Path: X-Original-To: apmail-flex-commits-archive@www.apache.org Delivered-To: apmail-flex-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B9EA911944 for ; Thu, 10 Jul 2014 16:04:40 +0000 (UTC) Received: (qmail 64533 invoked by uid 500); 10 Jul 2014 16:04:39 -0000 Delivered-To: apmail-flex-commits-archive@flex.apache.org Received: (qmail 64407 invoked by uid 500); 10 Jul 2014 16:04:39 -0000 Mailing-List: contact commits-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list commits@flex.apache.org Received: (qmail 64233 invoked by uid 99); 10 Jul 2014 16:04:39 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Jul 2014 16:04:39 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 34B019AB494; Thu, 10 Jul 2014 16:04:39 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: josebarragan@apache.org To: commits@flex.apache.org Date: Thu, 10 Jul 2014 16:04:48 -0000 Message-Id: <1b75ef251ab54d639c9b38489551153a@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [10/26] git commit: [flex-falcon] [refs/heads/experimental/VF2JS] - Prepare to handle MXML files as test subjects. Prepare to handle MXML files as test subjects. Signed-off-by: Erik de Bruin 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 Authored: Mon Jun 30 13:22:51 2014 +0200 Committer: Jose Barragan 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 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" + ""; - 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("