Thanks to visit codestin.com
Credit goes to github.com

Skip to content

doc: don't use os.Setenv in examples #1548

@kolyshkin

Description

@kolyshkin

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:

t := GinkgoT()
t.Setenv(newDir)

It seems that documentation should document this way, instead of promoting os.Setenv use in tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions