Skip to content

Commit 96c509e

Browse files
committed
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 fe23553 commit 96c509e

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

test/functional/test_runner.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,10 @@ def main():
320320
args=passon_args,
321321
combined_logs_len=args.combinedlogslen,
322322
failfast=args.failfast,
323+
level=logging_level
323324
)
324325

325-
def run_tests(test_list, src_dir, build_dir, tmpdir, jobs=1, enable_coverage=False, args=None, combined_logs_len=0, failfast=False):
326+
def run_tests(test_list, src_dir, build_dir, tmpdir, jobs=1, enable_coverage=False, args=None, combined_logs_len=0, failfast=False, level=logging.DEBUG):
326327
args = args or []
327328

328329
# Warn if bitcoind is already running (unix only)
@@ -357,22 +358,22 @@ def run_tests(test_list, src_dir, build_dir, tmpdir, jobs=1, enable_coverage=Fal
357358
raise
358359

359360
#Run Tests
360-
job_queue = TestHandler(jobs, tests_dir, tmpdir, test_list, flags)
361+
job_queue = TestHandler(jobs, tests_dir, tmpdir, test_list, flags, level)
361362
start_time = time.time()
362363
test_results = []
363364

364365
max_len_name = len(max(test_list, key=len))
365-
366-
for _ in range(len(test_list)):
366+
test_count = len(test_list)
367+
for i in range(test_count):
367368
test_result, testdir, stdout, stderr = job_queue.get_next()
368369
test_results.append(test_result)
369-
370+
done_str = "{}/{} - {}{}{}".format(i + 1, test_count, BOLD[1], test_result.name, BOLD[0])
370371
if test_result.status == "Passed":
371-
logging.debug("\n%s%s%s passed, Duration: %s s" % (BOLD[1], test_result.name, BOLD[0], test_result.time))
372+
logging.debug("%s passed, Duration: %s s" % (done_str, test_result.time))
372373
elif test_result.status == "Skipped":
373-
logging.debug("\n%s%s%s skipped" % (BOLD[1], test_result.name, BOLD[0]))
374+
logging.debug("%s skipped" % (done_str))
374375
else:
375-
print("\n%s%s%s failed, Duration: %s s\n" % (BOLD[1], test_result.name, BOLD[0], test_result.time))
376+
print("%s failed, Duration: %s s\n" % (done_str, test_result.time))
376377
print(BOLD[1] + 'stdout:\n' + BOLD[0] + stdout + '\n')
377378
print(BOLD[1] + 'stderr:\n' + BOLD[0] + stderr + '\n')
378379
if combined_logs_len and os.path.isdir(testdir):
@@ -438,13 +439,14 @@ class TestHandler:
438439
Trigger the test scripts passed in via the list.
439440
"""
440441

441-
def __init__(self, num_tests_parallel, tests_dir, tmpdir, test_list=None, flags=None):
442+
def __init__(self, num_tests_parallel, tests_dir, tmpdir, test_list=None, flags=None, logging_level=logging.DEBUG):
442443
assert(num_tests_parallel >= 1)
443444
self.num_jobs = num_tests_parallel
444445
self.tests_dir = tests_dir
445446
self.tmpdir = tmpdir
446447
self.test_list = test_list
447448
self.flags = flags
449+
self.logging_level = logging_level
448450
self.num_running = 0
449451
self.jobs = []
450452

@@ -471,6 +473,7 @@ def get_next(self):
471473
log_stderr))
472474
if not self.jobs:
473475
raise IndexError('pop from empty list')
476+
dot_count = 0
474477
while True:
475478
# Return first proc that finishes
476479
time.sleep(.5)
@@ -491,9 +494,14 @@ def get_next(self):
491494
status = "Failed"
492495
self.num_running -= 1
493496
self.jobs.remove(job)
494-
497+
if self.logging_level == logging.DEBUG:
498+
clearline = '\r' + (' ' * dot_count) + '\r'
499+
print(clearline, end='', flush=True)
500+
dot_count = 0
495501
return TestResult(name, status, int(time.time() - start_time)), testdir, stdout, stderr
496-
print('.', end='', flush=True)
502+
if self.logging_level == logging.DEBUG:
503+
print('.', end='', flush=True)
504+
dot_count += 1
497505

498506
def kill_and_join(self):
499507
"""Send SIGKILL to all jobs and block until all have ended."""

0 commit comments

Comments
 (0)