fix(dashboard-testing): preserve pytest skipped report shape

This commit is contained in:
2026-10-11 01:33:58 +03:00
parent 0da33919d6
commit 6433b61a5d

View File

@@ -126,6 +126,47 @@ def safe_failure(excinfo):
{'path': str(entry.path), 'line': entry.lineno + 1} for entry in excinfo.traceback]}, sort_keys=True)
# #region Tooling.VerifyDashboardTestingCurrent.SkipReport [C:2] [TYPE Function]
# @POST A valid owned skip location keeps pytest's required tuple shape with a fixed public reason; malformed locations refuse.
def safe_skip_report(longrepr, root: Path):
if (not isinstance(longrepr, tuple) or len(longrepr) != 3
or not isinstance(longrepr[0], str) or not longrepr[0]
or type(longrepr[1]) is not int or longrepr[1] < 0
or not isinstance(longrepr[2], str)
or re.search(r'[\x00-\x1f]', longrepr[0])):
refuse('FINAL_SKIP_REPORT_INVALID')
location = Path(longrepr[0])
if location.is_absolute():
try:
location = location.relative_to(root)
except ValueError:
refuse('FINAL_SKIP_REPORT_LOCATION_INVALID')
if '..' in location.parts or location == Path('.'):
refuse('FINAL_SKIP_REPORT_LOCATION_INVALID')
return location.as_posix(), longrepr[1], 'FINAL_NODE_SKIPPED'
# #endregion Tooling.VerifyDashboardTestingCurrent.SkipReport
# #region Tooling.VerifyDashboardTestingCurrent.ReportPrivacy [C:2] [TYPE Function]
# @POST Public reports retain installed pytest/JUnit outcome shapes while private reasons and captured output are removed.
def sanitize_report(report, call, safe, root: Path):
if report.outcome not in {'passed', 'failed', 'skipped'}:
refuse('FINAL_REPORT_OUTCOME_INVALID')
report.sections = []
report.user_properties = [(safe.text(key), safe.value(value)) for key, value in report.user_properties]
if hasattr(report, 'wasxfail'):
if not isinstance(report.wasxfail, str):
refuse('FINAL_XFAIL_REPORT_INVALID')
report.wasxfail = 'FINAL_NODE_XFAIL'
if report.skipped and not hasattr(report, 'wasxfail'):
report.longrepr = safe_skip_report(report.longrepr, root)
elif report.failed and call.excinfo:
report.longrepr = safe_failure(call.excinfo)
elif report.longrepr:
report.longrepr = 'FINAL_NODE_' + report.outcome.upper()
# #endregion Tooling.VerifyDashboardTestingCurrent.ReportPrivacy
# #region Tooling.VerifyDashboardTestingCurrent.PrivateFailures [C:3] [TYPE Class]
# @PRE The evidence directory belongs to this new attempt; diagnostics are never written beside a foreign existing attempt.
# @POST Original failure causes are retained once before report sanitization in one exclusively created private0600 JSONL.
@@ -335,12 +376,7 @@ def run_suite(root: Path, evidence: Path, commit: str, safe: SafeLogs, diagnosti
logger.explore('Frozen suite failure retained privately',
src='Tooling.VerifyDashboardTestingCurrent', error_code='FINAL_NODE_FAILED',
claim='OBSERVED: original failure retained before public report sanitization', payload=observed)
report.sections = []
report.user_properties = [(safe.text(key), safe.value(value)) for key, value in report.user_properties]
if report.failed and call.excinfo:
report.longrepr = safe_failure(call.excinfo)
elif report.longrepr:
report.longrepr = 'FINAL_NODE_' + report.outcome.upper()
sanitize_report(report, call, safe, root)
def retain_collection_failure(self, report):
if report.failed and not getattr(report, '_verify_private_failure_retained', False):