Skip to content
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

paralleltest: Function missing the call to method parallel (paralleltest) #149

Closed
CarlJi opened this issue Jun 4, 2024 · 2 comments
Closed
Milestone

Comments

@CarlJi
Copy link
Contributor

CarlJi commented Jun 4, 2024

image
@CarlJi
Copy link
Contributor Author

CarlJi commented Jun 4, 2024

我们知道,通常我们会使用 go test ./... 来执行某仓库下的所有用例,它的规则是:

  • 不同的包的单测是并行的
  • 但相同的包的单测是顺序执行的

而借助 t.Parallel() , 能让同包下的用例也并行,会让单测执行的更快,这也是上面检测错误的由来。

但实际上,go的单测通常是很小的方法,本身执行就很快,所以没必要非得上这个能力。甚至,有时候滥用这个能力,可能会导致数据竞争等诡异问题。所以在实际工程中,这个姿势并没有广泛普及(包括go源码的单测,很多都没使用这个姿势)。

所以 reviewbot 会继续关闭这个检查项,仅使用 paralleltest 检测可能的其他问题。

参考:

@CarlJi CarlJi added this to the v0.10.1 milestone Jun 4, 2024
@CarlJi
Copy link
Contributor Author

CarlJi commented Jun 7, 2024

fix by #151

@CarlJi CarlJi closed this as completed Jun 7, 2024
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

No branches or pull requests

1 participant