|
From: Markus B. <mba...@us...> - 2005-10-06 23:30:07
|
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-serv21432/src/org/rubypeople/rdt/debug/core/tests Modified Files: TC_DebuggerCommunicationTest.java TC_DebuggerProxyTest.java Log Message: RubyExceptionBreakpoints / catchpoints functionality added Index: TC_DebuggerProxyTest.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/TC_DebuggerProxyTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TC_DebuggerProxyTest.java 21 Jan 2003 13:30:13 -0000 1.2 --- TC_DebuggerProxyTest.java 6 Oct 2005 23:29:56 -0000 1.3 *************** *** 1,4 **** --- 1,6 ---- package org.rubypeople.rdt.debug.core.tests; + import java.io.BufferedReader; + import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; *************** *** 9,13 **** --- 11,17 ---- import junit.framework.TestCase; + import org.eclipse.core.runtime.CoreException; import org.rubypeople.rdt.internal.debug.core.RubyDebuggerProxy; + import org.rubypeople.rdt.internal.debug.core.RubyExceptionBreakpoint; import org.rubypeople.rdt.internal.debug.core.model.ThreadInfo; import org.xmlpull.v1.XmlPullParser; *************** *** 18,21 **** --- 22,26 ---- private RubyDebuggerProxy proxy ; private TestRubyDebugTarget target ; + private BufferedReader proxyOutputReader ; public TC_DebuggerProxyTest(String name) { *************** *** 40,47 **** } public void setUp() throws Exception { target = new TestRubyDebugTarget() ; proxy = new RubyDebuggerProxy(target) ; ! proxy.setWriter(new PrintWriter(new OutputStreamWriter(System.out))) ; XmlPullParserFactory factory = XmlPullParserFactory.newInstance("org.kxml2.io.KXmlParser,org.kxml2.io.KXmlSerializer", null); XmlPullParser xpp = factory.newPullParser(); --- 45,60 ---- } + public String getLineFromDebuggerProxy() throws IOException { + + return proxyOutputReader.readLine() ; + } + public void setUp() throws Exception { target = new TestRubyDebugTarget() ; proxy = new RubyDebuggerProxy(target) ; ! PipedInputStream pipedInputStream = new PipedInputStream() ; ! PipedOutputStream pipedOutputStream = new PipedOutputStream(pipedInputStream) ; ! ! proxy.setWriter(new PrintWriter(pipedOutputStream)) ; XmlPullParserFactory factory = XmlPullParserFactory.newInstance("org.kxml2.io.KXmlParser,org.kxml2.io.KXmlSerializer", null); XmlPullParser xpp = factory.newPullParser(); *************** *** 51,55 **** proxy.setXpp(xpp) ; proxy.startRubyLoop() ; ! writer = new PrintWriter(new OutputStreamWriter(outputStream)) ; } --- 64,69 ---- proxy.setXpp(xpp) ; proxy.startRubyLoop() ; ! writer = new PrintWriter(new OutputStreamWriter(outputStream)) ; ! proxyOutputReader = new BufferedReader(new InputStreamReader(pipedInputStream)) ; } *************** *** 78,80 **** --- 92,102 ---- } + + public void testExceptionBreakpoint() throws IOException, CoreException { + RubyExceptionBreakpoint rubyExceptionBreakpoint = new RubyExceptionBreakpoint("MyStandardError") ; + proxy.addBreakpoint( rubyExceptionBreakpoint ) ; + proxy.getWriter().flush() ; + assertEquals("cont", this.getLineFromDebuggerProxy()) ; + assertEquals("catch MyStandardError", this.getLineFromDebuggerProxy()) ; + } } 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.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** TC_DebuggerCommunicationTest.java 1 Oct 2005 23:10:38 -0000 1.37 --- TC_DebuggerCommunicationTest.java 6 Oct 2005 23:29:56 -0000 1.38 *************** *** 48,53 **** //suite.addTest(new TC_DebuggerCommunicationTest("testVariableInstanceNested")); //suite.addTest(new TC_DebuggerCommunicationTest("testStaticVariableInstanceNested")); ! //suite.addTest(new TC_DebuggerCommunicationTest("testException")); ! suite.addTest(new TC_DebuggerCommunicationTest("testNameError")); //suite.addTest(new TC_DebuggerCommunicationTest("testVariablesInObject")); //suite.addTest(new TC_DebuggerCommunicationTest("testStaticVariables")); --- 48,53 ---- //suite.addTest(new TC_DebuggerCommunicationTest("testVariableInstanceNested")); //suite.addTest(new TC_DebuggerCommunicationTest("testStaticVariableInstanceNested")); ! ! //suite.addTest(new TC_DebuggerCommunicationTest("testNameError")); //suite.addTest(new TC_DebuggerCommunicationTest("testVariablesInObject")); //suite.addTest(new TC_DebuggerCommunicationTest("testStaticVariables")); *************** *** 68,71 **** --- 68,74 ---- //suite.addTest(new TC_DebuggerCommunicationTest("testReloadInRequire")) ; //suite.addTest(new TC_DebuggerCommunicationTest("testReloadInStackFrame")) ; + suite.addTest(new TC_DebuggerCommunicationTest("testIgnoreException")); + suite.addTest(new TC_DebuggerCommunicationTest("testExceptionHierarchy")); + suite.addTest(new TC_DebuggerCommunicationTest("testException")); return suite; *************** *** 309,312 **** --- 312,317 ---- public void testException() throws Exception { + // per default catch is set to StandardError, i.e. every raise of a subclass of StandardError + // will suspend createSocket(new String[] { "puts 'a'", "raise 'message \\dir\\file: <xml/>\n<8>'", "puts 'c'" }); sendRuby("cont"); *************** *** 322,325 **** --- 327,353 ---- } + public void testIgnoreException() throws Exception { + createSocket(new String[] { "puts 'a'", "raise 'dont stop'" }); + sendRuby("catch off"); + sendRuby("cont"); + System.out.println("Waiting for the program to finish without suspending at the raise command"); + SuspensionPoint hit = getSuspensionReader().readSuspension(); + assertNull(hit); + } + + public void testExceptionHierarchy() throws Exception { + createSocket(new String[] { "class MyError < StandardError", "end", "begin", "raise StandardError.new", "rescue", "end", "raise MyError.new"}); + sendRuby("catch MyError"); + sendRuby("cont"); + System.out.println("Waiting for the program to finish without suspending at the raise command"); + SuspensionPoint hit = getSuspensionReader().readSuspension(); + assertNotNull(hit); + assertEquals(7, hit.getLine()); + assertEquals("MyError", ((ExceptionSuspensionPoint) hit).getExceptionType()); + sendRuby("cont"); + hit = getSuspensionReader().readSuspension(); + assertNull(hit); + } + public void testBreakpointNeverReached() throws Exception { createSocket(new String[] { "puts 'a'", "puts 'b'", "puts 'c'" }); |