|
From: <caw...@us...> - 2007-02-24 20:54:26
|
Revision: 2025
http://svn.sourceforge.net/rubyeclipse/?rev=2025&view=rev
Author: cawilliams
Date: 2007-02-24 12:54:22 -0800 (Sat, 24 Feb 2007)
Log Message:
-----------
try to make test work on Mac OSX - convert strinsg we're comparing ot an independant line delimeter, also remove code inside RubyloadpathVariableInitializer's init method - it doesn't actually do anything anyways, but it had a side-effect that messed up my testing when I blew away the default VM (it would re-initialize the vm types and try to set the default again).
Modified Paths:
--------------
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyLoadpathVariablesInitializer.java
trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RubyRuntime.java
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyLoadpathVariablesInitializer.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyLoadpathVariablesInitializer.java 2007-02-24 19:40:15 UTC (rev 2024)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyLoadpathVariablesInitializer.java 2007-02-24 20:54:22 UTC (rev 2025)
@@ -2,15 +2,12 @@
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceDescription;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.rubypeople.rdt.core.LoadpathVariableInitializer;
import org.rubypeople.rdt.core.RubyCore;
-import org.rubypeople.rdt.launching.IVMInstall;
-import org.rubypeople.rdt.launching.RubyRuntime;
public class RubyLoadpathVariablesInitializer extends LoadpathVariableInitializer {
@@ -18,57 +15,38 @@
@Override
public void initialize(String variable) {
- IVMInstall vmInstall= RubyRuntime.getDefaultVMInstall();
- if (vmInstall != null) {
- IPath newPath= null;
- IPath[] locations= RubyRuntime.getLibraryLocations(vmInstall);
- // FIXME What should we be looking for?!
- // look for rt.jar or classes.zip (both may exist, so do exhaustive search)
- IPath rtjar = null;
- IPath classeszip = null;
- for (int i = 0; i < locations.length; i++) {
- IPath location = locations[i];
- String name = location.lastSegment();
- if (name.equalsIgnoreCase("rt.jar")) { //$NON-NLS-1$
- rtjar = location;
- } else if (name.equalsIgnoreCase("classes.zip")) { //$NON-NLS-1$
- classeszip = location;
- }
- }
- // rt.jar if present, then classes.zip, else the first library
- IPath systemLib = rtjar;
- if (systemLib == null) {
- systemLib = classeszip;
- }
- if (systemLib == null && locations.length > 0) {
- systemLib = locations[0];
- }
- if (systemLib != null) {
- if (variable.equals(RubyRuntime.RUBYLIB_VARIABLE)) {
- newPath= systemLib;
- }
- if (newPath == null) {
- return;
- }
- IWorkspace workspace= ResourcesPlugin.getWorkspace();
- IWorkspaceDescription wsDescription= workspace.getDescription();
- boolean wasAutobuild= wsDescription.isAutoBuilding();
- try {
- setAutobuild(workspace, false);
- setRubyVMVariable(newPath, variable);
- } catch (CoreException ce) {
- LaunchingPlugin.log(ce);
- return;
- } finally {
- try {
- setAutobuild(workspace, wasAutobuild);
- } catch (CoreException ce) {
- LaunchingPlugin.log(ce);
- }
- }
- }
- }
-
+// FIXME What should we be looking for?!
+// IVMInstall vmInstall= RubyRuntime.getDefaultVMInstall();
+// if (vmInstall != null) {
+// IPath newPath= null;
+// IPath[] locations= RubyRuntime.getLibraryLocations(vmInstall);
+//
+//
+// if (systemLib != null) {
+// if (variable.equals(RubyRuntime.RUBYLIB_VARIABLE)) {
+// newPath= systemLib;
+// }
+// if (newPath == null) {
+// return;
+// }
+// IWorkspace workspace= ResourcesPlugin.getWorkspace();
+// IWorkspaceDescription wsDescription= workspace.getDescription();
+// boolean wasAutobuild= wsDescription.isAutoBuilding();
+// try {
+// setAutobuild(workspace, false);
+// setRubyVMVariable(newPath, variable);
+// } catch (CoreException ce) {
+// LaunchingPlugin.log(ce);
+// return;
+// } finally {
+// try {
+// setAutobuild(workspace, wasAutobuild);
+// } catch (CoreException ce) {
+// LaunchingPlugin.log(ce);
+// }
+// }
+// }
+// }
}
private void setRubyVMVariable(IPath newPath, String var) throws CoreException {
Modified: trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RubyRuntime.java
===================================================================
--- trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RubyRuntime.java 2007-02-24 19:40:15 UTC (rev 2024)
+++ trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RubyRuntime.java 2007-02-24 20:54:22 UTC (rev 2025)
@@ -7,6 +7,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.rubypeople.rdt.core.tests.ModifyingResourceTest;
+import org.rubypeople.rdt.core.tests.util.Util;
import org.rubypeople.rdt.launching.IVMInstall;
import org.rubypeople.rdt.launching.IVMInstallType;
import org.rubypeople.rdt.launching.RubyRuntime;
@@ -27,8 +28,13 @@
@Override
protected void setUp() throws Exception {
super.setUp();
+ RubyRuntime.getVMInstallTypes();
vmType = RubyRuntime.getVMInstallType(VM_TYPE_ID);
RubyRuntime.setDefaultVMInstall(null, null, true);
+ IVMInstall[] installs = vmType.getVMInstalls();
+ for (int i = 0; i < installs.length; i++) {
+ vmType.disposeVMInstall(installs[i].getId());
+ }
LaunchingPlugin.getDefault().setIgnoreVMDefPropertyChangeEvents(true);
createProject("/rubyRuntime");
folderOne = createFolder("/rubyRuntime/interpreterOne");
@@ -43,11 +49,15 @@
@Override
protected void tearDown() throws Exception {
- super.tearDown();
+ RubyRuntime.setDefaultVMInstall(null, null, true);
+ IVMInstall[] installs = vmType.getVMInstalls();
+ for (int i = 0; i < installs.length; i++) {
+ vmType.disposeVMInstall(installs[i].getId());
+ }
vmType = null;
- RubyRuntime.setDefaultVMInstall(null, null, true);
RubyRuntime.getPreferences().setValue(RubyRuntime.PREF_VM_XML, "");
deleteProject("/rubyRuntime");
+ super.tearDown();
}
public void testGetInstalledInterpreters() {
@@ -57,17 +67,16 @@
String vmTwoId = vmTwoName;
try {
VMStandin standin = new VMStandin(vmType, vmOneId);
- standin.setInstallLocation(new File("C:/RubyInstallRootOne"));
+ standin.setInstallLocation(folderOne.getLocation().toFile());
standin.setName(vmOneName);
standin.convertToRealVM();
VMStandin standin2 = new VMStandin(vmType, vmTwoId);
- standin2.setInstallLocation(new File("C:/RubyInstallRootTwo"));
+ standin2.setInstallLocation(folderTwo.getLocation().toFile());
standin2.setName(vmTwoName);
standin2.convertToRealVM();
- IVMInstallType myType = RubyRuntime.getVMInstallType(VM_TYPE_ID);
- IVMInstall[] installs = myType.getVMInstalls();
+ IVMInstall[] installs = vmType.getVMInstalls();
assertEquals(2, installs.length);
assertEquals(vmOneName, installs[0].getName());
assertEquals(vmTwoName, installs[1].getName());
@@ -86,46 +95,50 @@
VMStandin standin = new VMStandin(vmType, vmOneId);
standin.setInstallLocation(folderOne.getLocation().toFile());
standin.setName(vmOneName);
+ RubyRuntime.getVMInstallTypes();
IVMInstall one = standin.convertToRealVM();
RubyRuntime.setDefaultVMInstall(one, null,true);
+ assertEquals(1, vmType.getVMInstalls().length);
IPath vmOneLocation = folderOne.getLocation();
assertEquals(
"XML should indicate only one interpreter with it being the one selected.",
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" +
+ Util.convertToIndependantLineDelimiter("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" +
"<vmSettings defaultVM=\"43,org.rubypeople.rdt.launching.StandardVMType14," + vmOneId + "\">\r\n" +
"<vmType id=\"org.rubypeople.rdt.launching.StandardVMType\">\r\n" +
vmToXML(vmOneId, vmOneName, vmOneLocation) +
"</vmType>\r\n" +
- "</vmSettings>\r\n",
- getVMsXML());
+ "</vmSettings>\r\n"),
+ Util.convertToIndependantLineDelimiter(getVMsXML()));
IPath vmTwoLocation = folderTwo.getLocation();
VMStandin standin2 = new VMStandin(vmType, vmTwoId);
standin2.setInstallLocation(vmTwoLocation.toFile());
standin2.setName(vmTwoName);
IVMInstall two = standin2.convertToRealVM();
RubyRuntime.saveVMConfiguration();
+ assertEquals(2, vmType.getVMInstalls().length);
assertEquals(
"XML should indicate both interpreters with the first one being selected.",
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" +
+ Util.convertToIndependantLineDelimiter("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" +
"<vmSettings defaultVM=\"43,org.rubypeople.rdt.launching.StandardVMType14," + vmOneId + "\">\r\n" +
"<vmType id=\"org.rubypeople.rdt.launching.StandardVMType\">\r\n" +
vmToXML(vmOneId, vmOneName, vmOneLocation) +
vmToXML(vmTwoId, vmTwoName, vmTwoLocation) +
"</vmType>\r\n" +
- "</vmSettings>\r\n",
- getVMsXML());
+ "</vmSettings>\r\n"),
+ Util.convertToIndependantLineDelimiter(getVMsXML()));
RubyRuntime.setDefaultVMInstall(two, null,true);
+ assertEquals(2, vmType.getVMInstalls().length);
assertEquals(
"XML should indicate both interpreters with the second one being selected.",
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" +
+ Util.convertToIndependantLineDelimiter("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" +
"<vmSettings defaultVM=\"" + RubyRuntime.getCompositeIdFromVM(standin2) + "\">\r\n" +
"<vmType id=\"org.rubypeople.rdt.launching.StandardVMType\">\r\n" +
vmToXML(vmOneId, vmOneName, vmOneLocation) +
vmToXML(vmTwoId, vmTwoName, vmTwoLocation) +
"</vmType>\r\n" +
- "</vmSettings>\r\n",
- getVMsXML());
+ "</vmSettings>\r\n"),
+ Util.convertToIndependantLineDelimiter(getVMsXML()));
} finally {
vmType.disposeVMInstall(vmOneId);
vmType.disposeVMInstall(vmTwoId);
@@ -152,7 +165,7 @@
xml.append("<libraryLocation src=\"");
xml.append(location.toPortableString());
xml.append("/lib/ruby/1.8\"/>\r\n");
- File file = LaunchingPlugin.getFileInPlugin(new Path("ruby/" + id + "/lib"));
+ File file = LaunchingPlugin.getFileInPlugin(new Path("ruby" + File.separator + id + File.separator + "lib"));
xml.append("<libraryLocation src=\"");
xml.append(Path.fromOSString(file.toString()).toPortableString());
xml.append("\"/>\r\n");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|