test: Avoid hardcoding the chain name in combine_logs
This commit is contained in:
parent
fa8a1d7ba3
commit
faf36838bd
1 changed files with 25 additions and 15 deletions
|
@ -8,6 +8,7 @@ If no argument is provided, the most recent test directory will be used."""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
from collections import defaultdict, namedtuple
|
from collections import defaultdict, namedtuple
|
||||||
|
import glob
|
||||||
import heapq
|
import heapq
|
||||||
import itertools
|
import itertools
|
||||||
import os
|
import os
|
||||||
|
@ -76,9 +77,17 @@ def read_logs(tmp_dir):
|
||||||
Delegates to generator function get_log_events() to provide individual log events
|
Delegates to generator function get_log_events() to provide individual log events
|
||||||
for each of the input log files."""
|
for each of the input log files."""
|
||||||
|
|
||||||
|
# Find out what the folder is called that holds the debug.log file
|
||||||
|
chain = glob.glob("{}/node0/*/debug.log".format(tmp_dir))
|
||||||
|
if chain:
|
||||||
|
chain = chain[0] # pick the first one if more than one chain was found (should never happen)
|
||||||
|
chain = re.search('node0/(.+?)/debug\.log$', chain).group(1) # extract the chain name
|
||||||
|
else:
|
||||||
|
chain = 'regtest' # fallback to regtest (should only happen when none exists)
|
||||||
|
|
||||||
files = [("test", "%s/test_framework.log" % tmp_dir)]
|
files = [("test", "%s/test_framework.log" % tmp_dir)]
|
||||||
for i in itertools.count():
|
for i in itertools.count():
|
||||||
logfile = "{}/node{}/regtest/debug.log".format(tmp_dir, i)
|
logfile = "{}/node{}/{}/debug.log".format(tmp_dir, i, chain)
|
||||||
if not os.path.isfile(logfile):
|
if not os.path.isfile(logfile):
|
||||||
break
|
break
|
||||||
files.append(("node%d" % i, logfile))
|
files.append(("node%d" % i, logfile))
|
||||||
|
@ -184,5 +193,6 @@ def print_logs_html(log_events):
|
||||||
.get_template('combined_log_template.html')
|
.get_template('combined_log_template.html')
|
||||||
.render(title="Combined Logs from testcase", log_events=[event._asdict() for event in log_events]))
|
.render(title="Combined Logs from testcase", log_events=[event._asdict() for event in log_events]))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue