Skip to content

Commit ebe4cac

Browse files
committed
Merge bitcoin/bitcoin#30991: test: enable running independent functional test sub-tests
409d0d6 test: enable running individual independent functional test methods (ismaelsadeeq) Pull request description: - Some test methods in the functional test framework are independent and do not require any prior context or setup 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. - Using this option reduces the time you need to wait before the test you are interested in starts executing. - The functionality added by this PR can be achieved manually by commenting out code, but having a pragmatic option to do this is more convenient. Note: Running test methods that require arguments or context will fail. **Example Usage**: ```zsh build/test/functional/feature_reindex.py --test_methods continue_reindex_after_shutdown ``` ```zsh build/test/functional/feature_config_args.py --test_methods test_log_buffer test_args_log test_connect_with_seednode ``` ACKs for top commit: maflcko: review ACK 409d0d6 rkrux: reACK 409d0d6 ryanofsky: Code review ACK 409d0d6. This seems like a good step towards making it easy to run independent tests quickly. I think ideally there would be some naming convention or @ annotation added to test methods that can run independently, so the test framework could provide more functionality like being able to list test methods, being able to show command lines to quickly reproduce problems when tests fails, and calling test methods automatically instead of requiring individual tests to call them. But these ideas are all compatible with the new `--test_methods` option Tree-SHA512: b0daac7c3b322e6fd9b946962335d8279e8cb004ff76f502c8d597b9c4b0073840945be198a79d44c5aaa64bda421429829d5c84ceeb8c6139eb6ed079a35878
2 parents 1927674 + 409d0d6 commit ebe4cac

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

test/functional/test_framework/test_framework.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,11 @@ def main(self):
129129

130130
try:
131131
self.setup()
132-
self.run_test()
132+
if self.options.test_methods:
133+
self.run_test_methods()
134+
else:
135+
self.run_test()
136+
133137
except JSONRPCException:
134138
self.log.exception("JSONRPC error")
135139
self.success = TestStatus.FAILED
@@ -155,6 +159,13 @@ def main(self):
155159
exit_code = self.shutdown()
156160
sys.exit(exit_code)
157161

162+
def run_test_methods(self):
163+
for method_name in self.options.test_methods:
164+
self.log.info(f"Attempting to execute method: {method_name}")
165+
method = getattr(self, method_name)
166+
method()
167+
self.log.info(f"Method '{method_name}' executed successfully.")
168+
158169
def parse_args(self, test_file):
159170
previous_releases_path = os.getenv("PREVIOUS_RELEASES_DIR") or os.getcwd() + "/releases"
160171
parser = argparse.ArgumentParser(usage="%(prog)s [options]")
@@ -194,6 +205,8 @@ def parse_args(self, test_file):
194205
help="use BIP324 v2 connections between all nodes by default")
195206
parser.add_argument("--v1transport", dest="v1transport", default=False, action="store_true",
196207
help="Explicitly use v1 transport (can be used to overwrite global --v2transport option)")
208+
parser.add_argument("--test_methods", dest="test_methods", nargs='*',
209+
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.")
197210

198211
self.add_options(parser)
199212
# Running TestShell in a Jupyter notebook causes an additional -f argument

0 commit comments

Comments
 (0)