You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ph...@apache.org on 2013/01/18 13:54:33 UTC
svn commit: r1435120 - in /qpid/proton/branches/jni-binding/tests: pom.xml
src/test/java/org/apache/qpid/proton/JythonTest.java
Author: philharveyonline
Date: Fri Jan 18 12:54:32 2013
New Revision: 1435120
URL: http://svn.apache.org/viewvc?rev=1435120&view=rev
Log:
PROTON-194: allow a subset of the Python tests to be run from Maven using the command line args already support by proton-test
Modified:
qpid/proton/branches/jni-binding/tests/pom.xml
qpid/proton/branches/jni-binding/tests/src/test/java/org/apache/qpid/proton/JythonTest.java
Modified: qpid/proton/branches/jni-binding/tests/pom.xml
URL: http://svn.apache.org/viewvc/qpid/proton/branches/jni-binding/tests/pom.xml?rev=1435120&r1=1435119&r2=1435120&view=diff
==============================================================================
--- qpid/proton/branches/jni-binding/tests/pom.xml (original)
+++ qpid/proton/branches/jni-binding/tests/pom.xml Fri Jan 18 12:54:32 2013
@@ -25,14 +25,18 @@
<artifactId>tests</artifactId>
<version>1.0-SNAPSHOT</version>
- <description><![CDATA[The Proton system tests execute against either the Java or the C implementations, based on the chosen profile.
+ <description>
+The Proton system tests execute against either the Java or the C implementations, based on the chosen profile.
-To execute, run either "mvn test -P proton-j" or "mvn test -P proton-c".
+To execute, run either "mvn test -P proton-j" or "mvn test -P proton-c".
-The proton-c profile looks for the JNI jar and native libraries under directory <basedir>/proton-c/build.
-To override this, run Maven like so: "mvn test -P proton-c -Dproton-c-build-dir=/path/to/build/dir".
-]]>
- </description>
+To reduce the set of Python tests run, set system property proton.pythontest.pattern, for example:
+
+mvn test -Dproton.pythontest.pattern='proton_tests.transport.TransportTest.*'
+
+The proton-c profile looks for the JNI jar and native libraries under directory <basedir>/proton-c/build.
+To override this, run Maven like so: "mvn test -P proton-c -Dproton-c-build-dir=/path/to/build/dir".
+</description>
<build>
<plugins>
Modified: qpid/proton/branches/jni-binding/tests/src/test/java/org/apache/qpid/proton/JythonTest.java
URL: http://svn.apache.org/viewvc/qpid/proton/branches/jni-binding/tests/src/test/java/org/apache/qpid/proton/JythonTest.java?rev=1435120&r1=1435119&r2=1435120&view=diff
==============================================================================
--- qpid/proton/branches/jni-binding/tests/src/test/java/org/apache/qpid/proton/JythonTest.java (original)
+++ qpid/proton/branches/jni-binding/tests/src/test/java/org/apache/qpid/proton/JythonTest.java Fri Jan 18 12:54:32 2013
@@ -27,16 +27,21 @@ import java.util.logging.Logger;
import org.junit.Test;
import org.python.core.PyException;
+import org.python.core.PyString;
+import org.python.core.PySystemState;
import org.python.util.PythonInterpreter;
/**
- * Runs all the python tests.
+ * Runs all the python tests, or just those that match the system property {@value #TEST_PATTERN_SYSTEM_PROPERTY}
+ * if it exists
*/
public class JythonTest
{
- private static final String PROTON_TEST_SCRIPT_CLASSPATH_LOCATION = "/proton-test"; // PHTODO rename script??
private static final Logger LOGGER = Logger.getLogger(JythonTest.class.getName());
+ private static final String TEST_PATTERN_SYSTEM_PROPERTY = "proton.pythontest.pattern";
+ private static final String PROTON_TEST_SCRIPT_CLASSPATH_LOCATION = "/proton-test"; // PHTODO rename script??
+
@Test
public void test() throws Exception
{
@@ -46,9 +51,9 @@ public class JythonTest
File protonScriptFile = getPythonTestScript();
String parentDirectory = protonScriptFile.getParent();
- PythonInterpreter interp = new PythonInterpreter();
+ PythonInterpreter interp = createInterpreterWithArgs();
- LOGGER.info("About to call Jython test script: " + protonScriptFile + " with parent directory: " + parentDirectory + " added to Jython path");
+ LOGGER.info("About to call Jython test script: " + protonScriptFile + " with parent directory added to Jython path");
interp.exec(
"import sys\n"+
@@ -73,6 +78,17 @@ public class JythonTest
}
}
+ private PythonInterpreter createInterpreterWithArgs()
+ {
+ PySystemState systemState = new PySystemState();
+ String testPattern = System.getProperty(TEST_PATTERN_SYSTEM_PROPERTY);
+ if(testPattern != null)
+ {
+ systemState.argv.append(new PyString(testPattern));
+ }
+ PythonInterpreter interp = new PythonInterpreter(null, systemState);
+ return interp;
+ }
private File getPythonTestScript() throws URISyntaxException
{
@@ -80,5 +96,4 @@ public class JythonTest
File protonScriptFile = new File(protonScriptUrl.toURI());
return protonScriptFile;
}
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org