Skip to content

proposal: testing: t.Cleanup should run on panic #41355

Description

@powerman

There was a discussion about gomock hang on panic because it's ctrl.Finish() was called inside t.Cleanup instead of defer (golang/mock#428). It helped me to realize t.Cleanup won't be called in case of panic, as I (and probably others too) was expected.

At a glance it looks feasible to change testing package to add few internal defer to ensure t.Cleanup will be called on panic/t.FailNow. And as current documentation doesn't mention is this will happens or not we can consider this change compatible.

In case this proposal will be rejected I think it's worth to update the doc and make explicit that t.Cleanup won't be called on panic, because this limits it usability a lot and probably contradict user's expectations.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions