Repository navigation
[torchci] Report C++ tests - #200980
[torchci] Report C++ tests#200980georgehong wants to merge 5 commits into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/200980
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit f22e421 with merge base 47383b7 ( 🟡 GREEN LIGHT - OUTDATED (earlier commit) - PR requires human review:
reason: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
**Summary:** C++ tests run as `pytest <binary>` under pytest-cpp, not through run_tests, so run_test.py registers the report plugin for them. Each gtest is recorded as file `cpp/<binary>`, the name run_test.py and junit already use, with language `cpp` and the suite and test name from gtest's JSON test list (`--gtest_list_tests --gtest_output=json`), which keeps them as separate fields; a full name can't always be split on its `.`, since a custom typed-name generator can put one in the suite. The plugin lists each binary once per process itself, which costs about as much as running one of its tests, rather than setting GTEST_OUTPUT around pytest-cpp's own listing. Only pytest-cpp's Google Test items are recorded. The declared name drops a value-parameterized test's `/<param>`. As in junit, a gtest whose process crashed is `failed` with pytest-cpp's message. A test's source file isn't recorded, so owners for `cpp/<binary>` are left to a follow-up. run_test.py runs C++ tests under xdist with `-x`, which stops right after the final failing report, before the teardown report where the writer writes the run. Runs whose failure is already known are now written at session end; without that, the attempt that stops a C++ run is missing from its report. An xdist worker that dies isn't recorded: pytest-rerunfailures sends a test's reports only after each attempt, so the controller never has the identity of the test the worker was running. junit and the log still have it. **Test Plan:** ``` python test/torchci/test_testing.py CPP_TESTS_DIR=<dir with a gtest binary> python test/run_test.py --cpp -i cpp/<binary> --save-torchci-reports <dir> ``` `test_xdist_maxfail` fails without the session-end flush. Authored with the help of an AI assistant (Claude). ghstack-source-id: 99292dc Pull-Request: #200980
|
Part of pytorch/test-infra#9102 |
| if not is_cpp_test: | ||
| return [f"--save-torchci-reports={reports_dir}"] |
There was a problem hiding this comment.
Curious, why can't we always pass this? Empty reports?
There was a problem hiding this comment.
--save-torchci-reports is used by Python test files from run_tests() from common_utils.py. In comparison, C++ passes plugin args directly to pytest. If we always pass it in, it would trigger a pytest usage error for unknown options.
| return [f"--save-torchci-reports={reports_dir}"] | ||
| # C++ tests run under pytest-cpp, not run_tests, so register the plugin here. | ||
| prefix = Path(reports_dir) / sanitize_test_filename(test_file) | ||
| plugin = "torch.testing._internal.torchci.plugin" |
There was a problem hiding this comment.
I wonder if we can get this by importing plugin and getting the module name.
from torch.testing._internal.torchci import plugin
plugin._some_method_that_gives_module_name
There was a problem hiding this comment.
Suggestion incorporated - thanks!
| gtest adds an instantiation's ``Prefix/`` and a typed suite's ``/<type>`` to | ||
| the suite, and a value-parameterized test's ``/<param>`` to the test name; the | ||
| declared name drops that ``/<param>``.""" | ||
| file = f"cpp/{Path(binary).stem}" |
There was a problem hiding this comment.
I do wonder, do we even need the cpp/? The "language" column already tells us that
There was a problem hiding this comment.
run_test.py takes the same name, taking -i cpp/test_api, and this seems to be what our codebase currently uses throughout. C++ tests appear to go by cpp/binary: https://github.com/pytorch/pytorch/blob/main/.ci/pytorch/test.sh also has extensive usage of this with --cpp.
|
@claude Review this change |
|
Claude finished @huydhn's task in 1m 37s —— View job I found no correctness problems in this PR. There are two small cleanups and one optional testing gap, and none of them blocks merging. PR Review: #200980SummaryThe PR registers the torchci report plugin for C++ tests run under pytest-cpp. It names each gtest from the binary's JSON test list. It also writes out runs that already failed but whose teardown report never arrived because Code Quality
Testing
RecommendationApprove. Nothing blocks merging. I'd still fix the duplicated arg construction and the misleading comment before landing. |
**Summary:** C++ tests run as `pytest <binary>` under pytest-cpp, not through run_tests, so run_test.py registers the report plugin for them. Each gtest is recorded as file `cpp/<binary>`, the name run_test.py and junit already use, with language `cpp` and the suite and test name from gtest's JSON test list (`--gtest_list_tests --gtest_output=json`), which keeps them as separate fields; a full name can't always be split on its `.`, since a custom typed-name generator can put one in the suite. The plugin lists each binary once per process itself, which costs about as much as running one of its tests, rather than setting GTEST_OUTPUT around pytest-cpp's own listing. Only pytest-cpp's Google Test items are recorded. The declared name drops a value-parameterized test's `/<param>`. As in junit, a gtest whose process crashed is `failed` with pytest-cpp's message. A test's source file isn't recorded, so owners for `cpp/<binary>` are left to a follow-up. run_test.py runs C++ tests under xdist with `-x`, which stops right after the final failing report, before the teardown report where the writer writes the run. Runs whose failure is already known are now written at session end; without that, the attempt that stops a C++ run is missing from its report. An xdist worker that dies isn't recorded: pytest-rerunfailures sends a test's reports only after each attempt, so the controller never has the identity of the test the worker was running. junit and the log still have it. **Test Plan:** ``` python test/torchci/test_testing.py CPP_TESTS_DIR=<dir with a gtest binary> python test/run_test.py --cpp -i cpp/<binary> --save-torchci-reports <dir> ``` `test_xdist_maxfail` fails without the session-end flush. Authored with the help of an AI assistant (Claude). ghstack-source-id: 9089b90 Pull-Request: #200980
**Summary:** C++ tests run as `pytest <binary>` under pytest-cpp, not through run_tests, so run_test.py registers the report plugin for them. Each gtest is recorded as file `cpp/<binary>`, the name run_test.py and junit already use, with language `cpp` and the suite and test name from gtest's JSON test list (`--gtest_list_tests --gtest_output=json`), which keeps them as separate fields; a full name can't always be split on its `.`, since a custom typed-name generator can put one in the suite. The plugin lists each binary once per process itself, which costs about as much as running one of its tests, rather than setting GTEST_OUTPUT around pytest-cpp's own listing. Only pytest-cpp's Google Test items are recorded. The declared name drops a value-parameterized test's `/<param>`. As in junit, a gtest whose process crashed is `failed` with pytest-cpp's message. A test's source file isn't recorded, so owners for `cpp/<binary>` are left to a follow-up. run_test.py runs C++ tests under xdist with `-x`, which stops right after the final failing report, before the teardown report where the writer writes the run. Runs whose failure is already known are now written at session end; without that, the attempt that stops a C++ run is missing from its report. An xdist worker that dies isn't recorded: pytest-rerunfailures sends a test's reports only after each attempt, so the controller never has the identity of the test the worker was running. junit and the log still have it. **Test Plan:** ``` python test/torchci/test_testing.py CPP_TESTS_DIR=<dir with a gtest binary> python test/run_test.py --cpp -i cpp/<binary> --save-torchci-reports <dir> ``` `test_xdist_maxfail` fails without the session-end flush. Authored with the help of an AI assistant (Claude). ghstack-source-id: 2a6a5da Pull-Request: #200980
|
rebase onto timeout/crash handling PR to avoid merge conflict |
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 1 STARTUP failures reported, please check workflows syntax! Details for Dev Infra teamRaised by workflow job |
**Summary:** C++ tests run as `pytest <binary>` under pytest-cpp, not through run_tests, so run_test.py registers the report plugin for them. Each gtest is recorded as file `cpp/<binary>`, the name run_test.py and junit already use, with language `cpp` and the suite and test name from gtest's JSON test list (`--gtest_list_tests --gtest_output=json`), which keeps them as separate fields; a full name can't always be split on its `.`, since a custom typed-name generator can put one in the suite. The plugin lists each binary once per process itself, which costs about as much as running one of its tests, rather than setting GTEST_OUTPUT around pytest-cpp's own listing. Only pytest-cpp's Google Test items are recorded. The declared name drops a value-parameterized test's `/<param>`. As in junit, a gtest whose process crashed is `failed` with pytest-cpp's message. A test's source file isn't recorded, so owners for `cpp/<binary>` are left to a follow-up. run_test.py runs C++ tests under xdist with `-x`, which stops right after the final failing report, before the teardown report where the writer writes the run. Runs whose failure is already known are now written at session end; without that, the attempt that stops a C++ run is missing from its report. An xdist worker that dies isn't recorded: pytest-rerunfailures sends a test's reports only after each attempt, so the controller never has the identity of the test the worker was running. junit and the log still have it. **Test Plan:** ``` python test/torchci/test_testing.py CPP_TESTS_DIR=<dir with a gtest binary> python test/run_test.py --cpp -i cpp/<binary> --save-torchci-reports <dir> ``` `test_xdist_maxfail` fails without the session-end flush. Authored with the help of an AI assistant (Claude). ghstack-source-id: 1b49284 Pull-Request: #200980
|
rebase to address merge error
|
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: GraphQL query Details for Dev Infra teamRaised by workflow job |
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
…trict workflows (#201097) **Summary:** Continue rollout. This should be passing based on #201020 already, with the exception of `periodic-strict`, so `ci-no-td` shouldn't be necessary here. Authored with the help of an AI assistant (Claude). Pull Request resolved: #201097 Approved by: https://github.com/jathu, https://github.com/huydhn ghstack dependencies: #200980
✴️ iz2: When a GitHub GraphQL call fails, mergebot's "Merge failed" comment put the whole query and its variables on the **Reason** line, about 40 lines of query text (example: #200980). Now **Reason** shows only GitHub's error message, on one line (or "(no error message)" when the errors list is empty): > **Reason**: GitHub GraphQL query failed: Something went wrong while executing your query on 2026-10-15T17:52:34Z. Please include `83C2:…` when reporting this issue. The variables, raw errors and query move into "Details for Dev Infra team" as fenced blocks, each size-capped to keep the comment under GitHub's 65536-char limit. The same context also stays in the job log for every `gh_graphql` caller: `gh_graphql` prints it when it raises, and `GHGraphQLError` adds it as an exception note on Python 3.11+ (mergebot runs on 3.10, where tracebacks don't show notes). `handle_exception` becomes the module-level `format_failure_comment()` so it can be tested. The details block now also appears when there is a failing merge rule but `GH_RUN_URL` is unset. **Exposure check:** the comment and log contain nothing sensitive. The token is sent as an HTTP header and never reaches the exception. The query text is already in this repo. The variables are owner, repo name, PR number and opaque pagination cursors. The request ID is the one GitHub asks you to share. Test plan: `python -m unittest test_trymerge test_delete_old_branches` in `.github/scripts` (Python 3.12): 159 pass, 2 skipped. `TestFailureComment` covers the short reason, empty errors, the log output and note, the collapsed details, size caps, the merge-rule case and the no-details case. Pull Request resolved: #201104 Approved by: https://github.com/huydhn
…h#201104) ✴️ iz2: When a GitHub GraphQL call fails, mergebot's "Merge failed" comment put the whole query and its variables on the **Reason** line, about 40 lines of query text (example: pytorch#200980). Now **Reason** shows only GitHub's error message, on one line (or "(no error message)" when the errors list is empty): > **Reason**: GitHub GraphQL query failed: Something went wrong while executing your query on 2026-10-15T17:52:34Z. Please include `83C2:…` when reporting this issue. The variables, raw errors and query move into "Details for Dev Infra team" as fenced blocks, each size-capped to keep the comment under GitHub's 65536-char limit. The same context also stays in the job log for every `gh_graphql` caller: `gh_graphql` prints it when it raises, and `GHGraphQLError` adds it as an exception note on Python 3.11+ (mergebot runs on 3.10, where tracebacks don't show notes). `handle_exception` becomes the module-level `format_failure_comment()` so it can be tested. The details block now also appears when there is a failing merge rule but `GH_RUN_URL` is unset. **Exposure check:** the comment and log contain nothing sensitive. The token is sent as an HTTP header and never reaches the exception. The query text is already in this repo. The variables are owner, repo name, PR number and opaque pagination cursors. The request ID is the one GitHub asks you to share. Test plan: `python -m unittest test_trymerge test_delete_old_branches` in `.github/scripts` (Python 3.12): 159 pass, 2 skipped. `TestFailureComment` covers the short reason, empty errors, the log output and note, the collapsed details, size caps, the merge-rule case and the no-details case. Pull Request resolved: pytorch#201104 Approved by: https://github.com/huydhn
Stack from ghstack (oldest at bottom):
Summary:
Writes test run reports for C++ tests. run_test.py runs them as
pytest <binary>under pytest-cpp rather than through run_tests, so it registers the report plugin itself.Each gtest is recorded as
cpp/<binary>, the name run_test.py and junit already use. Its suite and test name come from gtest's JSON test list (--gtest_list_tests --gtest_output=json, one extra launch per xdist worker) rather than from splitting the full name, since a custom typed-name generator can put a.in the suite. The declared name drops a value parameter's/<param>. Only Google Test binaries are recorded, not pytest-cpp's Boost.Test or Catch2 items. Owners forcpp/<binary>are left to a follow-up.C++ tests run under xdist with
-x, which stops before the final failure's teardown report, where the writer writes the run. Runs with a known failure are now written at session end, so the failure that stops a run is no longer missing. As in junit, a crashed gtest isfailedwith pytest-cpp's message; a dead xdist worker's test isn't recorded, since pytest-rerunfailures only sends a test's reports after each attempt.Test Plan:
Added unit tests, inspection of CI, and ran C++ torch test suite as smoke test on devgpu.
Authored with the help of an AI assistant (Claude).