Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1082/src/org/rubypeople/rdt/debug/core/tests Modified Files: TC_DebuggerCommunicationTest.java TestRubyDebugTarget.java TS_Debug.java Added Files: FTC_DebuggerLaunch.java Log Message: fixed port 1098 replaced by variable port Index: TestRubyDebugTarget.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/TestRubyDebugTarget.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestRubyDebugTarget.java 19 Dec 2002 21:15:17 -0000 1.1 --- TestRubyDebugTarget.java 9 Oct 2005 21:22:19 -0000 1.2 *************** *** 129,131 **** --- 129,136 ---- } + + public int getPort() { + return -1; + } + } Index: TC_DebuggerCommunicationTest.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/TC_DebuggerCommunicationTest.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** TC_DebuggerCommunicationTest.java 6 Oct 2005 23:29:56 -0000 1.38 --- TC_DebuggerCommunicationTest.java 9 Oct 2005 21:22:19 -0000 1.39 *************** *** 88,92 **** return tmpDir; } ! private static String RUBY_INTERPRETER; static { RUBY_INTERPRETER = System.getProperty("rdt.rubyInterpreter"); --- 88,92 ---- return tmpDir; } ! public static String RUBY_INTERPRETER; static { RUBY_INTERPRETER = System.getProperty("rdt.rubyInterpreter"); Index: TS_Debug.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/TS_Debug.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TS_Debug.java 20 Mar 2003 22:17:09 -0000 1.4 --- TS_Debug.java 9 Oct 2005 21:22:19 -0000 1.5 *************** *** 11,14 **** --- 11,15 ---- suite.addTestSuite(TC_DebuggerProxyTest.class) ; suite.addTestSuite(TC_ReadStrategyTest.class) ; + suite.addTestSuite(FTC_DebuggerLaunch.class) ; return suite; } --- NEW FILE: FTC_DebuggerLaunch.java --- package org.rubypeople.rdt.debug.core.tests; import java.io.ByteArrayInputStream; import junit.framework.Assert; import junit.framework.TestCase; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationType; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.model.IProcess; import org.rubypeople.eclipse.testutils.ResourceTools; import org.rubypeople.rdt.internal.debug.core.RubyLineBreakpoint; import org.rubypeople.rdt.internal.launching.RubyInterpreter; import org.rubypeople.rdt.internal.launching.RubyLaunchConfigurationAttribute; import org.rubypeople.rdt.internal.launching.RubyRuntime; /* * */ public class FTC_DebuggerLaunch extends TestCase { public void setUp() { this.createInterpreter() ; } protected void createInterpreter() { RubyInterpreter rubyInterpreter = new RubyInterpreter("RubyInterpreter", new Path(TC_DebuggerCommunicationTest.RUBY_INTERPRETER)); RubyRuntime.getDefault().addInstalledInterpreter(rubyInterpreter) ; } protected void log(String label, ILaunch launch) throws Exception { System.out.println("Infos about " + label + ":"); IProcess process = launch.getProcesses()[0]; if (process.isTerminated()) { System.out.println("Process has finished with exit-value: " + process.getExitValue()); } else { System.out.println("Process still running."); } String error = process.getStreamsProxy().getErrorStreamMonitor().getContents(); if (error != null && error.length() > 0) { System.out.println("Process stderr: " + error); } String stdout = process.getStreamsProxy().getOutputStreamMonitor().getContents(); if (stdout != null && stdout.length() > 0) { System.out.println("Process stdout: " + stdout); } } public void testTwoSessions() throws Exception { ILaunchConfigurationType lcT = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(RubyLaunchConfigurationAttribute.RUBY_LAUNCH_CONFIGURATION_TYPE) ; ILaunchConfigurationWorkingCopy wc = lcT.newInstance(null, "TestLaunchConfiguration") ; IProject project = ResourceTools.createProject("FTCDebuggerLaunchMultipleSessions") ; IFile rubyFile = project.getFile("run.rb"); rubyFile.create(new ByteArrayInputStream("puts 'a'\nputs 'b'".getBytes()), true, new NullProgressMonitor()) ; wc.setAttribute(RubyLaunchConfigurationAttribute.PROJECT_NAME, rubyFile.getProject().getName()); wc.setAttribute(RubyLaunchConfigurationAttribute.FILE_NAME, rubyFile.getProjectRelativePath().toString()); //wc.setAttribute(RubyLaunchConfigurationAttribute.WORKING_DIRECTORY, RubyApplicationShortcut.getDefaultWorkingDirectory(rubyFile.getProject())); wc.setAttribute(RubyLaunchConfigurationAttribute.SELECTED_INTERPRETER, RubyRuntime.getDefault().getSelectedInterpreter().getName()); ILaunchConfiguration lc = wc.doSave() ; DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(new RubyLineBreakpoint(rubyFile, 1)) ; ILaunch launch = lc.launch("debug", new NullProgressMonitor()) ; Thread.sleep(5000) ; this.log("1. launch", launch) ; // getDebugTarget returns null if connection between ruby debugger and RubyDebuggerProxy (RubyLoop) could not // be established Assert.assertNotNull(launch.getDebugTarget()) ; Assert.assertTrue(launch.getDebugTarget().getThreads()[0].isSuspended()) ; // the breakpoint we have set for the first launch has disappeard at this point through // a ResourceChanged Event DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(new RubyLineBreakpoint(rubyFile, 1)) ; ILaunch secondlaunch = lc.launch("debug", new NullProgressMonitor()) ; Thread.sleep(5000) ; this.log("2. launch", secondlaunch) ; Assert.assertNotNull(secondlaunch.getDebugTarget()) ; Assert.assertFalse(secondlaunch.getProcesses()[0].isTerminated()) ; Assert.assertTrue(secondlaunch.getDebugTarget().getThreads()[0].isSuspended()) ; } } |