Skip to content

Commit

Permalink
fix(common): small improvements to result display
Browse files Browse the repository at this point in the history
Minor fixes to DebugInfo and TestInfo.

Save the entire TestInfo instance instead of just the debug data,
otherwise the result is not shown in the report.

Fix a bug with spacing between results and debug data.
  • Loading branch information
JulioLoayzaM committed Aug 22, 2024
1 parent 8320432 commit d4cf7ea
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions crypto_condor/primitives/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,8 @@ def __str__(self):
"""Returns a string representation."""
s = f"ID = {self.tid}\n"
s += f"Result = {'PASS' if self.result else 'FAIL'}\n"
# TODO: add test type?
# s += f"Test type: {self.test_type}\n"
s += f"Flags: {self.flags}\n"
s += f"Type = {self.test_type}\n"
s += f"Flags = {self.flags}\n"
s += f"Comment = {self.comment if self.comment else '<none>'}\n"
if self.error_msg:
s += f"Error = {self.error_msg}\n"
Expand Down Expand Up @@ -227,7 +226,7 @@ def __str__(self) -> str:
elif self.result is not None:
s += "Result = [red1]FAIL[/]\n"
if self.err_msg:
s += "Error = {self.err_msg}\n"
s += f"Error = {self.err_msg}\n"
else:
s += "Result = [yellow1]None[/]\n"
return s
Expand Down Expand Up @@ -509,7 +508,7 @@ class that has an attribute called ``info`` which is an instance of
raise ValueError("The result of test %d is None" % data.id)
self._tids.add(data.id)
self._flags |= set(data.flags)
self.data[data.id] = data.data
self.data[data.id] = data
match data.type:
case TestType.VALID:
self.valid.add(data.id, data.result, data.flags)
Expand Down Expand Up @@ -609,8 +608,14 @@ def __str__(self) -> str:
s += f" Failed: {inv_f}\n"
if acc_p + acc_f > 0:
s += "Acceptable tests:\n"
s += f" Passed: [yellow1]{acc_p}[/]\n"
s += f" Failed: [yellow1]{acc_f}[/]\n"
if acc_p > 0:
s += f" Passed: [yellow1]{acc_p}[/]\n"
else:
s += f" Passed: {acc_p}\n"
if acc_f > 0:
s += f" Failed: [yellow1]{acc_f}[/]\n"
else:
s += f" Failed: {acc_f}\n"
# Remove the leading newline, avoids the extra space inside the panel.
return s.rstrip("\n")

Expand Down Expand Up @@ -811,11 +816,12 @@ def process_results(
for data in track(
r.data.values(), f"Writing debug data {count}/{num_res}"
):
printer.print(str(data))
# For TestInfo we have to print the debug data
# separately.
if isinstance(data, TestInfo):
printer.print(str(data.data))
printer.print(str(data), str(data.data))
else:
printer.print(str(data))
else:
header = "Debug data"
line = "^" * len(header)
Expand Down

0 comments on commit d4cf7ea

Please sign in to comment.