proposal: testing: allow TestMain to return int #23404
Closed
Labels
Milestone
Comments
Playing the devil's advocate - if one wants to be sure that
I understand that this is more verbose, but I'm wondering if that offsets adding extra code and documentation to the testing package. I would definitely agree with you if the testing package was designed from the ground up, however. Unless there is a specific reason for |
@mvdan |
TestMain is already a rare need. It doesn't make much sense to stack another one on top, especially when you can do what @mvdan suggests. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Currently TestMain is expected to call os.Exit itself, but that means it's
not possible to use defer to do package-wide test cleanup there,
because the defer will never be called.
I propose that TestMain be optionally allowed to return an integer,
in which case os.Exit will be called with its result.
Then we can write:
which is arguably more natural and harder to get wrong than calling os.Exit.
The text was updated successfully, but these errors were encountered: