Skip to content

Commit

Permalink
Strip ANSI codes from Unity output
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankravets committed May 4, 2022
1 parent 517ee65 commit 3ed5d41
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions platformio/test/runners/unity.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

from platformio.test.exception import UnitTestSuiteError
from platformio.test.runners.base import TestRunnerBase
from platformio.util import strip_ansi_codes


class UnityTestRunner(TestRunnerBase):
Expand Down Expand Up @@ -249,6 +250,7 @@ def generate_unity_extras(self, dst_dir):
)

def on_test_output(self, data):
data = strip_ansi_codes(data or "")
if not data.strip():
return click.echo(data, nl=False)

Expand All @@ -258,11 +260,18 @@ def on_test_output(self, data):
# beautify output
for line in data.strip().split("\n"):
line = line.strip()
if line.endswith(":PASS"):
click.echo("%s\t[%s]" % (line[:-5], click.style("PASSED", fg="green")))
elif line.endswith(":IGNORE"):
if line.strip(".").endswith(":PASS"):
click.echo(
"%s\t[%s]" % (line[:-7], click.style("IGNORED", fg="yellow"))
"%s\t[%s]"
% (line[: line.rindex(":PASS")], click.style("PASSED", fg="green"))
)
elif line.strip(".").endswith(":IGNORE"):
click.echo(
"%s\t[%s]"
% (
line[: line.rindex(":IGNORE")],
click.style("IGNORED", fg="yellow"),
)
)
elif ":FAIL" in line:
click.echo("%s\t[%s]" % (line, click.style("FAILED", fg="red")))
Expand Down

0 comments on commit 3ed5d41

Please sign in to comment.