petergtz / pegomock

Pegomock is a powerful, yet simple mocking framework for the Go programming language
Apache License 2.0
252 stars 28 forks source link

Running `remove` with `-r` causes "too many open files" error #98

Closed jpopadak closed 4 years ago

jpopadak commented 4 years ago

We have a ton of mocks (and matchers) in our project. However, we are getting to the point where we have so many that Pegomock tries to open all the files and remove them at the same time. This causes a too many open files error and does not successfully remove them all.

/Users/james.popadak/gomod/project/ext/tools/bin/pegomock remove -r -n -s ./internal
Could not open file internal/test/matchers/serviceerrorcause.go. Error: open internal/test/matchers/serviceerrorcause.go: too many open files
Could not open file internal/test/matchers/serviceerrorcode.go. Error: open internal/test/matchers/serviceerrorcode.go: too many open files
Could not open file internal/test/matchers/serviceerrormessage.go. Error: open internal/test/matchers/serviceerrormessage.go: too many open files
Could not open file internal/test/matchers/validulid.go. Error: open internal/test/matchers/validulid.go: too many open files
Could not open file internal/test/matchers/validuuid.go. Error: open internal/test/matchers/validuuid.go: too many open files
petergtz commented 4 years ago

Hi @jpopadak, sorry for the slow response. I've been pretty busy. I think I found the root cause. In

https://github.com/petergtz/pegomock/blob/master/pegomock/remove/remove.go#L155-L169

there is a missing Close call. I will see when I get the time to fix it. Feel free to open a PR if you need it quickly and I'll be happy to merge it.