mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
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:
committed by
PyTorch MergeBot
parent
a21090a38c
commit
99287b170b
@ -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)
|
||||
|
@ -1231,7 +1231,7 @@ def run_tests(argv=UNITTEST_ARGS):
|
||||
if RERUN_DISABLED_TESTS:
|
||||
other_args.append("--rerun-disabled-tests")
|
||||
if TEST_SAVE_XML:
|
||||
other_args += ['--save-xml', args.save_xml]
|
||||
other_args += ['--save-xml', TEST_SAVE_XML]
|
||||
|
||||
test_cases = (
|
||||
get_pytest_test_cases(argv) if USE_PYTEST else
|
||||
@ -1297,7 +1297,7 @@ def run_tests(argv=UNITTEST_ARGS):
|
||||
# exitcode of 5 means no tests were found, which happens since some test configs don't
|
||||
# run tests from certain files
|
||||
sys.exit(0 if exit_code == 5 else exit_code)
|
||||
elif TEST_SAVE_XML is not None:
|
||||
elif TEST_SAVE_XML:
|
||||
# import here so that non-CI doesn't need xmlrunner installed
|
||||
import xmlrunner # type: ignore[import]
|
||||
from xmlrunner.result import _XMLTestResult # type: ignore[import]
|
||||
|
Reference in New Issue
Block a user