Permalink
Browse files

FLEXMOJOS-418 - patch from Chris Price

  • Loading branch information...
1 parent 7d935fe commit 67c94d5cf8b57672a1bffc9e905b466980d769d3 @velo velo committed Aug 26, 2011
@@ -121,6 +121,20 @@
private String coverageStrategy;
/**
+ * If specified, the testrunner swf will be compiled to use this value as the port to open during test runs.
+ *
+ * @parameter expression="${flex.testPort}"
+ */
+ private Integer testPort;
+
+ /**
+ * If specified, the testrunner swf will be compiled to use this value as the control port to open during test runs.
+ *
+ * @parameter expression="${flex.testControlPort}"
+ */
+ private Integer testControlPort;
+
+ /**
* Files to exclude from testing. If not defined, assumes no exclusions
*
* @parameter
@@ -227,8 +241,12 @@ public void buildTests( List<String> testClasses )
{
String testFilename = "TestRunner";
- Integer testControlPort = freePort();
- Integer testPort = freePort();
+ if (testControlPort == null) {
+ testControlPort = freePort();
+ }
+ if (testPort == null) {
+ testPort = freePort();
+ }
putPluginContext( FLEXMOJOS_TEST_CONTROL_PORT, testControlPort );
putPluginContext( FLEXMOJOS_TEST_PORT, testPort );
getLog().debug( "Flexmojos test port: " + testPort + " - control: " + testControlPort );
@@ -1,15 +1,5 @@
package org.sonatype.flexmojos.plugin.test;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.StringReader;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
import org.apache.maven.plugin.Mojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
@@ -32,6 +22,16 @@
import org.sonatype.flexmojos.test.report.TestCoverageReport;
import org.sonatype.flexmojos.util.PathUtil;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.StringReader;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
/**
* Goal to run unit tests on Flex. It does support the following frameworks:
* <ul>
@@ -168,6 +168,22 @@
*/
private List<String> coverageSourceRoots;
+ /**
+ * If specified, flexmojos will use this value as the port to connect to during test runs.
+ *
+ * @parameter expression="${flex.testPort}"
+ */
+ private Integer testPort;
+
+ /**
+ * If specified, the flexmojos will use this value as the control port to connect to during test runs.
+ *
+ * @parameter expression="${flex.testControlPort}"
+ */
+ private Integer testControlPort;
+
+
+
private Throwable executionError;
private boolean failures = false;
@@ -423,9 +439,16 @@ public void runTest( String swfName, Integer testPort, Integer testControlPort,
public void runTests( String[] swfs, CoverageReporter reporter )
throws MojoExecutionException, MojoFailureException
{
- Integer testPort = getFromPluginContext( TestCompilerMojo.FLEXMOJOS_TEST_PORT );
- Integer testControlPort = getFromPluginContext( TestCompilerMojo.FLEXMOJOS_TEST_CONTROL_PORT );
+ if (testPort == null) {
+ // This will fail if you are trying to run the "test-run" goal in a separate maven execution from the "test-compile" goal!
+ testPort = getFromPluginContext( TestCompilerMojo.FLEXMOJOS_TEST_PORT );
+ }
+ if (testControlPort == null) {
+ // This will fail if you are trying to run the "test-run" goal in a separate maven execution from the "test-compile" goal!
+ testControlPort = getFromPluginContext( TestCompilerMojo.FLEXMOJOS_TEST_CONTROL_PORT );
+ }
getLog().debug( "Found " + swfs.length + " test runners:\n" + Arrays.toString( swfs ) );
+ getLog().debug( "Using test port '" + testPort + "' and test control port '" + testControlPort + "'");
for ( String swfName : swfs )
{
runTest( swfName, testPort, testControlPort, reporter );

0 comments on commit 67c94d5

Please sign in to comment.