Skip to content

Commit 8c7288c

Browse files
committed
Print out the final 1000 lines of test_framework.log if test fails
1 parent 6d780b1 commit 8c7288c

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

test/functional/test_framework/test_framework.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Base class for RPC testing."""
66

7+
from collections import deque
78
import logging
89
import optparse
910
import os
@@ -177,12 +178,17 @@ def main(self):
177178
# Dump the end of the debug logs, to aid in debugging rare
178179
# travis failures.
179180
import glob
180-
filenames = glob.glob(self.options.tmpdir + "/node*/regtest/debug.log")
181+
filenames = [self.options.tmpdir + "/test_framework.log"]
182+
filenames += glob.glob(self.options.tmpdir + "/node*/regtest/debug.log")
181183
MAX_LINES_TO_PRINT = 1000
182-
for f in filenames:
183-
print("From" , f, ":")
184-
from collections import deque
185-
print("".join(deque(open(f), MAX_LINES_TO_PRINT)))
184+
for fn in filenames:
185+
try:
186+
with open(fn, 'r') as f:
187+
print("From" , fn, ":")
188+
print("".join(deque(f, MAX_LINES_TO_PRINT)))
189+
except OSError:
190+
print("Opening file %s failed." % fn)
191+
traceback.print_exc()
186192
if success:
187193
self.log.info("Tests successful")
188194
sys.exit(self.TEST_EXIT_PASSED)

0 commit comments

Comments
 (0)