Skip to content

Conversation

@SimoTod
Copy link

@SimoTod SimoTod commented Oct 3, 2025

This pull request updates the linter so it does not report an error when t.SetEnv is used.

For example

func TestSomething(t *testing.T) {
	t.Setenv("foo", "bar")

	t.Run("Test 1", func(t *testing.T) {
		t.Parallel()

		// actual test
	})

	t.Run("test 2", func(t *testing.T) {		                
		// actual test
	})
}

TestSomething cannot be run in parallel as it sets an env variable. However, once or more children could still be allowed to run in parallel. When combined to other linters like paralleltest, this conflicts and forces developers to add nolint comments to their tests.

Fixes #25

@SimoTod SimoTod changed the title Fix: Do not require t.parallel if the function uses SetEnv Fix: Do not require t.Parallel if the function uses t.Setenv Oct 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should not require parallel tests if T.Setenv() is called

1 participant