Skip to content

Commit

Permalink
render-summary: render skips correctly (#76)
Browse files Browse the repository at this point in the history
Signed-off-by: William Woodruff <[email protected]>
  • Loading branch information
woodruffw authored Nov 3, 2023
1 parent 9d392cd commit 5eb5fc0
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions harness/render-summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import argparse
import json
import os
from pathlib import Path
import sys
from pathlib import Path

# render-summary.py: take a `results.json` from a harness run and render
# it as a GitHub Actions step summary, collating against `limbo.json`
Expand All @@ -16,9 +16,11 @@

_RESULT_ROW = "| {testcase_id} | {status} | {expected} | {actual} | {context} |"


def _render(s: str) -> None:
print(f"{s}", file=_OUT)


parser = argparse.ArgumentParser()
parser.add_argument("limbo", type=Path)
parser.add_argument("results", type=Path)
Expand All @@ -29,26 +31,30 @@ def _render(s: str) -> None:

_render(f"## Limbo results for `{results["harness"]}`\n")

_render("""
_render(
"""
| Testcase | Status | Expected | Actual | Context |
| -------- | ------ | -------- | ------ | ------- |"""
)

for result in results["results"]:
testcase_id = result["id"]
actual = result["actual_result"]

context = result["context"]
if not context:
# Normalize missing context into an empty string.
context = ""
else:
context = f"`{context}`"
context = f"`{context}`" if context else ""

testcase = next(t for t in limbo["testcases"] if t["id"] == testcase_id)
expected = testcase["expected_result"]
description = testcase["description"]

status = "✅" if expected == actual else "❌"
match (expected, actual):
case ("SUCCESS", "SUCCESS") | ("FAILURE", "FAILURE"):
status = "✅"
case (_, "SKIPPED"):
status = "🚧"
case _:
status = "❌"

row = _RESULT_ROW.format(
testcase_id=testcase_id,
Expand Down

0 comments on commit 5eb5fc0

Please sign in to comment.