Skip to content

suite: fix panic if a WithStats suite skips a test early #1802

Closed
segogoreng wants to merge 3 commits into
stretchr:masterfrom
segogoreng:issue_1722
Closed

suite: fix panic if a WithStats suite skips a test early #1802
segogoreng wants to merge 3 commits into
stretchr:masterfrom
segogoreng:issue_1722

Conversation

@segogoreng
Copy link
Copy Markdown

@segogoreng segogoreng commented Sep 23, 2025

Summary

Continues work from #1723 by @FGasper .
This PR rebases with the latest master.

This fixes issue #1722.

Changes

Prevent stats.end() if stats.start() never ran.

Motivation

Allow skipping a test in a setup/before hook. See issue #1722 for an example.

Related issues

Closes #1722

Comment thread suite/suite_stats_and_skip_test.go Outdated
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Do we need a new test file for this?
I feel like we can put this in the existing test file.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think so too. You might also find there's an existing substitute for mySuite.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Moved the test to suite/suite_test.go and renamed mySuite to a more descriptive suiteSkipTestWithStats

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hi @brackendawson, could you take a look at this, please?

@dolmen dolmen force-pushed the issue_1722 branch 2 times, most recently from f947962 to 49f6fcf Compare May 11, 2026 15:43
@dolmen
Copy link
Copy Markdown
Collaborator

dolmen commented May 11, 2026

Closing: #1877 is another merged implementation.

@dolmen dolmen closed this May 11, 2026
@dolmen dolmen added pkg-suite Change related to package testify/suite bug rejected/duplicate labels May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug pkg-suite Change related to package testify/suite rejected/duplicate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

suite: skip in SetupTest() with HandleStats() causes panic

4 participants