[TD] test_cpp_extensions_aot_ninja corresponds to things in test/cpp_extensions (#148992)

Manually map test_cpp_extensions_aot_ninja to files in test/cpp_extensions since test_cpp_extensions_aot_ninja isn't an actual file you can edit, but a wrapper for files in test/cpp_extensions.

Idk if this is a good idea, feels very manual.  Maybe it would be better to classify this the same as any other TD failure where TD simply can't figure out the tests it needs to run
Pull Request resolved: https://github.com/pytorch/pytorch/pull/148992
Approved by: https://github.com/malfet, https://github.com/seemethere, https://github.com/janeyx99
This commit is contained in:
Catherine Lee 2025-03-12 15:40:06 +00:00 committed by PyTorch MergeBot
parent 488c4480f9
commit 9a0f65d3d3

View File

@ -1,5 +1,6 @@
from __future__ import annotations from __future__ import annotations
import re
from typing import Any from typing import Any
from warnings import warn from warnings import warn
@ -14,6 +15,18 @@ from tools.testing.target_determination.heuristics.utils import (
from tools.testing.test_run import TestRun from tools.testing.test_run import TestRun
# Some files run tests in other test files, so we map them to each other here.
# This is a map from file that runs the test to regex that matches the file that
# contains the test. Test file with path test/a/b.py should of the form a/b.
# Regexes should be based on repo root.
ADDITIONAL_MAPPINGS = {
# Not files that are tracked by git but rather functions defined in
# run_test.py that generate test files which run tests in test/cpp_extensions.
"test_cpp_extensions_aot_ninja": [r"test\/cpp_extensions.*"],
"test_cpp_extensions_aot_no_ninja": [r"test\/cpp_extensions.*"],
}
class EditedByPR(HeuristicInterface): class EditedByPR(HeuristicInterface):
def __init__(self, **kwargs: dict[str, Any]) -> None: def __init__(self, **kwargs: dict[str, Any]) -> None:
super().__init__(**kwargs) super().__init__(**kwargs)
@ -28,9 +41,16 @@ class EditedByPR(HeuristicInterface):
def _get_modified_tests() -> set[str]: def _get_modified_tests() -> set[str]:
try: try:
changed_files = query_changed_files() changed_files = query_changed_files()
should_run = python_test_file_to_test_name(set(changed_files))
for test_file, regexes in ADDITIONAL_MAPPINGS.items():
if any(
re.search(regex, changed_file) is not None
for regex in regexes
for changed_file in changed_files
):
should_run.add(test_file)
return should_run
except Exception as e: except Exception as e:
warn(f"Can't query changed test files due to {e}") warn(f"Can't query changed test files due to {e}")
# If unable to get changed files from git, quit without doing any sorting # If unable to get changed files from git, quit without doing any sorting
return set() return set()
return python_test_file_to_test_name(set(changed_files))