mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-09 11:27:28 -03:00
test: enable running individual independent functional test methods
- Some test methods in the functional test framework are independent and do not require any previous context or setup defined in `run_test`. - This commit adds a new option for running these specific methods within a test file, allowing them to be executed individually without running the entire test suite. - running test methods that require an argument or context will fail.
This commit is contained in:
parent
0903ce8dbc
commit
409d0d6293
1 changed files with 14 additions and 1 deletions
|
@ -129,7 +129,11 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
|||
|
||||
try:
|
||||
self.setup()
|
||||
self.run_test()
|
||||
if self.options.test_methods:
|
||||
self.run_test_methods()
|
||||
else:
|
||||
self.run_test()
|
||||
|
||||
except JSONRPCException:
|
||||
self.log.exception("JSONRPC error")
|
||||
self.success = TestStatus.FAILED
|
||||
|
@ -155,6 +159,13 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
|||
exit_code = self.shutdown()
|
||||
sys.exit(exit_code)
|
||||
|
||||
def run_test_methods(self):
|
||||
for method_name in self.options.test_methods:
|
||||
self.log.info(f"Attempting to execute method: {method_name}")
|
||||
method = getattr(self, method_name)
|
||||
method()
|
||||
self.log.info(f"Method '{method_name}' executed successfully.")
|
||||
|
||||
def parse_args(self, test_file):
|
||||
previous_releases_path = os.getenv("PREVIOUS_RELEASES_DIR") or os.getcwd() + "/releases"
|
||||
parser = argparse.ArgumentParser(usage="%(prog)s [options]")
|
||||
|
@ -194,6 +205,8 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
|||
help="use BIP324 v2 connections between all nodes by default")
|
||||
parser.add_argument("--v1transport", dest="v1transport", default=False, action="store_true",
|
||||
help="Explicitly use v1 transport (can be used to overwrite global --v2transport option)")
|
||||
parser.add_argument("--test_methods", dest="test_methods", nargs='*',
|
||||
help="Run specified test methods sequentially instead of the full test. Use only for methods that do not depend on any context set up in run_test or other methods.")
|
||||
|
||||
self.add_options(parser)
|
||||
# Running TestShell in a Jupyter notebook causes an additional -f argument
|
||||
|
|
Loading…
Reference in a new issue