From 213e59d3540f41bf73c934af6e55e08be223e6ef Mon Sep 17 00:00:00 2001 From: Hodlinator <172445034+hodlinator@users.noreply.github.com> Date: Fri, 6 Dec 2024 00:49:37 +0100 Subject: [PATCH] refactor test: Cleaner combine_logs.py logic --- test/functional/combine_logs.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/test/functional/combine_logs.py b/test/functional/combine_logs.py index 57fd0710b6907f..0478a3f70387ab 100755 --- a/test/functional/combine_logs.py +++ b/test/functional/combine_logs.py @@ -81,13 +81,14 @@ def read_logs(tmp_dir): # Find out what the folder is called that holds node 0's debug.log file debug_logs = list(pathlib.Path(tmp_dir).glob('node0/**/debug.log')) - if len(debug_logs) > 0: - assert len(debug_logs) < 2, 'Max one debug.log is supported, ' \ - 'found several:\n\t' + '\n\t'.join([str(f) for f in debug_logs]) - path = debug_logs[0] - chain = re.search(r'node0/(.+?)/debug\.log$', path.as_posix()).group(1) # extract the chain name - else: - chain = 'regtest' # fallback to regtest (should only happen when none exists) + match len(debug_logs): + case 0: + chain = 'regtest' # fallback to regtest + case 1: + chain = re.search(r'node0/(.+?)/debug\.log$', debug_logs[0].as_posix()).group(1) + case _: + raise RuntimeError('Max one debug.log is supported, found several:\n\t' + + '\n\t'.join([str(f) for f in debug_logs])) files = [("test", "%s/test_framework.log" % tmp_dir)] for i in itertools.count():