Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ def pytest_collection() -> None:
"CUDA_VISIBLE_DEVICES", str(xdist_worker_number % num_cuda_devices)
)

_USE_ROCM_ABORT_DETECTOR_PLUGIN = bool(
os.environ.get("PYTEST_ABORT_LAST_RUNNING_FILE")
or os.environ.get("PYTEST_ABORT_LAST_RUNNING_DIR")
)


class ThreadSafeTestLogger:
"""Thread-safe logging for parallel test execution and abort detection"""
def __init__(self):
Expand Down Expand Up @@ -171,8 +177,7 @@ def clear_running_test(self, test_file):
os.remove(log_file)


# Global logger instance
test_logger = ThreadSafeTestLogger()
test_logger = ThreadSafeTestLogger() if not _USE_ROCM_ABORT_DETECTOR_PLUGIN else None


@pytest.hookimpl(hookwrapper=True)
Expand All @@ -183,6 +188,10 @@ def pytest_runtest_protocol(item, nextitem):
when the test completes successfully. If the test crashes, the file remains
and can be detected by the test runner.
"""
if _USE_ROCM_ABORT_DETECTOR_PLUGIN or test_logger is None:
outcome = yield
return outcome

test_file = test_logger.get_test_file_name(item.session)
test_name = item.name
nodeid = item.nodeid
Expand Down Expand Up @@ -230,6 +239,9 @@ def pytest_sessionfinish(session, exitstatus):
If a crash file still exists, it means a test crashed and the runner
will detect it. We just report it here for visibility.
"""
if _USE_ROCM_ABORT_DETECTOR_PLUGIN or test_logger is None:
return

test_file = test_logger.get_test_file_name(session)
log_file = f"{test_logger.base_dir}/{test_file}_last_running.json"

Expand Down