You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by jo...@apache.org on 2022/08/02 16:07:13 UTC

[royale-compiler] branch develop updated (809c56398 -> 34c9fb9f0)

This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git


    from 809c56398 royaleunit: Call to setThreadContextLoader() for Playwright needs a matching call to resetThreadContextLoader()
     new 0b4edfc1b RoyaleUnit: Fix Windows test runs that failed to run Playwright because the environment variables were too long
     new 34c9fb9f0 RoyaleUnit: all calls to update classpath for Playwright happen in DefaultPlaywrightContext instead of split between Command and Context

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../playwright/DefaultPlaywrightCommand.java       | 29 ++++------------------
 .../contexts/DefaultPlaywrightContext.java         |  6 +++--
 2 files changed, 9 insertions(+), 26 deletions(-)


[royale-compiler] 01/02: RoyaleUnit: Fix Windows test runs that failed to run Playwright because the environment variables were too long

Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git

commit 0b4edfc1b2ac20d58a8183113010d2e493a7ca05
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Tue Aug 2 08:57:33 2022 -0700

    RoyaleUnit: Fix Windows test runs that failed to run Playwright because the environment variables were too long
---
 .../playwright/DefaultPlaywrightCommand.java       | 22 +++++-----------------
 1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/royaleunit-ant-tasks/src/main/java/org/apache/royale/test/ant/launcher/commands/playwright/DefaultPlaywrightCommand.java b/royaleunit-ant-tasks/src/main/java/org/apache/royale/test/ant/launcher/commands/playwright/DefaultPlaywrightCommand.java
index 670ca5594..c591f34bf 100644
--- a/royaleunit-ant-tasks/src/main/java/org/apache/royale/test/ant/launcher/commands/playwright/DefaultPlaywrightCommand.java
+++ b/royaleunit-ant-tasks/src/main/java/org/apache/royale/test/ant/launcher/commands/playwright/DefaultPlaywrightCommand.java
@@ -87,7 +87,7 @@ public class DefaultPlaywrightCommand implements PlaywrightCommand
         ((AntClassLoader)getClass().getClassLoader()).setThreadContextLoader();
 
         CreateOptions createOptions = new CreateOptions();
-        createOptions.setEnv(getJointEnvironment());
+        createOptions.setEnv(getEnvironmentMap());
         playwright = PlaywrightImpl.create(createOptions);
     }
     
@@ -150,30 +150,18 @@ public class DefaultPlaywrightCommand implements PlaywrightCommand
         environment = variables;
     }
 
-    /**
-     * Combine process environment variables and command's environment to emulate the default
-     * behavior of the Execute task.  Needed especially when user expects environment to be 
-     * available to custom command (e.g. - xvnc with player not on path).
-     */
     @SuppressWarnings("unchecked")
-    private Map<String,String> getJointEnvironment()
+    private Map<String,String> getEnvironmentMap()
     {
-        Map<String, String> jointEnvironment = new HashMap<String, String>();
-        Vector<String> executeProcEnvironment = Execute.getProcEnvironment();
-        String[] procEnvironment = executeProcEnvironment.toArray(new String[0]);
-        for (String envVar : procEnvironment)
-        {
-            String[] parts = envVar.split("=");
-            jointEnvironment.put(parts[0].trim(), parts.length > 1 ? parts[1].trim() : "");
-        }
+        Map<String, String> result = new HashMap<String, String>();
         if (environment != null)
         {
             for (String envVar : environment)
             {
                 String[] parts = envVar.split("=");
-                jointEnvironment.put(parts[0].trim(), parts.length > 1 ? parts[1].trim() : "");
+                result.put(parts[0].trim(), parts.length > 1 ? parts[1].trim() : "");
             }
         }
-        return jointEnvironment;
+        return result;
     }
 }


[royale-compiler] 02/02: RoyaleUnit: all calls to update classpath for Playwright happen in DefaultPlaywrightContext instead of split between Command and Context

Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git

commit 34c9fb9f0a34cacae19ded35f9e580c24e2c8edc
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Tue Aug 2 09:00:11 2022 -0700

    RoyaleUnit: all calls to update classpath for Playwright happen in DefaultPlaywrightContext instead of split between Command and Context
---
 .../ant/launcher/commands/playwright/DefaultPlaywrightCommand.java | 7 -------
 .../test/ant/launcher/contexts/DefaultPlaywrightContext.java       | 6 ++++--
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/royaleunit-ant-tasks/src/main/java/org/apache/royale/test/ant/launcher/commands/playwright/DefaultPlaywrightCommand.java b/royaleunit-ant-tasks/src/main/java/org/apache/royale/test/ant/launcher/commands/playwright/DefaultPlaywrightCommand.java
index c591f34bf..05b5f2bdd 100644
--- a/royaleunit-ant-tasks/src/main/java/org/apache/royale/test/ant/launcher/commands/playwright/DefaultPlaywrightCommand.java
+++ b/royaleunit-ant-tasks/src/main/java/org/apache/royale/test/ant/launcher/commands/playwright/DefaultPlaywrightCommand.java
@@ -20,13 +20,10 @@ import java.io.File;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.Vector;
 import java.util.function.Consumer;
 
 import org.apache.royale.test.ant.LoggingUtil;
-import org.apache.tools.ant.AntClassLoader;
 import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.Execute;
 
 import com.microsoft.playwright.Browser;
 import com.microsoft.playwright.BrowserType;
@@ -82,10 +79,6 @@ public class DefaultPlaywrightCommand implements PlaywrightCommand
     
     public void prepare()
     {
-        // must also call resetThreadContextLoader() after test run completes.
-        // that happens in stop() method of DefaultPlaywrightContext
-        ((AntClassLoader)getClass().getClassLoader()).setThreadContextLoader();
-
         CreateOptions createOptions = new CreateOptions();
         createOptions.setEnv(getEnvironmentMap());
         playwright = PlaywrightImpl.create(createOptions);
diff --git a/royaleunit-ant-tasks/src/main/java/org/apache/royale/test/ant/launcher/contexts/DefaultPlaywrightContext.java b/royaleunit-ant-tasks/src/main/java/org/apache/royale/test/ant/launcher/contexts/DefaultPlaywrightContext.java
index 979de5631..34e35f20a 100644
--- a/royaleunit-ant-tasks/src/main/java/org/apache/royale/test/ant/launcher/contexts/DefaultPlaywrightContext.java
+++ b/royaleunit-ant-tasks/src/main/java/org/apache/royale/test/ant/launcher/contexts/DefaultPlaywrightContext.java
@@ -43,6 +43,9 @@ public class DefaultPlaywrightContext implements PlaywrightExecutionContext
 
     public void start() throws IOException
     {
+        // calls resetThreadContextLoader() in stop() after test run completes
+        ((AntClassLoader)getClass().getClassLoader()).setThreadContextLoader();
+       
         //prep anything the command needs to run
         command.prepare();
     }
@@ -52,8 +55,7 @@ public class DefaultPlaywrightContext implements PlaywrightExecutionContext
         //destroy the playwright instance, if it exists
         if(playwright != null)
         {
-            // setThreadContextLoader() was called in DefaultPlaywrightCommand,
-            // and this is the matching call to resetThreadContextLoader()
+            // setThreadContextLoader() was called in start()
             ((AntClassLoader)getClass().getClassLoader()).resetThreadContextLoader();
 
             playwright.close();