Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18660/src/org/rubypeople/rdt/testunit/launcher Modified Files: Tag: SRB_0-6-1 TestUnitLaunchShortcut.java TestUnitRunnerConfiguration.java TestUnitLaunchConfigurationDelegate.java Log Message: fixed problems with finding free ports. Now the procedure is equal for starting from shortcut and from the run configuration dialog. The port is added as attribute to the launch. Index: TestUnitRunnerConfiguration.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitRunnerConfiguration.java,v retrieving revision 1.14 retrieving revision 1.14.2.1 diff -C2 -d -r1.14 -r1.14.2.1 *** TestUnitRunnerConfiguration.java 25 Sep 2005 17:56:54 -0000 1.14 --- TestUnitRunnerConfiguration.java 4 Oct 2005 22:32:55 -0000 1.14.2.1 *************** *** 10,18 **** import org.rubypeople.rdt.core.RubyCore; import org.rubypeople.rdt.internal.launching.InterpreterRunnerConfiguration; - import org.rubypeople.rdt.internal.launching.RdtLaunchingPlugin; import org.rubypeople.rdt.testunit.TestunitPlugin; public class TestUnitRunnerConfiguration extends InterpreterRunnerConfiguration { ! public TestUnitRunnerConfiguration(ILaunchConfiguration aConfiguration) { super(aConfiguration); --- 10,18 ---- import org.rubypeople.rdt.core.RubyCore; import org.rubypeople.rdt.internal.launching.InterpreterRunnerConfiguration; import org.rubypeople.rdt.testunit.TestunitPlugin; public class TestUnitRunnerConfiguration extends InterpreterRunnerConfiguration { ! private int port = -1 ; ! public TestUnitRunnerConfiguration(ILaunchConfiguration aConfiguration) { super(aConfiguration); *************** *** 49,52 **** --- 49,61 ---- } + public int getPort() { + // the port is needed render the command line for the ruby interpreter call + // and in TestUnitPlugin::launchChanged in order to start the server on + // the java side + if (port == -1) { + port = SocketUtil.findFreePort(); + } + return port ; + } /* * (non-Javadoc) *************** *** 54,59 **** * @see org.rubypeople.rdt.internal.launching.InterpreterRunnerConfiguration#getProgramArguments() */ ! public String getProgramArguments() { ! int port = 6789; String fileName = ""; String testClass = ""; --- 63,67 ---- * @see org.rubypeople.rdt.internal.launching.InterpreterRunnerConfiguration#getProgramArguments() */ ! public String getProgramArguments() { String fileName = ""; String testClass = ""; *************** *** 64,69 **** try { // Pull out the port and other unit testing variables ! // and convert them into command line args ! port = configuration.getAttribute(TestUnitLaunchConfigurationDelegate.PORT_ATTR, 6789); fileName = configuration.getAttribute(TestUnitLaunchConfigurationDelegate.LAUNCH_CONTAINER_ATTR, ""); testClass = configuration.getAttribute(TestUnitLaunchConfigurationDelegate.TESTTYPE_ATTR, ""); --- 72,76 ---- try { // Pull out the port and other unit testing variables ! // and convert them into command line args fileName = configuration.getAttribute(TestUnitLaunchConfigurationDelegate.LAUNCH_CONTAINER_ATTR, ""); testClass = configuration.getAttribute(TestUnitLaunchConfigurationDelegate.TESTTYPE_ATTR, ""); *************** *** 71,77 **** } catch (CoreException e) { TestunitPlugin.log(e); } ! return fileName + " " + port + " " + keepAlive + " " + testClass + " " + testMethod; } --- 78,85 ---- } catch (CoreException e) { TestunitPlugin.log(e); + throw new RuntimeException("Could not get necessary attributes from the launch configuration.") ; } ! return fileName + " " + this.getPort() + " " + keepAlive + " " + testClass + " " + testMethod; } Index: TestUnitLaunchConfigurationDelegate.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitLaunchConfigurationDelegate.java,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** TestUnitLaunchConfigurationDelegate.java 2 Mar 2005 01:35:45 -0000 1.2 --- TestUnitLaunchConfigurationDelegate.java 4 Oct 2005 22:32:55 -0000 1.2.2.1 *************** *** 1,4 **** --- 1,5 ---- package org.rubypeople.rdt.testunit.launcher; + import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; import org.rubypeople.rdt.internal.launching.InterpreterRunnerConfiguration; *************** *** 7,12 **** public class TestUnitLaunchConfigurationDelegate extends RubyApplicationLaunchConfigurationDelegate { - - public static final String PORT_ATTR = TestunitPlugin.PLUGIN_ID + ".PORT"; //$NON-NLS-1$ /** * The single test type, or "" iff running a launch container. --- 8,11 ---- *************** *** 28,33 **** } ! protected InterpreterRunnerConfiguration wrapConfiguration(ILaunchConfiguration configuration) { ! return new TestUnitRunnerConfiguration(configuration) ; } --- 27,35 ---- } ! protected InterpreterRunnerConfiguration wrapConfigurationAndHandleLaunch(ILaunchConfiguration configuration, ILaunch launch) { ! ! TestUnitRunnerConfiguration testRunnerConfiguration = new TestUnitRunnerConfiguration(configuration) ; ! launch.setAttribute(TestunitPlugin.TESTUNIT_PORT_ATTR, Integer.toString(testRunnerConfiguration.getPort())) ; ! return testRunnerConfiguration ; } Index: TestUnitLaunchShortcut.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitLaunchShortcut.java,v retrieving revision 1.12 retrieving revision 1.12.2.1 diff -C2 -d -r1.12 -r1.12.2.1 *** TestUnitLaunchShortcut.java 18 Sep 2005 15:18:02 -0000 1.12 --- TestUnitLaunchShortcut.java 4 Oct 2005 22:32:55 -0000 1.12.2.1 *************** *** 139,143 **** wc.setAttribute(RubyLaunchConfigurationAttribute.PROJECT_NAME, rubyFile.getProject().getName()); - int port = SocketUtil.findFreePort(); // FIXME Probably shouldn't write this out. It's now ignored at runtime wc.setAttribute(RubyLaunchConfigurationAttribute.FILE_NAME, TestUnitRunnerConfiguration.getTestRunnerPath()); --- 139,142 ---- *************** *** 147,152 **** wc.setAttribute(TestUnitLaunchConfigurationDelegate.TESTNAME_ATTR, testName); wc.setAttribute(TestUnitLaunchConfigurationDelegate.TESTTYPE_ATTR, ""); - // FIXME shouldn't this be determined at RUN time, not LAUNCH creation time? - wc.setAttribute(TestUnitLaunchConfigurationDelegate.PORT_ATTR, port); wc.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, "org.rubypeople.rdt.debug.ui.rubySourceLocator"); config = wc.doSave(); --- 146,149 ---- |