+
Skip to content

proposal: Exclude transactions closed in t.Cleanup from unclosetx check #51

Open
@uji

Description

@uji

Currently, the unclosetx check detects unclosed transactions.
However, in test code, it is becoming more common to close transactions using t.Cleanup.

tx := client.ReadOnlyTransaction()
t.Cleanup(tx.Close)
// ...

t.Cleanup is a method that registers a cleanup function to be executed at the end of the test function. It is similar to defer, but it ensures that the cleanup function runs only after all parallel subtests have completed.

However, the current unclosetx check considers transactions closed inside t.Cleanup as unclosed, leading to false positives.

To improve this, I would like to propose modifying the unclosetx check to exclude transactions that are closed inside t.Cleanup, similar to how it already handles defer.
Would this be a feasible enhancement?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载