kunwardeep / paralleltest

Linter to check if your tests have been marked as parallel correctly
MIT License
48 stars 12 forks source link

False positive on tests in go 1.22 / 1.21 w/ GOEXPERIMENT=loopvar #34

Closed pkwarren closed 7 months ago

pkwarren commented 8 months ago

In Go 1.22 (with GOEXPERIMENT=loopvar now the default), the Range statement for test <test> does not reinitialise the variable <var> linter is no longer accurate. If you take the example program linked from https://github.com/kunwardeep/paralleltest?tab=readme-ov-file#tparallel-is-called-in-the-range-method-and-test-case-variable-tc-being-used-but-is-not-reinitialised-more-info, you can see that it no longer reports incorrect output.

Is it possible to omit these warnings when running on Go 1.22+ or allow a mechanism to ignore these warnings?

kunwardeep commented 7 months ago

Hey @pkwarren, thanks for bringing this to my attention. Any chance you could submit a PR?

ldez commented 7 months ago

@kunwardeep I create a PR to add an option https://github.com/kunwardeep/paralleltest/pull/35