-
-
Notifications
You must be signed in to change notification settings - Fork 671
doc: don't use os.Setenv in examples #1548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
actually - this isn't a problem in ginkgo because it implements per-process parallelization. you can actually use |
Nice, I did not know that, thanks for the explanation. Yet, the cleanup in the docs mentioned above is still not necessary? If that is so, should the doc be fixed anyway? |
hey @kolyshkin - while it's true that one could call |
Just to clarify (and thank you for your help in advance) -- is it true that each
Yes, I do understand that it's just to illustrate things, but given that
this makes it a subpar example, since:
Any example is a piece of documentation in itself, and official documentation is often considered a "best practices" document. Also, people tend to overlook details and just follow the examples. That's why I think using |
hey @kolyshkin sorry for the confusion. the documentation covers how Ginkgo runs specs in parallel so i recommend reading that. in brief, by default invoking As for the example - |
Related: #838
The official documentation https://onsi.github.io/ginkgo/#spec-cleanup-aftereach-and-defercleanup promotes the use of os.Setenv to set per-test-case environment variables. This is dangerous, since the environment is per-process, meaning any other tests running in parallel will have the same environment. Go's testing package solved this, providing Setenv since Go 1.17. If used together with t.Parallel, it errors out.
In Ginkgo, one can use something like:
It seems that documentation should document this way, instead of promoting
os.Setenv
use in tests.The text was updated successfully, but these errors were encountered: