Merge bitcoin/bitcoin#36958: test: drop `jinja2` dependency from `combine_logs.py`
What changed, and why it matters
This commit removes an optional HTML output feature from a Bitcoin Core test helper script called combine_logs.py. The change drops the third-party jinja2 library and the associated --html command-line option. There is no security fix here; it is a routine cleanup to reduce a test-only dependency.
No security action needed. Treat as normal maintenance. If downstream tooling relied on --html, migrate to plain-text output or re-implement HTML rendering externally.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch deletes the print_logs_html() function, the –html argument, and the combined_log_template.html file from test/functional/combine_logs.py. The script now only supports plain-text or colored terminal output. The jinja2 import was used only for local rendering of test logs and is no longer required.
Changed components
test/functional/combine_logs.pytest/functional/combined_log_template.htmlInspect captured patch +3 / −63
### test/functional/combine_logs.py
@@ -31,21 +31,16 @@
LogEvent = namedtuple('LogEvent', ['timestamp', 'source', 'event'])
def main():
- """Main function. Parses args, reads the log files and renders them as text or html."""
+ """Main function. Parses args, reads the log files and renders them as text."""
parser = argparse.ArgumentParser(
description=__doc__, formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument(
'testdir', nargs='?', default='',
help=('temporary test directory to combine logs from. '
'Defaults to the most recent'))
parser.add_argument('-c', '--color', dest='color', action='store_true', help='outputs the combined log with events colored by source (requires posix terminal colors. Use less -r for viewing)')
- parser.add_argument('--html', dest='html', action='store_true', help='outputs the combined log as html. Requires jinja2. pip install jinja2')
args = parser.parse_args()
- if args.html and args.color:
- print("Only one out of --color or --html should be specified")
- sys.exit(1)
-
testdir = args.testdir or find_latest_test_dir()
if not testdir:
@@ -66,11 +61,8 @@ def main():
log_events = read_logs(testdir)
- if args.html:
- print_logs_html(log_events)
- else:
- print_logs_plain(log_events, colors)
- print_node_warnings(testdir, colors)
+ print_logs_plain(log_events, colors)
+ print_node_warnings(testdir, colors)
def read_logs(tmp_dir):
@@ -187,17 +179,5 @@ def print_logs_plain(log_events, colors):
print("{0}{1}{2}".format(colors[event.source.rstrip()], line, colors["reset"]))
-def print_logs_html(log_events):
- """Renders the iterator of log events into html."""
- try:
- import jinja2 #type:ignore
- except ImportError:
- print("jinja2 not found. Try `pip install jinja2`")
- sys.exit(1)
- print(jinja2.Environment(loader=jinja2.FileSystemLoader('./'))
- .get_template('combined_log_template.html')
- .render(title="Combined Logs from testcase", log_events=[event._asdict() for event in log_events]))
-
-
if __name__ == '__main__':
main()
### test/functional/combined_log_template.html
@@ -1,40 +0,0 @@
-<html lang="en">
-<head>
- <title> {{ title }} </title>
- <style>
- ul {
- list-style-type: none;
- font-family: monospace;
- }
- li {
- border: 1px solid slategray;
- margin-bottom: 1px;
- }
- li:hover {
- filter: brightness(85%);
- }
- li.log-test {
- background-color: cyan;
- }
- li.log-node0 {
- background-color: lightblue;
- }
- li.log-node1 {
- background-color: lightgreen;
- }
- li.log-node2 {
- background-color: lightsalmon;
- }
- li.log-node3 {
- background-color: lightyellow;
- }
- </style>
-</head>
-<body>
-<ul>
-{% for event in log_events %}
-<li class="log-{{ event.source }}"> {{ event.source }} {{ event.timestamp }} {{event.event}}</li>
-{% endfor %}
-</ul>
-</body>
-</html>Why this scored 16/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.