Continued modernizing the debugger interface. jsonrpc

Thu, 01 Sep 2016 20:03:50 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 01 Sep 2016 20:03:50 +0200
branch
jsonrpc
changeset 5125
eb1b3e0577e4
parent 5124
1ba8ee313b57
child 5128
b6cbdba69967

Continued modernizing the debugger interface.

DebugClients/Python3/DebugBase.py file | annotate | diff | comparison | revisions
DebugClients/Python3/DebugClientBase.py file | annotate | diff | comparison | revisions
Debugger/DebuggerInterfacePython3.py file | annotate | diff | comparison | revisions
--- a/DebugClients/Python3/DebugBase.py	Thu Sep 01 19:00:46 2016 +0200
+++ b/DebugClients/Python3/DebugBase.py	Thu Sep 01 20:03:50 2016 +0200
@@ -246,7 +246,8 @@
             return self.trace_dispatch
         if event == 'c_return':
             return self.trace_dispatch
-        print('bdb.Bdb.dispatch: unknown debugging event: ', repr(event))   # __IGNORE_WARNING__
+        print('DebugBase.trace_dispatch: unknown debugging event: ',       # __IGNORE_WARNING__
+              repr(event))
         return self.trace_dispatch
 
     def dispatch_line(self, frame):
--- a/DebugClients/Python3/DebugClientBase.py	Thu Sep 01 19:00:46 2016 +0200
+++ b/DebugClients/Python3/DebugClientBase.py	Thu Sep 01 20:03:50 2016 +0200
@@ -863,55 +863,55 @@
 ##                self.__generateFilterObjects(int(scope), filterString)
 ##                return
 ##            
-            if cmd == DebugProtocol.RequestUTPrepare:
-                fn, tn, tfn, failed, cov, covname, erase = arg.split('|')
-                sys.path.insert(0, os.path.dirname(os.path.abspath(fn)))
-                os.chdir(sys.path[0])
-                failed = eval(failed)
-
-                # set the system exception handling function to ensure, that
-                # we report on all unhandled exceptions
-                sys.excepthook = self.__unhandled_exception
-                self.__interceptSignals()
-                
-                try:
-                    import unittest
-                    utModule = imp.load_source(tn, fn)
-                    try:
-                        if failed:
-                            self.test = unittest.defaultTestLoader\
-                                .loadTestsFromNames(failed, utModule)
-                        else:
-                            self.test = unittest.defaultTestLoader\
-                                .loadTestsFromName(tfn, utModule)
-                    except AttributeError:
-                        self.test = unittest.defaultTestLoader\
-                            .loadTestsFromModule(utModule)
-                except Exception:
-                    exc_type, exc_value, exc_tb = sys.exc_info()
-                    self.write('{0}{1}\n'.format(
-                        DebugProtocol.ResponseUTPrepared,
-                        str((0, str(exc_type), str(exc_value)))))
-                    self.__exceptionRaised()
-                    return
-                
-                # generate a coverage object
-                if int(cov):
-                    from coverage import coverage
-                    self.cover = coverage(
-                        auto_data=True,
-                        data_file="{0}.coverage".format(
-                            os.path.splitext(covname)[0]))
-                    if int(erase):
-                        self.cover.erase()
-                else:
-                    self.cover = None
-                
-                self.write('{0}{1}\n'.format(
-                    DebugProtocol.ResponseUTPrepared,
-                    str((self.test.countTestCases(), "", ""))))
-                return
-            
+##            if cmd == DebugProtocol.RequestUTPrepare:
+##                fn, tn, tfn, failed, cov, covname, erase = arg.split('|')
+##                sys.path.insert(0, os.path.dirname(os.path.abspath(fn)))
+##                os.chdir(sys.path[0])
+##                failed = eval(failed)
+##
+##                # set the system exception handling function to ensure, that
+##                # we report on all unhandled exceptions
+##                sys.excepthook = self.__unhandled_exception
+##                self.__interceptSignals()
+##                
+##                try:
+##                    import unittest
+##                    utModule = imp.load_source(tn, fn)
+##                    try:
+##                        if failed:
+##                            self.test = unittest.defaultTestLoader\
+##                                .loadTestsFromNames(failed, utModule)
+##                        else:
+##                            self.test = unittest.defaultTestLoader\
+##                                .loadTestsFromName(tfn, utModule)
+##                    except AttributeError:
+##                        self.test = unittest.defaultTestLoader\
+##                            .loadTestsFromModule(utModule)
+##                except Exception:
+##                    exc_type, exc_value, exc_tb = sys.exc_info()
+##                    self.write('{0}{1}\n'.format(
+##                        DebugProtocol.ResponseUTPrepared,
+##                        str((0, str(exc_type), str(exc_value)))))
+##                    self.__exceptionRaised()
+##                    return
+##                
+##                # generate a coverage object
+##                if int(cov):
+##                    from coverage import coverage
+##                    self.cover = coverage(
+##                        auto_data=True,
+##                        data_file="{0}.coverage".format(
+##                            os.path.splitext(covname)[0]))
+##                    if int(erase):
+##                        self.cover.erase()
+##                else:
+##                    self.cover = None
+##                
+##                self.write('{0}{1}\n'.format(
+##                    DebugProtocol.ResponseUTPrepared,
+##                    str((self.test.countTestCases(), "", ""))))
+##                return
+##            
             if cmd == DebugProtocol.RequestUTRun:
                 from DCTestResult import DCTestResult
                 self.testResult = DCTestResult(self)
