Repository: flex-falcon
Updated Branches:
  refs/heads/develop ebf72609d -> f363d911d


Changed the test to have a timeout when starting the flashplayer.


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

Branch: refs/heads/develop
Commit: f363d911d500dc4ef49158aea447216f94b16435
Parents: ebf7260
Author: Christofer Dutz <[email protected]>
Authored: Fri Nov 28 15:27:41 2014 +0100
Committer: Christofer Dutz <[email protected]>
Committed: Fri Nov 28 15:27:41 2014 +0100

----------------------------------------------------------------------
 .../mxml/tags/MXMLFeatureTestsBase.java         | 35 ++++++++++++++++++--
 1 file changed, 32 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/f363d911/compiler.tests/feature-tests/mxml/tags/MXMLFeatureTestsBase.java
----------------------------------------------------------------------
diff --git a/compiler.tests/feature-tests/mxml/tags/MXMLFeatureTestsBase.java 
b/compiler.tests/feature-tests/mxml/tags/MXMLFeatureTestsBase.java
index 58b732a..f72da2e 100644
--- a/compiler.tests/feature-tests/mxml/tags/MXMLFeatureTestsBase.java
+++ b/compiler.tests/feature-tests/mxml/tags/MXMLFeatureTestsBase.java
@@ -31,6 +31,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
+import java.util.concurrent.*;
 
 import org.apache.flex.compiler.clients.MXMLC;
 import org.apache.flex.compiler.problems.ICompilerProblem;
@@ -143,9 +144,7 @@ public class MXMLFeatureTestsBase
                try
                {
                        System.out.println("Executing test:\n" + 
Arrays.toString(runArgs));
-                       Process process = Runtime.getRuntime().exec(runArgs);
-                       process.waitFor();
-                       exitCode = process.exitValue();
+                       exitCode = executeCommandWithTimeout(runArgs, 2);
                }
                catch (Exception e)
                {
@@ -160,4 +159,34 @@ public class MXMLFeatureTestsBase
        {
                compileAndRun(mxml, false, false, false, null);
        }
+
+       public static int executeCommandWithTimeout(String[] args, long 
timeoutInSeconds) throws Exception {
+               ExecutorService service = Executors.newSingleThreadExecutor();
+               Process process = Runtime.getRuntime().exec(args);
+               try {
+                       Callable<Integer> call = new CallableProcess(process);
+                       Future<Integer> future = service.submit(call);
+                       return future.get(timeoutInSeconds, TimeUnit.SECONDS);
+               } catch (ExecutionException e) {
+                       throw new Exception("Process failed to execute", e);
+               } catch (TimeoutException e) {
+                       process.destroy();
+                       throw new Exception("Process timed out", e);
+               } finally {
+                       service.shutdown();
+               }
+       }
+
+       private static class CallableProcess implements Callable {
+               private Process p;
+
+               public CallableProcess(Process process) {
+                       p = process;
+               }
+
+               public Integer call() throws Exception {
+                       return p.waitFor();
+               }
+       }
+
 }

Reply via email to