Skip to content

[ci] print rerun stacktraces for pytest - #86831

Closed
clee2000 wants to merge 5 commits into
masterfrom
csl/pytestlogs
Closed

clee2000 wants to merge 5 commits into
masterfrom
csl/pytestlogs

Conversation

@clee2000

@clee2000 clee2000 commented Oct 12, 2022 •

Copy link
Copy Markdown
Contributor

@pytorch-bot

pytorch-bot Bot commented Oct 12, 2022 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/86831

Note: Links to docs will display an error until the docs builds have been completed.

❌ 5 Failures

As of commit adcb8ec:

The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot Bot added the topic: not user facing topic category label Oct 12, 2022
@clee2000
clee2000 marked this pull request as ready for review October 13, 2022 17:20
@clee2000
clee2000 requested a review from a team October 13, 2022 17:20
@huydhn

huydhn commented Oct 13, 2022

Copy link
Copy Markdown
Contributor

Looking at your PR, I realize that test/functorch/conftest.py can now be removed #86927. Let see if functorch tests pass on that PR, once it's merged. You can rebase this on top and skip the change to test/functorch/conftest.py

@huydhn huydhn left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird, removing this file from functorch breaks it #86927. I'll take a closer look but there is no need to be blocked on that PR Found the cause, we also need to remove pytest.ini under test/functorch

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Oct 13, 2022
@clee2000

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge -f "failures unrelated, sample example shows that it works"

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@github-actions
github-actions Bot deleted the csl/pytestlogs branch April 15, 2024 02:52
pytorchmergebot pushed a commit that referenced this pull request Oct 31, 2026
## Human Note
Claude removed the tb=line branch since it doesn't trigger in CI, and claims the teardown sections stuff never worked even on older pytest. I don't really have a bone in this fight.

## Agent Report
test/conftest.py's RERUNS section (#86831) prints why each rerun attempt
failed, since pytest-rerunfailures itself only lists reruns. It did so through
four private TerminalReporter methods (`_getcrashline`, `_getfailureheadline`,
`_outrep_summary`, `_handle_teardown_sections`). pytest 9.2 changed
`_handle_teardown_sections` to take a `NodeId`, so the teardown part silently
printed nothing.

