Debugger/DebugServer.py

branch
maintenance
changeset 6923
d062df8f1d9f
parent 6646
51eefa621de4
parent 6904
3f35037a08d4
equal deleted inserted replaced
6827:14680839ad7a 6923:d062df8f1d9f
67 the client side 67 the client side
68 @signal clientSyntaxError(exception) emitted after a syntax error has been 68 @signal clientSyntaxError(exception) emitted after a syntax error has been
69 detected on the client side 69 detected on the client side
70 @signal clientSignal(signal) emitted after a signal has been generated on 70 @signal clientSignal(signal) emitted after a signal has been generated on
71 the client side 71 the client side
72 @signal clientExit(int) emitted with the exit status after the client has 72 @signal clientExit(int, str, bool) emitted after the client has exited
73 exited 73 giving the exit status, an exit message and an indication to be quiet
74 @signal clientClearBreak(filename, lineno) emitted after the debug client 74 @signal clientClearBreak(filename, lineno) emitted after the debug client
75 has decided to clear a temporary breakpoint 75 has decided to clear a temporary breakpoint
76 @signal clientBreakConditionError(fn, lineno) emitted after the client has 76 @signal clientBreakConditionError(fn, lineno) emitted after the client has
77 signaled a syntax error in a breakpoint condition 77 signaled a syntax error in a breakpoint condition
78 @signal clientClearWatch(condition) emitted after the debug client 78 @signal clientClearWatch(condition) emitted after the debug client
92 connected in passive debug mode 92 connected in passive debug mode
93 @signal clientGone(bool) emitted if the client went away (planned or 93 @signal clientGone(bool) emitted if the client went away (planned or
94 unplanned) 94 unplanned)
95 @signal clientInterpreterChanged(str) emitted to signal a change of the 95 @signal clientInterpreterChanged(str) emitted to signal a change of the
96 client interpreter 96 client interpreter
97 @signal utDiscovered(testCases, exc_type, exc_value) emitted after the
98 client has performed a test case discovery action
97 @signal utPrepared(nrTests, exc_type, exc_value) emitted after the client 99 @signal utPrepared(nrTests, exc_type, exc_value) emitted after the client
98 has loaded a unittest suite 100 has loaded a unittest suite
99 @signal utFinished() emitted after the client signalled the end of the 101 @signal utFinished() emitted after the client signalled the end of the
100 unittest 102 unittest
101 @signal utStartTest(testname, testdocu) emitted after the client has 103 @signal utStartTest(testname, testdocu) emitted after the client has
132 clientVariable = pyqtSignal(int, list) 134 clientVariable = pyqtSignal(int, list)
133 clientStatement = pyqtSignal(bool) 135 clientStatement = pyqtSignal(bool)
134 clientException = pyqtSignal(str, str, list) 136 clientException = pyqtSignal(str, str, list)
135 clientSyntaxError = pyqtSignal(str, str, int, int) 137 clientSyntaxError = pyqtSignal(str, str, int, int)
136 clientSignal = pyqtSignal(str, str, int, str, str) 138 clientSignal = pyqtSignal(str, str, int, str, str)
137 clientExit = pyqtSignal(int, str) 139 clientExit = pyqtSignal(int, str, bool)
138 clientBreakConditionError = pyqtSignal(str, int) 140 clientBreakConditionError = pyqtSignal(str, int)
139 clientWatchConditionError = pyqtSignal(str) 141 clientWatchConditionError = pyqtSignal(str)
140 clientRawInput = pyqtSignal(str, bool) 142 clientRawInput = pyqtSignal(str, bool)
141 clientBanner = pyqtSignal(str, str, str, str) 143 clientBanner = pyqtSignal(str, str, str, str)
142 clientCapabilities = pyqtSignal(int, str, str) 144 clientCapabilities = pyqtSignal(int, str, str)
143 clientCompletionList = pyqtSignal(list, str) 145 clientCompletionList = pyqtSignal(list, str)
144 clientInterpreterChanged = pyqtSignal(str) 146 clientInterpreterChanged = pyqtSignal(str)
147 utDiscovered = pyqtSignal(list, str, str)
145 utPrepared = pyqtSignal(int, str, str) 148 utPrepared = pyqtSignal(int, str, str)
146 utStartTest = pyqtSignal(str, str) 149 utStartTest = pyqtSignal(str, str)
147 utStopTest = pyqtSignal() 150 utStopTest = pyqtSignal()
148 utTestFailed = pyqtSignal(str, str, str) 151 utTestFailed = pyqtSignal(str, str, str)
149 utTestErrored = pyqtSignal(str, str, str) 152 utTestErrored = pyqtSignal(str, str, str)
1309 from the remote client. 1312 from the remote client.
1310 1313
1311 @param text the text to be completed (string) 1314 @param text the text to be completed (string)
1312 """ 1315 """
1313 self.debuggerInterface.remoteCompletion(text) 1316 self.debuggerInterface.remoteCompletion(text)
1314 1317
1315 def remoteUTPrepare(self, fn, tn, tfn, failed, cov, covname, coverase, 1318 def remoteUTDiscover(self, clientType, forProject, venvName, syspath,
1316 clientType=""): 1319 workdir, discoveryStart):
1317 """ 1320 """
1318 Public method to prepare a new unittest run. 1321 Public method to perform a test case discovery.
1319 1322
1320 @param fn the filename to load (string) 1323 @param clientType client type to be used
1321 @param tn the testname to load (string) 1324 @type str
1322 @param tfn the test function name to load tests from (string) 1325 @param forProject flag indicating a project related action
1323 @param failed list of failed test, if only failed test should be run 1326 @type bool
1324 (list of strings) 1327 @param venvName name of a virtual environment
1325 @param cov flag indicating collection of coverage data is requested 1328 @type str
1326 (boolean) 1329 @param syspath list of directories to be added to sys.path on the
1327 @param covname filename to be used to assemble the coverage caches 1330 remote side
1328 filename (string) 1331 @type list of str
1329 @param coverase flag indicating erasure of coverage data is requested 1332 @param workdir path name of the working directory
1330 (boolean) 1333 @type str
1331 @keyparam clientType client type to be used (string) 1334 @param discoveryStart directory to start auto-discovery at
1332 """ 1335 @type str
1333 if clientType not in self.getSupportedLanguages(): 1336 """
1337 if clientType and clientType not in self.getSupportedLanguages():
1334 # a not supported client language was requested 1338 # a not supported client language was requested
1335 E5MessageBox.critical( 1339 E5MessageBox.critical(
1336 None, 1340 None,
1337 self.tr("Start Debugger"), 1341 self.tr("Start Debugger"),
1338 self.tr( 1342 self.tr(
1343 1347
1344 # Restart the client if there is already a program loaded. 1348 # Restart the client if there is already a program loaded.
1345 try: 1349 try:
1346 if clientType: 1350 if clientType:
1347 self.__setClientType(clientType) 1351 self.__setClientType(clientType)
1352 except KeyError:
1353 self.__setClientType('Python3') # assume it is a Python3 file
1354 self.startClient(False, forProject=forProject, venvName=venvName)
1355
1356 self.debuggerInterface.remoteUTDiscover(
1357 syspath, workdir, discoveryStart)
1358
1359 def remoteUTPrepare(self, fn, tn, tfn, failed, cov, covname, coverase,
1360 clientType="", forProject=False, venvName="",
1361 syspath=None, workdir="", discover=False,
1362 discoveryStart="", testCases=None, debug=False):
1363 """
1364 Public method to prepare a new unittest run.
1365
1366 @param fn the filename to load
1367 @type str
1368 @param tn the testname to load
1369 @type str
1370 @param tfn the test function name to load tests from
1371 @type str
1372 @param failed list of failed test, if only failed test should be run
1373 @type list of str
1374 @param cov flag indicating collection of coverage data is requested
1375 @type bool
1376 @param covname filename to be used to assemble the coverage caches
1377 filename
1378 @type str
1379 @param coverase flag indicating erasure of coverage data is requested
1380 @type bool
1381 @param clientType client type to be used
1382 @type str
1383 @param forProject flag indicating a project related action
1384 @type bool
1385 @param venvName name of a virtual environment
1386 @type str
1387 @param syspath list of directories to be added to sys.path on the
1388 remote side
1389 @type list of str
1390 @param workdir path name of the working directory
1391 @type str
1392 @param discover flag indicating to discover the tests automatically
1393 @type bool
1394 @param discoveryStart directory to start auto-discovery at
1395 @type str
1396 @param testCases list of test cases to be loaded
1397 @type list of str
1398 @param debug flag indicating to run unittest with debugging
1399 @type bool
1400 """
1401 if clientType and clientType not in self.getSupportedLanguages():
1402 # a not supported client language was requested
1403 E5MessageBox.critical(
1404 None,
1405 self.tr("Start Debugger"),
1406 self.tr(
1407 """<p>The debugger type <b>{0}</b> is not supported"""
1408 """ or not configured.</p>""").format(clientType)
1409 )
1410 return
1411
1412 # Restart the client if there is already a program loaded.
1413 try:
1414 if clientType:
1415 self.__setClientType(clientType)
1348 else: 1416 else:
1349 self.__setClientType( 1417 self.__setClientType(
1350 self.__findLanguageForExtension(os.path.splitext(fn)[1])) 1418 self.__findLanguageForExtension(os.path.splitext(fn)[1]))
1351 except KeyError: 1419 except KeyError:
1352 self.__setClientType('Python3') # assume it is a Python3 file 1420 self.__setClientType('Python3') # assume it is a Python3 file
1353 self.startClient(False) 1421 self.startClient(False, forProject=forProject, venvName=venvName)
1354 1422
1355 self.debuggerInterface.remoteUTPrepare( 1423 self.debuggerInterface.remoteUTPrepare(
1356 fn, tn, tfn, failed, cov, covname, coverase) 1424 fn, tn, tfn, failed, cov, covname, coverase, syspath, workdir,
1357 self.debugging = False 1425 discover, discoveryStart, testCases, debug)
1358 self.running = True 1426 self.running = True
1359 1427 self.debugging = debug
1360 def remoteUTRun(self): 1428 if debug:
1429 self.__restoreBreakpoints()
1430 self.__restoreWatchpoints()
1431
1432 def remoteUTRun(self, debug=False, failfast=False):
1361 """ 1433 """
1362 Public method to start a unittest run. 1434 Public method to start a unittest run.
1363 """ 1435
1364 self.debuggerInterface.remoteUTRun() 1436 @param debug flag indicating to run unittest with debugging
1437 @type bool
1438 @param failfast flag indicating to stop at the first error
1439 @type bool
1440 """
1441 self.debuggerInterface.remoteUTRun(debug, failfast)
1365 1442
1366 def remoteUTStop(self): 1443 def remoteUTStop(self):
1367 """ 1444 """
1368 public method to stop a unittest run. 1445 public method to stop a unittest run.
1369 """ 1446 """
1498 @param message message sent with the exit 1575 @param message message sent with the exit
1499 @type str 1576 @type str
1500 """ 1577 """
1501 if self.passive: 1578 if self.passive:
1502 self.__passiveShutDown() 1579 self.__passiveShutDown()
1503 self.clientExit.emit(int(status), message) 1580 self.clientExit.emit(int(status), message, False)
1504 if Preferences.getDebugger("AutomaticReset") or (self.running and 1581 if Preferences.getDebugger("AutomaticReset") or (self.running and
1505 not self.debugging): 1582 not self.debugging):
1506 self.debugging = False 1583 self.debugging = False
1507 self.startClient(False, forProject=self.__forProject) 1584 self.startClient(False, forProject=self.__forProject)
1508 if self.passive: 1585 if self.passive:
1611 """ 1688 """
1612 self.callTraceInfo.emit( 1689 self.callTraceInfo.emit(
1613 isCall, fromFile, fromLine, fromFunction, 1690 isCall, fromFile, fromLine, fromFunction,
1614 toFile, toLine, toFunction) 1691 toFile, toLine, toFunction)
1615 1692
1693 def clientUtDiscovered(self, testCases, exceptionType, exceptionValue):
1694 """
1695 Public method to process the client unittest discover info.
1696
1697 @param testCases list of detected test cases
1698 @type str
1699 @param exceptionType exception type
1700 @type str
1701 @param exceptionValue exception message
1702 @type str
1703 """
1704 self.utDiscovered.emit(testCases, exceptionType, exceptionValue)
1705
1616 def clientUtPrepared(self, result, exceptionType, exceptionValue): 1706 def clientUtPrepared(self, result, exceptionType, exceptionValue):
1617 """ 1707 """
1618 Public method to process the client unittest prepared info. 1708 Public method to process the client unittest prepared info.
1619 1709
1620 @param result number of test cases (0 = error) (integer) 1710 @param result number of test cases (0 = error) (integer)
1685 @param testname name of the test (string) 1775 @param testname name of the test (string)
1686 @param testId id of the test (string) 1776 @param testId id of the test (string)
1687 """ 1777 """
1688 self.utTestSucceededUnexpected.emit(testname, testId) 1778 self.utTestSucceededUnexpected.emit(testname, testId)
1689 1779
1690 def clientUtFinished(self): 1780 def clientUtFinished(self, status):
1691 """ 1781 """
1692 Public method to process the client unit test finished info. 1782 Public method to process the client unit test finished info.
1783
1784 @param status exit status of the unit test
1785 @type int
1693 """ 1786 """
1694 self.utFinished.emit() 1787 self.utFinished.emit()
1788
1789 self.clientExit.emit(int(status), "", True)
1790 self.debugging = False
1791 self.running = False
1695 1792
1696 def passiveStartUp(self, fn, exc): 1793 def passiveStartUp(self, fn, exc):
1697 """ 1794 """
1698 Public method to handle a passive debug connection. 1795 Public method to handle a passive debug connection.
1699 1796

eric ide

mercurial