|
30 | 30 | get_process_memory_usage, EXIT_TIMEOUT) |
31 | 31 |
|
32 | 32 |
|
| 33 | +def github_error(title: str, message: str) -> None: |
| 34 | + # Emit a GitHub Actions error annotation (workflow command) |
| 35 | + def escape(text: str) -> str: |
| 36 | + return (text.replace("%", "%25").replace("\r", "%0D") |
| 37 | + .replace("\n", "%0A")) |
| 38 | + title = escape(title).replace(":", "%3A").replace(",", "%2C") |
| 39 | + print(f"::error title={title}::{escape(message)}", flush=True) |
| 40 | + |
| 41 | + |
33 | 42 | class Regrtest: |
34 | 43 | """Execute a test suite. |
35 | 44 |
|
@@ -504,10 +513,14 @@ def write(text: str) -> None: |
504 | 513 | f"{count(ncase, 'test case')} failed") |
505 | 514 | for result, result_cases in zip(failed, cases): |
506 | 515 | write(f"### {decolor(str(result))}") |
| 516 | + if not result_cases: |
| 517 | + github_error(result.test_name, decolor(str(result))) |
507 | 518 | if result.env_changed_reasons: |
508 | 519 | write("\n".join(f"- {reason}" |
509 | 520 | for reason in result.env_changed_reasons)) |
510 | 521 | for name, traceback in result_cases: |
| 522 | + github_error(f"{result.test_name}: {name}", |
| 523 | + decolor(traceback)) |
511 | 524 | # Expand short tracebacks when there are only a few |
512 | 525 | is_open = ncase <= 5 and traceback.count("\n") < 30 |
513 | 526 | write(f"<details{' open' if is_open else ''}>" |
|
0 commit comments