@@ -1489,6 +1489,67 @@
         if method == "RequestCompletion":
             self.__completionList(params["text"])
             return
+        
+        if method == "RequestUTPrepare":
+##            fn, tn, tfn, failed, cov, covname, erase = arg.split('|')
+##            sys.path.insert(0, os.path.dirname(os.path.abspath(fn)))
+##            os.chdir(sys.path[0])
+##            failed = eval(failed)
+##
+            # set the system exception handling function to ensure, that
+            # we report on all unhandled exceptions
+            sys.excepthook = self.__unhandled_exception
+            self.__interceptSignals()
+            
+            try:
+                import unittest
+                utModule = imp.load_source(
+                    params["testname"], params["filename"])
+                try:
+                    if params["failed"]:
+                        self.test = unittest.defaultTestLoader\
+                            .loadTestsFromNames(params["failed"], utModule)
+                    else:
+                        self.test = unittest.defaultTestLoader\
+                            .loadTestsFromName(params["testfunctionname"],
+                                               utModule)
+                except AttributeError:
+                    self.test = unittest.defaultTestLoader\
+                        .loadTestsFromModule(utModule)
+            except Exception:
+                exc_type, exc_value, exc_tb = sys.exc_info()
+##                self.write('{0}{1}\n'.format(
+##                    DebugProtocol.ResponseUTPrepared,
+##                    str((0, str(exc_type), str(exc_value)))))
+                self.__sendJsonCommand("ResponseUTPrepared", {
+                    "count": 0,
+                    "exception": exc_type.__name__,
+                    "message": str(exc_value),
+                })
+                self.__exceptionRaised()
+                return
+            
+            # generate a coverage object
+            if params["coverage"]:
+                from coverage import coverage
+                self.cover = coverage(
+                    auto_data=True,
+                    data_file="{0}.coverage".format(
+                        os.path.splitext(params["coveragefile"])[0]))
+                if params["coverageerase"]:
+                    self.cover.erase()
+            else:
+                self.cover = None
+            
+##            self.write('{0}{1}\n'.format(
+##                DebugProtocol.ResponseUTPrepared,
+##                str((self.test.countTestCases(), "", ""))))
+            self.__sendJsonCommand("ResponseUTPrepared", {
+                "count": self.test.countTestCases(),
+                "exception": "",
+                "message": "",
+            })
+            return
     
     def __sendJsonCommand(self, command, params):
         """
--- a/Debugger/DebuggerInterfacePython3.py	Thu Sep 01 19:00:46 2016 +0200
+++ b/Debugger/DebuggerInterfacePython3.py	Thu Sep 01 20:03:50 2016 +0200
@@ -867,9 +867,18 @@
         self.__scriptName = os.path.abspath(fn)
         
         fn = self.translate(os.path.abspath(fn), False)
-        self.__sendCommand('{0}{1}|{2}|{3}|{4}|{5:d}|{6}|{7:d}\n'.format(
-            DebugProtocol.RequestUTPrepare, fn, tn, tfn, str(failed),
-            cov, covname, coverase))
+##        self.__sendCommand('{0}{1}|{2}|{3}|{4}|{5:d}|{6}|{7:d}\n'.format(
+##            DebugProtocol.RequestUTPrepare, fn, tn, tfn, str(failed),
+##            cov, covname, coverase))
+        self.__sendJsonCommand("RequestUTPrepare", {
+            "filename": fn,
+            "testname": tn,
+            "testfunctionname": tfn,
+            "failed": failed,
+            "coverage": cov,
+            "coveragefile": covname,
+            "coverageerase": coverase,
+        })
     
     def remoteUTRun(self):
         """
@@ -1110,11 +1119,11 @@
 ##                    self.debugServer.passiveStartUp(fn, exc)
 ##                    continue
 ##                
-                if resp == DebugProtocol.ResponseUTPrepared:
-                    res, exc_type, exc_value = eval(line[eoc:-1])
-                    self.debugServer.clientUtPrepared(res, exc_type, exc_value)
-                    continue
-                
+##                if resp == DebugProtocol.ResponseUTPrepared:
+##                    res, exc_type, exc_value = eval(line[eoc:-1])
+##                    self.debugServer.clientUtPrepared(res, exc_type, exc_value)
+##                    continue
+##                
                 if resp == DebugProtocol.ResponseUTStartTest:
                     testname, doc = eval(line[eoc:-1])
                     self.debugServer.clientUtStartTest(testname, doc)
@@ -1315,11 +1324,14 @@
             return
         
         if method == "ResponseCompletion":
-##                    clstring, text = line[eoc:-1].split('||')
-##                    cl = eval(clstring)
             self.debugServer.signalClientCompletionList(
                 params["completions"], params["text"])
             return
+        
+        if method == "ResponseUTPrepared":
+            self.debugServer.clientUtPrepared(
+                params["count"], params["exception"], params["message"])
+            return
     
     def __sendCommand(self, cmd):
         """

eric ide

mercurial