This builds the same output from public API: each rerun report's `head_line`,
`toterminal()` (onto `config.get_terminal_writer()`) and `sections`, filtered by
`--show-capture` like pytest's FAILURES section. With `--tb=line` it still
prints one crash line per attempt, now from the public
`rep.longrepr.reprcrash` (falling back to the start of `str(longrepr)`, as
`_getcrashline` did, for a plain-string longrepr such as an xdist worker
crash's).

One part is dropped: the teardown sections. They were looked up by node id, so
they printed the teardown output of every attempt of the test (including the
one that passed) under each failed attempt.

Test plan: a flaky test that prints in call and teardown, a test that fails all
attempts, and a passing test, run with `--reruns=1` under pytest 7.3.2, 9.1.1
and 9.2.0, with `--tb=native` and `--tb=long --color=yes --showlocals`. The new
RERUNS section is identical to the old one except for the dropped teardown
sections. With `--tb=line` (adding a setup error and a `pytrace=False` failure)
under 7.3.2 and 9.2.0, it prints one line per attempt, matching the old
conftest except where the two pytest versions format `reprcrash` differently.

```
cd test && PYTHONPATH=<pytest==$V overlay> python -m pytest -p no:cacheprovider zz_scratch_reruns.py --reruns=1
```

Authored with an AI assistant (Claude).

<details>
<summary>Agent Worklog</summary>

- 2026-10-28: split out of #202390 (C). Verified on 7.3.2/9.1.1/9.2.0.
- 2026-10-29: kept the `--tb=line` branch (automated review), via public `reprcrash`.

</details>

---
*This PR was generated by [ptq](https://github.com/drisspg/pt_job_queue) with human review.*

Pull Request resolved: #202412
Approved by: https://github.com/Skylion007
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 5, 2026
## Human Note
Claude removed the tb=line branch since it doesn't trigger in CI, and claims the teardown sections stuff never worked even on older pytest. I don't really have a bone in this fight.

## Agent Report
test/conftest.py's RERUNS section (pytorch#86831) prints why each rerun attempt
failed, since pytest-rerunfailures itself only lists reruns. It did so through
four private TerminalReporter methods (`_getcrashline`, `_getfailureheadline`,
`_outrep_summary`, `_handle_teardown_sections`). pytest 9.2 changed
`_handle_teardown_sections` to take a `NodeId`, so the teardown part silently
printed nothing.

This builds the same output from public API: each rerun report's `head_line`,
`toterminal()` (onto `config.get_terminal_writer()`) and `sections`, filtered by
`--show-capture` like pytest's FAILURES section. With `--tb=line` it still
prints one crash line per attempt, now from the public
`rep.longrepr.reprcrash` (falling back to the start of `str(longrepr)`, as
`_getcrashline` did, for a plain-string longrepr such as an xdist worker
crash's).

One part is dropped: the teardown sections. They were looked up by node id, so
they printed the teardown output of every attempt of the test (including the
one that passed) under each failed attempt.

Test plan: a flaky test that prints in call and teardown, a test that fails all
attempts, and a passing test, run with `--reruns=1` under pytest 7.3.2, 9.1.1
and 9.2.0, with `--tb=native` and `--tb=long --color=yes --showlocals`. The new
RERUNS section is identical to the old one except for the dropped teardown
sections. With `--tb=line` (adding a setup error and a `pytrace=False` failure)
under 7.3.2 and 9.2.0, it prints one line per attempt, matching the old
conftest except where the two pytest versions format `reprcrash` differently.

```
cd test && PYTHONPATH=<pytest==$V overlay> python -m pytest -p no:cacheprovider zz_scratch_reruns.py --reruns=1
```

Authored with an AI assistant (Claude).

<details>
<summary>Agent Worklog</summary>

- 2026-10-28: split out of pytorch#202390 (C). Verified on 7.3.2/9.1.1/9.2.0.
- 2026-10-29: kept the `--tb=line` branch (automated review), via public `reprcrash`.

</details>

---
*This PR was generated by [ptq](https://github.com/drisspg/pt_job_queue) with human review.*

Pull Request resolved: pytorch#202412
Approved by: https://github.com/Skylion007
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 9, 2026
## Human Note
Claude removed the tb=line branch since it doesn't trigger in CI, and claims the teardown sections stuff never worked even on older pytest. I don't really have a bone in this fight.

## Agent Report
test/conftest.py's RERUNS section (pytorch#86831) prints why each rerun attempt
failed, since pytest-rerunfailures itself only lists reruns. It did so through
four private TerminalReporter methods (`_getcrashline`, `_getfailureheadline`,
`_outrep_summary`, `_handle_teardown_sections`). pytest 9.2 changed
`_handle_teardown_sections` to take a `NodeId`, so the teardown part silently
printed nothing.

This builds the same output from public API: each rerun report's `head_line`,
`toterminal()` (onto `config.get_terminal_writer()`) and `sections`, filtered by
`--show-capture` like pytest's FAILURES section. With `--tb=line` it still
prints one crash line per attempt, now from the public
`rep.longrepr.reprcrash` (falling back to the start of `str(longrepr)`, as
`_getcrashline` did, for a plain-string longrepr such as an xdist worker
crash's).

One part is dropped: the teardown sections. They were looked up by node id, so
they printed the teardown output of every attempt of the test (including the
one that passed) under each failed attempt.

Test plan: a flaky test that prints in call and teardown, a test that fails all
attempts, and a passing test, run with `--reruns=1` under pytest 7.3.2, 9.1.1
and 9.2.0, with `--tb=native` and `--tb=long --color=yes --showlocals`. The new
RERUNS section is identical to the old one except for the dropped teardown
sections. With `--tb=line` (adding a setup error and a `pytrace=False` failure)
under 7.3.2 and 9.2.0, it prints one line per attempt, matching the old
conftest except where the two pytest versions format `reprcrash` differently.

```
cd test && PYTHONPATH=<pytest==$V overlay> python -m pytest -p no:cacheprovider zz_scratch_reruns.py --reruns=1
```

Authored with an AI assistant (Claude).

<details>
<summary>Agent Worklog</summary>

- 2026-10-28: split out of pytorch#202390 (C). Verified on 7.3.2/9.1.1/9.2.0.
- 2026-10-29: kept the `--tb=line` branch (automated review), via public `reprcrash`.

</details>

---
*This PR was generated by [ptq](https://github.com/drisspg/pt_job_queue) with human review.*

Pull Request resolved: pytorch#202412
Approved by: https://github.com/Skylion007
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants