|
From: <caw...@us...> - 2007-01-20 22:53:23
|
Revision: 1832
http://svn.sourceforge.net/rubyeclipse/?rev=1832&view=rev
Author: cawilliams
Date: 2007-01-20 14:53:20 -0800 (Sat, 20 Jan 2007)
Log Message:
-----------
hey look at that! The Test::Unit launcher stuff works again. I should probably clean it up a bunch more...
Modified Paths:
--------------
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitLaunchConfigurationDelegate.java
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitLaunchShortcut.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitRunnerConfiguration.java
Modified: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitLaunchConfigurationDelegate.java
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitLaunchConfigurationDelegate.java 2007-01-20 22:15:24 UTC (rev 1831)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitLaunchConfigurationDelegate.java 2007-01-20 22:53:20 UTC (rev 1832)
@@ -1,5 +1,13 @@
package org.rubypeople.rdt.testunit.launcher;
+import java.io.File;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.core.SocketUtil;
import org.rubypeople.rdt.internal.testunit.ui.TestunitPlugin;
import org.rubypeople.rdt.launching.RubyLaunchDelegate;
@@ -18,9 +26,44 @@
public static final String LAUNCH_CONTAINER_ATTR = TestunitPlugin.PLUGIN_ID + ".CONTAINER"; //$NON-NLS-1$
public static final String ID_TESTUNIT_APPLICATION = "org.rubypeople.rdt.testunit.launchconfig"; //$NON-NLS-1$
+
+ private int port = -1;
- public TestUnitLaunchConfigurationDelegate() {
- super();
+ @Override
+ public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
+ launch.setAttribute(TestunitPlugin.TESTUNIT_PORT_ATTR, Integer.toString(getPort()));
+ super.launch(configuration, mode, launch, monitor);
}
-// FIXME This won't work anymore!
+
+ public static String getTestRunnerPath() {
+ String directory = RubyCore.getOSDirectory(TestunitPlugin.getDefault());
+ File pluginDirFile = new File(directory, "ruby");
+
+ if (!pluginDirFile.exists())
+ throw new RuntimeException("Expected directory of RemoteTestRunner.rb does not exist: " + pluginDirFile.getAbsolutePath());
+
+ return pluginDirFile.getAbsolutePath() + File.separator + TestUnitLaunchShortcut.TEST_RUNNER_FILE;
+ }
+
+ private int getPort() {
+ if (port == -1) {
+ port = SocketUtil.findFreePort();
+ }
+ return port;
+ }
+
+ @Override
+ public String getProgramArguments(ILaunchConfiguration configuration) throws CoreException {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(configuration.getAttribute(TestUnitLaunchConfigurationDelegate.LAUNCH_CONTAINER_ATTR, ""));
+ buffer.append(' ');
+ buffer.append(Integer.toString(getPort()));
+ buffer.append(' ');
+ buffer.append(Boolean.toString(false));
+ buffer.append(' ');
+ buffer.append(configuration.getAttribute(TestUnitLaunchConfigurationDelegate.TESTTYPE_ATTR, ""));
+ buffer.append(' ');
+ buffer.append(configuration.getAttribute(TestUnitLaunchConfigurationDelegate.TESTNAME_ATTR, ""));
+ return buffer.toString();
+ }
}
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitLaunchShortcut.java
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitLaunchShortcut.java 2007-01-20 22:15:24 UTC (rev 1831)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitLaunchShortcut.java 2007-01-20 22:53:20 UTC (rev 1832)
@@ -46,7 +46,6 @@
* @param rubyElement
*/
protected void doLaunch(IRubyElement rubyElement, String mode) throws CoreException {
-
String container = getContainer(rubyElement);
ILaunchConfiguration config = findOrCreateLaunchConfiguration(rubyElement, mode, container, "", "");
if (config != null) {
@@ -58,10 +57,10 @@
protected ILaunchConfiguration findOrCreateLaunchConfiguration(IRubyElement rubyElement, String mode, String container, String testClass, String testName) throws CoreException {
IFile rubyFile = (IFile) rubyElement.getUnderlyingResource();
ILaunchConfigurationType configType = getRubyLaunchConfigType();
- List candidateConfigs = null;
+ List<ILaunchConfiguration> candidateConfigs = null;
ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations(configType);
- candidateConfigs = new ArrayList(configs.length);
+ candidateConfigs = new ArrayList<ILaunchConfiguration>(configs.length);
for (int i = 0; i < configs.length; i++) {
ILaunchConfiguration config = configs[i];
if ((config.getAttribute(TestUnitLaunchConfigurationDelegate.LAUNCH_CONTAINER_ATTR, "").equals(container))
@@ -137,9 +136,7 @@
ILaunchConfigurationType configType = getRubyLaunchConfigType();
ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager().generateUniqueLaunchConfigurationNameFrom(rubyFile.getName()));
wc.setAttribute(RubyLaunchConfigurationAttribute.PROJECT_NAME, rubyFile.getProject().getName());
-
- // FIXME Probably shouldn't write this out. It's now ignored at runtime
- wc.setAttribute(RubyLaunchConfigurationAttribute.FILE_NAME, TestUnitRunnerConfiguration.getTestRunnerPath());
+ wc.setAttribute(RubyLaunchConfigurationAttribute.FILE_NAME, TestUnitLaunchConfigurationDelegate.getTestRunnerPath());
wc.setAttribute(RubyLaunchConfigurationAttribute.WORKING_DIRECTORY, TestUnitLaunchShortcut.getDefaultWorkingDirectory(rubyFile.getProject()));
wc.setAttribute(RubyLaunchConfigurationAttribute.SELECTED_INTERPRETER, RubyRuntime.getCompositeIdFromVM(RubyRuntime.getDefaultVMInstall()));
wc.setAttribute(TestUnitLaunchConfigurationDelegate.LAUNCH_CONTAINER_ATTR, container);
Deleted: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitRunnerConfiguration.java
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitRunnerConfiguration.java 2007-01-20 22:15:24 UTC (rev 1831)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitRunnerConfiguration.java 2007-01-20 22:53:20 UTC (rev 1832)
@@ -1,108 +0,0 @@
-package org.rubypeople.rdt.testunit.launcher;
-
-import java.io.File;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.rubypeople.rdt.core.RubyCore;
-import org.rubypeople.rdt.core.SocketUtil;
-import org.rubypeople.rdt.internal.testunit.ui.TestunitPlugin;
-import org.rubypeople.rdt.launching.VMRunnerConfiguration;
-
-public class TestUnitRunnerConfiguration extends VMRunnerConfiguration {
- private int port = -1 ;
- private ILaunchConfiguration configuration;
-
- public TestUnitRunnerConfiguration(ILaunchConfiguration aConfiguration) {
- super(getTestRunnerPath(), null);
- configuration = aConfiguration;
- }
-
- public String getAbsoluteFileName() {
- return new File(getFileName()).getAbsolutePath();
- }
-
- public String getFileName() {
- return getTestRunnerPath();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.rubypeople.rdt.internal.launching.InterpreterRunnerConfiguration#getAbsoluteFileDirectory()
- */
- public String getAbsoluteFileDirectory() {
- IPath path = new Path(this.getFileName());
- path = path.removeLastSegments(1);
- return path.toOSString();
- }
-
- public String getAbsoluteTestFileName() {
- String fileName = "";
- try {
- fileName = configuration.getAttribute(TestUnitLaunchConfigurationDelegate.LAUNCH_CONTAINER_ATTR, "");
- } catch (CoreException e) {}
-
- IPath path = new Path(fileName);
- path = path.removeLastSegments(1);
- return path.toOSString();
- }
-
- 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)
- *
- * @see org.rubypeople.rdt.launching.VMRunnerConfiguration#getProgramArguments()
- */
- public String[] getProgramArguments() {
- String fileName = "";
- String testClass = "";
- String testMethod = "";
- // FIXME Remove keepAlive on this end and remove looking for it on
- // RemoteTestRunner.rb
- boolean keepAlive = false;
- 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, "");
- testMethod = configuration.getAttribute(TestUnitLaunchConfigurationDelegate.TESTNAME_ATTR, "");
- } catch (CoreException e) {
- TestunitPlugin.log(e);
- throw new RuntimeException("Could not get necessary attributes from the launch configuration.") ;
- }
-
- return new String[] { fileName, Integer.toString(getPort()), Boolean.toString(keepAlive), testClass, testMethod};
- }
-
- public String[] getLoadPath() {
- String[] loadPath = super.getLoadPath();
- String[] newLoadPath = new String[loadPath.length + 1];
- for (int i = 0; i < loadPath.length; i++) {
- newLoadPath[i] = loadPath[i];
- }
- newLoadPath[loadPath.length] = getAbsoluteTestFileName();
- return newLoadPath;
- }
-
- public static String getTestRunnerPath() {
- String directory = RubyCore.getOSDirectory(TestunitPlugin.getDefault());
- File pluginDirFile = new File(directory, "ruby");
-
- if (!pluginDirFile.exists())
- throw new RuntimeException("Expected directory of RemoteTestRunner.rb does not exist: " + pluginDirFile.getAbsolutePath());
-
- return pluginDirFile.getAbsolutePath() + File.separator + TestUnitLaunchShortcut.TEST_RUNNER_FILE;
- }
-}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|