mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
Merge #11023: [tests] Add option to attach a python debugger if functional test fails
cc5d38f4b
Add option to attach a python debugger if test fails (John Newbery)
Pull request description:
Adds a simple option to the test_framework to attach pdb if the test fails.
Helpful for catching and debugging intermittent failures: Run the test in a loop with this option. The first failure will cause execution to pause and nodes will be left running for interactive debugging.
@sdaftuar
Tree-SHA512: 01cfae15fa3f04ed6ec6a99fef60a6c6a59723429309e81eacd6767caf12f5758f59b337804291ecab33a38a2958f36e2b513d201bee72a2eeb207a67046f952
This commit is contained in:
parent
52aef4cfec
commit
7f1009ed57
@ -10,6 +10,7 @@ from enum import Enum
|
|||||||
import logging
|
import logging
|
||||||
import optparse
|
import optparse
|
||||||
import os
|
import os
|
||||||
|
import pdb
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
@ -138,6 +139,8 @@ class BitcoinTestFramework(object):
|
|||||||
help="Write tested RPC commands into this directory")
|
help="Write tested RPC commands into this directory")
|
||||||
parser.add_option("--configfile", dest="configfile",
|
parser.add_option("--configfile", dest="configfile",
|
||||||
help="Location of the test framework config file")
|
help="Location of the test framework config file")
|
||||||
|
parser.add_option("--pdbonfailure", dest="pdbonfailure", default=False, action="store_true",
|
||||||
|
help="Attach a python debugger if test fails")
|
||||||
self.add_options(parser)
|
self.add_options(parser)
|
||||||
(self.options, self.args) = parser.parse_args()
|
(self.options, self.args) = parser.parse_args()
|
||||||
|
|
||||||
@ -178,6 +181,10 @@ class BitcoinTestFramework(object):
|
|||||||
except KeyboardInterrupt as e:
|
except KeyboardInterrupt as e:
|
||||||
self.log.warning("Exiting after keyboard interrupt")
|
self.log.warning("Exiting after keyboard interrupt")
|
||||||
|
|
||||||
|
if success == TestStatus.FAILED and self.options.pdbonfailure:
|
||||||
|
print("Testcase failed. Attaching python debugger. Enter ? for help")
|
||||||
|
pdb.set_trace()
|
||||||
|
|
||||||
if not self.options.noshutdown:
|
if not self.options.noshutdown:
|
||||||
self.log.info("Stopping nodes")
|
self.log.info("Stopping nodes")
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user