Skip to content

Commit c412fd8

Browse files
author
MarcoFalke
committed
Merge #9780: Suppress noisy output from qa tests in Travis
8c7288c Print out the final 1000 lines of test_framework.log if test fails (John Newbery) 6d780b1 Update travis config to run rpc-tests.py in quiet mode (John Newbery) 55992f1 Add --quiet option to suppress rpc-tests.py output (John Newbery) Tree-SHA512: ab080458a07a9346d3b3cbc8ab59b73cea3d4010b1cb0206bb5fade0aaac7562c623475d0a02993f001b22ae9d1ba68e2d0d1a3645cea7e79cc1045b42e2ce3a
2 parents 5114f81 + 8c7288c commit c412fd8

File tree

3 files changed

+29
-13
lines changed

3 files changed

+29
-13
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ script:
7070
- make $MAKEJOBS $GOAL || ( echo "Build failure. Verbose build follows." && make $GOAL V=1 ; false )
7171
- export LD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/depends/$HOST/lib
7272
- if [ "$RUN_TESTS" = "true" ]; then make $MAKEJOBS check VERBOSE=1; fi
73-
- if [ "$TRAVIS_EVENT_TYPE" = "cron" ]; then extended="--extended --exclude pruning"; fi
73+
- if [ "$TRAVIS_EVENT_TYPE" = "cron" ]; then extended="--extended --quiet --exclude pruning"; fi
7474
- if [ "$RUN_TESTS" = "true" ]; then test/functional/test_runner.py --coverage ${extended}; fi
7575
after_script:
7676
- echo $TRAVIS_COMMIT_RANGE

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)

test/functional/test_runner.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import subprocess
2424
import tempfile
2525
import re
26+
import logging
2627

2728
TEST_EXIT_PASSED = 0
2829
TEST_EXIT_SKIPPED = 77
@@ -141,6 +142,7 @@ def main():
141142
parser.add_argument('--force', '-f', action='store_true', help='run tests even on platforms where they are disabled by default (e.g. windows).')
142143
parser.add_argument('--help', '-h', '-?', action='store_true', help='print help text and exit')
143144
parser.add_argument('--jobs', '-j', type=int, default=4, help='how many test scripts to run in parallel. Default=4.')
145+
parser.add_argument('--quiet', '-q', action='store_true', help='only print results summary and failure logs')
144146
parser.add_argument('--nozmq', action='store_true', help='do not run the zmq tests')
145147
args, unknown_args = parser.parse_known_args()
146148

@@ -152,6 +154,10 @@ def main():
152154
config = configparser.ConfigParser()
153155
config.read_file(open(os.path.dirname(__file__) + "/config.ini"))
154156

157+
# Set up logging
158+
logging_level = logging.INFO if args.quiet else logging.DEBUG
159+
logging.basicConfig(format='%(message)s', level=logging_level)
160+
155161
enable_wallet = config["components"].getboolean("ENABLE_WALLET")
156162
enable_utils = config["components"].getboolean("ENABLE_UTILS")
157163
enable_bitcoind = config["components"].getboolean("ENABLE_BITCOIND")
@@ -233,7 +239,7 @@ def run_tests(test_list, src_dir, build_dir, exeext, jobs=1, enable_coverage=Fal
233239
if enable_coverage:
234240
coverage = RPCCoverage()
235241
flags.append(coverage.flag)
236-
print("Initializing coverage directory at %s\n" % coverage.dir)
242+
logging.debug("Initializing coverage directory at %s" % coverage.dir)
237243
else:
238244
coverage = None
239245

@@ -249,16 +255,20 @@ def run_tests(test_list, src_dir, build_dir, exeext, jobs=1, enable_coverage=Fal
249255
job_queue = TestHandler(jobs, tests_dir, test_list, flags)
250256

251257
max_len_name = len(max(test_list, key=len))
252-
results = BOLD[1] + "%s | %s | %s\n\n" % ("TEST".ljust(max_len_name), "STATUS ", "DURATION") + BOLD[0]
258+
results = "\n" + BOLD[1] + "%s | %s | %s\n\n" % ("TEST".ljust(max_len_name), "STATUS ", "DURATION") + BOLD[0]
253259
for _ in range(len(test_list)):
254260
(name, stdout, stderr, status, duration) = job_queue.get_next()
255261
all_passed = all_passed and status != "Failed"
256262
time_sum += duration
257263

258-
print('\n' + BOLD[1] + name + BOLD[0] + ":")
259-
print('' if status == "Passed" else stdout + '\n', end='')
260-
print('' if stderr == '' else 'stderr:\n' + stderr + '\n', end='')
261-
print("Status: %s%s%s, Duration: %s s\n" % (BOLD[1], status, BOLD[0], duration))
264+
if status == "Passed":
265+
logging.debug("\n%s%s%s passed, Duration: %s s" % (BOLD[1], name, BOLD[0], duration))
266+
elif status == "Skipped":
267+
logging.debug("\n%s%s%s skipped" % (BOLD[1], name, BOLD[0]))
268+
else:
269+
print("\n%s%s%s failed, Duration: %s s\n" % (BOLD[1], name, BOLD[0], duration))
270+
print(BOLD[1] + 'stdout:\n' + BOLD[0] + stdout + '\n')
271+
print(BOLD[1] + 'stderr:\n' + BOLD[0] + stderr + '\n')
262272

263273
results += "%s | %s | %s s\n" % (name.ljust(max_len_name), status.ljust(7), duration)
264274

@@ -269,7 +279,7 @@ def run_tests(test_list, src_dir, build_dir, exeext, jobs=1, enable_coverage=Fal
269279
if coverage:
270280
coverage.report_rpc_coverage()
271281

272-
print("Cleaning up coverage data")
282+
logging.debug("Cleaning up coverage data")
273283
coverage.cleanup()
274284

275285
sys.exit(not all_passed)

0 commit comments

Comments
 (0)