You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ft...@apache.org on 2015/07/07 20:18:17 UTC

[5/9] git commit: [flex-falcon] [refs/heads/add-CollectImportPass] - Build JS test files based on the Test Method Name

Build JS test files based on the Test Method Name


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

Branch: refs/heads/add-CollectImportPass
Commit: 72fe8eaf12382752d468c4c1af1bae7d414f4377
Parents: 0a63b49
Author: Frédéric THOMAS <we...@gmail.com>
Authored: Tue Jul 7 18:30:45 2015 +0100
Committer: Frédéric THOMAS <we...@gmail.com>
Committed: Tue Jul 7 19:15:39 2015 +0100

----------------------------------------------------------------------
 .../codegen/externals/ExternalsTestBase.java    | 29 ++++++++++++++++----
 1 file changed, 23 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/72fe8eaf/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestBase.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestBase.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestBase.java
index b4b8789..cfb088f 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestBase.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestBase.java
@@ -19,6 +19,8 @@
 
 package org.apache.flex.compiler.internal.codegen.externals;
 
+import static org.junit.Assert.assertTrue;
+
 import java.io.File;
 import java.io.IOException;
 
@@ -36,8 +38,7 @@ import com.google.javascript.rhino.jstype.JSType;
 
 public abstract class ExternalsTestBase
 {
-    private static File unitTestBaseDir = new File(
-            FilenameNormalization.normalize("test-files/externals_unit_tests"));
+    private static File unitTestBaseDir = new File(FilenameNormalization.normalize("test-files/externals_unit_tests"));
 
     // Only used for testing, all configuration must happen in configure()
     protected ExternCConfiguration config;
@@ -53,8 +54,7 @@ public abstract class ExternalsTestBase
         model = client.getModel();
     }
 
-    protected abstract void configure(ExternCConfiguration config)
-            throws IOException;
+    protected abstract void configure(ExternCConfiguration config) throws IOException;
 
     @After
     public void tearDown()
@@ -82,9 +82,26 @@ public abstract class ExternalsTestBase
 
     protected JSType evaluateParam(MethodReference method, String paramName)
     {
-        JSType jsType = method.getComment().getParameterType(paramName).evaluate(
-                null, client.getCompiler().getJSCompiler().getTypeRegistry());
+        JSType jsType = method.getComment().getParameterType(paramName).evaluate(null,
+                client.getCompiler().getJSCompiler().getTypeRegistry());
         return jsType;
     }
 
+    /**
+     * Clean, compile a js file based on the test method name.
+     * 
+     * @param relativeTestDir unitTestBaseDir relative base test directory.
+     * @throws IOException
+     */
+    protected void assertCompileTestFileSuccess(String relativeTestDir) throws IOException
+    {
+        if (config.getAsRoot() != null)
+        {
+            client.cleanOutput();
+        }
+        final StackTraceElement[] ste = Thread.currentThread().getStackTrace();
+        final String methodName = ste[2].getMethodName();
+        Result result = compile(relativeTestDir + methodName + ".js");
+        assertTrue(result.success);
+    }
 }