mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 10:07:14 +02:00
Enhance unit testing summary
This commit is contained in:
@ -314,11 +314,12 @@ def _clean_build_dir(build_dir):
|
|||||||
f.write(proj_hash)
|
f.write(proj_hash)
|
||||||
|
|
||||||
|
|
||||||
def print_header(label, is_error=False):
|
def print_header(label, is_error=False, fg=None):
|
||||||
terminal_width, _ = click.get_terminal_size()
|
terminal_width, _ = click.get_terminal_size()
|
||||||
width = len(click.unstyle(label))
|
width = len(click.unstyle(label))
|
||||||
half_line = "=" * int((terminal_width - width - 2) / 2)
|
half_line = "=" * int((terminal_width - width - 2) / 2)
|
||||||
click.echo("%s %s %s" % (half_line, label, half_line), err=is_error)
|
click.secho(
|
||||||
|
"%s %s %s" % (half_line, label, half_line), fg=fg, err=is_error)
|
||||||
|
|
||||||
|
|
||||||
def print_summary(results, start_time):
|
def print_summary(results, start_time):
|
||||||
|
@ -148,7 +148,8 @@ def cli( # pylint: disable=redefined-builtin
|
|||||||
if without_testing:
|
if without_testing:
|
||||||
return
|
return
|
||||||
|
|
||||||
passed = True
|
passed_nums = 0
|
||||||
|
failed_nums = 0
|
||||||
testname_max_len = max([len(r[1]) for r in results])
|
testname_max_len = max([len(r[1]) for r in results])
|
||||||
envname_max_len = max([len(click.style(r[2], fg="cyan")) for r in results])
|
envname_max_len = max([len(click.style(r[2], fg="cyan")) for r in results])
|
||||||
|
|
||||||
@ -157,12 +158,14 @@ def cli( # pylint: disable=redefined-builtin
|
|||||||
|
|
||||||
for result in results:
|
for result in results:
|
||||||
status, testname, envname = result
|
status, testname, envname = result
|
||||||
status_str = click.style("PASSED", fg="green")
|
|
||||||
if status is False:
|
if status is False:
|
||||||
passed = False
|
failed_nums += 1
|
||||||
status_str = click.style("FAILED", fg="red")
|
status_str = click.style("FAILED", fg="red")
|
||||||
elif status is None:
|
elif status is None:
|
||||||
status_str = click.style("IGNORED", fg="yellow")
|
status_str = click.style("IGNORED", fg="yellow")
|
||||||
|
else:
|
||||||
|
passed_nums += 1
|
||||||
|
status_str = click.style("PASSED", fg="green")
|
||||||
|
|
||||||
click.echo(
|
click.echo(
|
||||||
("test/{:<%d} > {:<%d}\t[{}]" %
|
("test/{:<%d} > {:<%d}\t[{}]" %
|
||||||
@ -171,12 +174,13 @@ def cli( # pylint: disable=redefined-builtin
|
|||||||
err=status is False)
|
err=status is False)
|
||||||
|
|
||||||
print_header(
|
print_header(
|
||||||
"[%s] Took %.2f seconds" % (
|
"%s%d passed in %.2f seconds"
|
||||||
(click.style("PASSED", fg="green", bold=True) if passed else
|
% ("%d failed, " % failed_nums if failed_nums else "", passed_nums,
|
||||||
click.style("FAILED", fg="red", bold=True)), time() - start_time),
|
time() - start_time),
|
||||||
is_error=not passed)
|
is_error=failed_nums,
|
||||||
|
fg="red" if failed_nums else "green")
|
||||||
|
|
||||||
if not passed:
|
if failed_nums:
|
||||||
raise exception.ReturnErrorCode(1)
|
raise exception.ReturnErrorCode(1)
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user