Closed spencerschrock closed 9 months ago
@mitar would you mind taking a first look at the added tests to see what's now being flagged/not-flagged, and if it addresses your comment?
Thanks. This looks great.
Maybe add some test cases which use a test helper (function which calls t.Helper()
) and in it it calls t.Setenv
. Then test case should still not be flagged for missing t.Parallel
.
Maybe add some test cases which use a test helper (function which calls
t.Helper()
) and in it it callst.Setenv
. Then test case should still not be flagged for missingt.Parallel
.
Ah that's a great catch, though it's a harder case to handle with how the rest of the analyzer is written. I don't think I'll try to implement it in this PR, it would involve larger changes to the analyzer. My initial thoughts involve some sort of pre-pass to identify test helpers which call Setenv
, and then a call analysis for reachability.
I like this simple approach implemented here. We are having the same issues where if we use t.Setenv() along with t.Parallel() we get a panic yet the linter is telling us we are wong.
Sorry folks, I was away on holiday. I will take a look at this today
Setenv cannot be used in parallel tests or tests with parallel ancestors.
This attempts to fix the issue raised in https://github.com/kunwardeep/paralleltest/issues/13#issuecomment-1749707624