Coder Social home page Coder Social logo

Support t.Parallel? about goleak HOT 7 CLOSED

uber-go avatar uber-go commented on July 26, 2024 2
Support t.Parallel?

from goleak.

Comments (7)

prashantv avatar prashantv commented on July 26, 2024 1

I think adding testing.(*T).Parallel is reasonable for ignoring tests that are queued to be run later.

I don't think we can support goroutine verification in parallel tests though, since goleak verified all running goroutines, and in parallel tests, the end of a single test may still have many other goroutines running from other tests.

from goleak.

prashantv avatar prashantv commented on July 26, 2024 1

I don't think there is a good solution for detecting goroutine leaks from a test when using t.Parallel since it's intentionally running with other tests which will definitely have their own running goroutines, and we cannot identify which goroutines are started by which test.

However, there is a workaround: Use the TestMain integration in the package,

func TestMain(m *testing.M) {
	goleak.VerifyTestMain(m)
}

This will verify that there's no leaks after all tests are run.

from goleak.

houqp avatar houqp commented on July 26, 2024

Got hit by the same issue, is there any reason not to add t.Parallel to the whitelist?

from goleak.

zchee avatar zchee commented on July 26, 2024

/cc @prashantv

from goleak.

zchee avatar zchee commented on July 26, 2024

@prashantv Thanks for the polite answer. I totally agreed with your thought.
I wait for merge #25 pull request :D

from goleak.

houqp avatar houqp commented on July 26, 2024

I think that's reasonable and the behavior should probably be documented :)

In our cases, the tests we run in parallel don't create extra go routines at all, so goleak should still be able to handle it. That said, I think our use-case is probably a pretty restricted edge-case ;)

from goleak.

bwplotka avatar bwplotka commented on July 26, 2024

Is t.Parrallel() something reasonable as a feature request though?

It would be really nice to join forces to finally have solution to this: detection of leak go routines and parallel tests. (:

Related discussion: fortytw2/leaktest#4

from goleak.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.