Generate test reports for pytest when option is given (#152170)

The argument needs to be appended when test reports should be generated. IS_CI is not necessarily set, so rather check TEST_SAVE_XML instead as in other places where test reports are conditionally enabled.

See also https://github.com/pytorch/pytorch/issues/126523
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152170
Approved by: https://github.com/Skylion007
This commit is contained in:
Alexander Grund
2025-05-05 17:46:35 +00:00
committed by PyTorch MergeBot
parent a21090a38c
commit 99287b170b
2 changed files with 4 additions and 3 deletions

View File

@ -34,6 +34,7 @@ from torch.testing._internal.common_utils import (
set_cwd,
shell,
TEST_CUDA,
TEST_SAVE_XML,
TEST_WITH_ASAN,
TEST_WITH_CROSSREF,
TEST_WITH_ROCM,
@ -1169,7 +1170,7 @@ def get_pytest_args(options, is_cpp_test=False, is_distributed_test=False):
# is much slower than running them directly
pytest_args.extend(["-n", str(NUM_PROCS)])
if IS_CI:
if TEST_SAVE_XML:
# Add the option to generate XML test report here as C++ tests
# won't go into common_utils
test_report_path = get_report_path(pytest=True)