Skip to content

Commit

Permalink
Log test vector properties in the test report
Browse files Browse the repository at this point in the history
  • Loading branch information
vbrkicTT committed Jan 16, 2025
1 parent d51f5a9 commit b96eb45
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion forge/test/operators/pytorch/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
from test.operators.utils import PyTestUtils
from test.operators.utils import FailingReasonsValidation

from ..utils import TestPlanUtils


@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item: _pytest.python.Function, call: _pytest.runner.CallInfo):
Expand All @@ -23,14 +25,16 @@ def pytest_runtest_makereport(item: _pytest.python.Function, call: _pytest.runne
# This hook function is called after each step of the test execution (setup, call, teardown)
if call.when == "call": # 'call' is a phase when the test is actually executed

xfail_reason = PyTestUtils.get_xfail_reason(item)

if call.excinfo is not None: # an exception occurred during the test execution

logger.trace(
f"Test: skipped: {report.skipped} failed: {report.failed} passed: {report.passed} report: {report}"
)

exception_value = call.excinfo.value
xfail_reason = PyTestUtils.get_xfail_reason(item)

if xfail_reason is not None: # an xfail reason is defined for the test
valid_reason = FailingReasonsValidation.validate_exception(exception_value, xfail_reason)

Expand All @@ -50,3 +54,30 @@ def pytest_runtest_makereport(item: _pytest.python.Function, call: _pytest.runne
outcome.force_result(new_report)
else:
logger.debug(f"Test '{item.name}' failed with exception: {type(exception_value)} '{exception_value}'")

log_test_vector_properties(item, report, xfail_reason)


def log_test_vector_properties(item: _pytest.python.Function, report: _pytest.reports.TestReport, xfail_reason: str):
original_name = item.originalname
test_id = item.name
test_id = test_id.replace(f"{original_name}[", "")
test_id = test_id.replace("]", "")
test_vector = TestPlanUtils.test_id_to_test_vector(test_id)

item.user_properties.append(("id", test_id))
item.user_properties.append(("operator", test_vector.operator))
item.user_properties.append(
("input_source", test_vector.input_source.name if test_vector.input_source is not None else None)
)
item.user_properties.append(
("dev_data_format", test_vector.dev_data_format.name if test_vector.dev_data_format is not None else None)
)
item.user_properties.append(
("math_fidelity", test_vector.math_fidelity.name if test_vector.math_fidelity is not None else None)
)
item.user_properties.append(("input_shape", test_vector.input_shape))
item.user_properties.append(("kwargs", test_vector.kwargs))
if xfail_reason is not None:
item.user_properties.append(("xfail_reason", xfail_reason))
item.user_properties.append(("outcome", report.outcome))

0 comments on commit b96eb45

Please sign in to comment.