Skip to content

Commit cde9d13

Browse files
isgheWarrows
authored andcommitted
show the progress of functional test
example (added the progress index `n/m`) ``` 1/107 - wallet_hd.py passed, Duration: 27 s ......................................................................................... 2/107 - mining_getblocktemplate_longpoll.py passed, Duration: 72 s .................................................................. 3/107 - feature_maxuploadtarget.py passed, Duration: 78 s ``` - clear dots line ``` $ test/functional/test_runner.py -t can_trash Temporary test directory at can_trash/test_runner_₿_🏃_20181018_220600 1/105 - wallet_hd.py passed, Duration: 21 s 2/105 - mining_getblocktemplate_longpoll.py passed, Duration: 71 s 3/105 - feature_maxuploadtarget.py passed, Duration: 68 s .................. ``` - don't print the `dot` progressive if `--quiet` - done_str - nothing commit to check again travis tests
1 parent e47fe3d commit cde9d13

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

test/functional/test_runner.py

+19-12
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,9 @@ def main():
254254
if not args.keepcache:
255255
shutil.rmtree("%s/test/cache" % config["environment"]["BUILDDIR"], ignore_errors=True)
256256

257-
run_tests(test_list, config["environment"]["SRCDIR"], config["environment"]["BUILDDIR"], config["environment"]["EXEEXT"], tmpdir, args.jobs, args.coverage, passon_args, args.combinedlogslen)
257+
run_tests(test_list, config["environment"]["SRCDIR"], config["environment"]["BUILDDIR"], config["environment"]["EXEEXT"], tmpdir, args.jobs, args.coverage, passon_args, args.combinedlogslen, level=logging_level)
258258

259-
def run_tests(test_list, src_dir, build_dir, exeext, tmpdir, jobs=1, enable_coverage=False, args=[], combined_logs_len=0):
259+
def run_tests(test_list, src_dir, build_dir, exeext, tmpdir, jobs=1, enable_coverage=False, args=[], combined_logs_len=0, level=logging.DEBUG):
260260
# Warn if bitcoind is already running (unix only)
261261
try:
262262
if subprocess.check_output(["pidof", "pivxd"]) is not None:
@@ -295,22 +295,22 @@ def run_tests(test_list, src_dir, build_dir, exeext, tmpdir, jobs=1, enable_cove
295295
raise
296296

297297
#Run Tests
298-
job_queue = TestHandler(jobs, tests_dir, tmpdir, test_list, flags)
298+
job_queue = TestHandler(jobs, tests_dir, tmpdir, test_list, flags, level)
299299
time0 = time.time()
300300
test_results = []
301301

302302
max_len_name = len(max(test_list, key=len))
303-
304-
for _ in range(len(test_list)):
303+
test_count = len(test_list)
304+
for i in range(test_count):
305305
test_result, testdir, stdout, stderr = job_queue.get_next()
306306
test_results.append(test_result)
307-
307+
done_str = "{}/{} - {}{}{}".format(i + 1, test_count, BOLD[1], test_result.name, BOLD[0])
308308
if test_result.status == "Passed":
309-
logging.debug("\n%s%s%s passed, Duration: %s s" % (BOLD[1], test_result.name, BOLD[0], test_result.time))
309+
logging.debug("%s passed, Duration: %s s" % (done_str, test_result.time))
310310
elif test_result.status == "Skipped":
311-
logging.debug("\n%s%s%s skipped" % (BOLD[1], test_result.name, BOLD[0]))
311+
logging.debug("%s skipped" % (done_str))
312312
else:
313-
print("\n%s%s%s failed, Duration: %s s\n" % (BOLD[1], test_result.name, BOLD[0], test_result.time))
313+
print("%s failed, Duration: %s s\n" % (done_str, test_result.time))
314314
print(BOLD[1] + 'stdout:\n' + BOLD[0] + stdout + '\n')
315315
print(BOLD[1] + 'stderr:\n' + BOLD[0] + stderr + '\n')
316316
if combined_logs_len and os.path.isdir(testdir):
@@ -361,13 +361,14 @@ class TestHandler:
361361
Trigger the test scripts passed in via the list.
362362
"""
363363

364-
def __init__(self, num_tests_parallel, tests_dir, tmpdir, test_list=None, flags=None):
364+
def __init__(self, num_tests_parallel, tests_dir, tmpdir, test_list=None, flags=None, logging_level=logging.DEBUG):
365365
assert(num_tests_parallel >= 1)
366366
self.num_jobs = num_tests_parallel
367367
self.tests_dir = tests_dir
368368
self.tmpdir = tmpdir
369369
self.test_list = test_list
370370
self.flags = flags
371+
self.logging_level = logging_level
371372
self.num_running = 0
372373
# In case there is a graveyard of zombie pivxds, we can apply a
373374
# pseudorandom offset to hopefully jump over them.
@@ -398,6 +399,7 @@ def get_next(self):
398399
log_stderr))
399400
if not self.jobs:
400401
raise IndexError('pop from empty list')
402+
dot_count = 0
401403
while True:
402404
# Return first proc that finishes
403405
time.sleep(.5)
@@ -419,9 +421,14 @@ def get_next(self):
419421
status = "Failed"
420422
self.num_running -= 1
421423
self.jobs.remove(j)
422-
424+
if self.logging_level == logging.DEBUG:
425+
clearline = '\r' + (' ' * dot_count) + '\r'
426+
print(clearline, end='', flush=True)
427+
dot_count = 0
423428
return TestResult(name, status, int(time.time() - time0)), testdir, stdout, stderr
424-
print('.', end='', flush=True)
429+
if self.logging_level == logging.DEBUG:
430+
print('.', end='', flush=True)
431+
dot_count += 1
425432

426433
class TestResult():
427434
def __init__(self, name, status, time):

0 commit comments

Comments
 (0)