-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Milestone
Description
os.Args is similar to os.Getenv that it is a global state of the process. testing package provides a function Setenv on T which tries to help tests which use environment variables:
- It makes sure that such tests are not run in parallel.
- It makes sure to restore env after the test.
Currently, nothing similar exist for os.Args. But sometimes it is necessary to do so to be able to test CLI parsing (especially in tools which expect to read from os.Args. Current option to do the change to os.Args yourself and then restore it has a downside that it does not check if t.Parallel has been called.
I understand that global state is tricky, but making a function which checks for parallel execution could help here.
Reactions are currently unavailable