-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
🐛 Panic instead of Exit in FakeClient #232
Conversation
/label 🐛 |
(No idea how this label thing is supposed to work) |
Your title is correct. LMK if I can make the wording clearer, or just submit a PR ;-). We can also but the PR title is the important one here. |
Hmm... I think this is probably fine. We set up all of our loggers to log to the GinkgoSetup in our tests, but you do actually have to do that manually. Honestly, I'd prefer a bit to make it easier to just set up logging for tests, since you should always do that (you either want to have Zap dump to GinkgoWriter, like we do in CR, or point the loggers at a |
|
It's clear, I was just surprised by the appearance of
Great!
knative/eventing uses logr to set up the manager's internal logging in the main entry point. All other logging is plain Zap, testing is stdlib, and tests don't involve the manager at all. It's fine for the CR tests to be opinionated about how testing or logging works, but the fake client is in a different category IMO. It's support code needed by every user of the real client, and thus should have the same level of pluggability as the real client. |
I totally get why this is missing from logr but it is a little painful to not have the |
(Having said all the above, I'd like to see what changes you'd recommend to make it easier to set up logging for tests 😺) |
honestly, the panic is probably fine here :-). I'm tempted to just merge this.
Sure. The idea is that logr is that plugability -- if you're using stdlib, you can just do
If you're using Ginkgo, and want to get the full zap output with traces, you can do |
Btw, looks like you've got some vet errors. If you fix them we can merge this. |
Nice, that's useful to know about! Fixed the vet error. |
I hit the same issue and had a very hard time debugging it, as I couldn't find any flags to get |
Fixes #354 @anthonyho007 independently created #373 to fix this. |
User code may use this fake client in tests without setting up logging, making errors here extremely difficult to track down. Panic logs more reliably with better debugging details.
Rebased to latest master. This passes tests locally so I'm not sure why it's failing on Travis. |
Passed this time 😄 Friendly ping @DirectXMan12. |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: DirectXMan12, grantr The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
User code may use this fake client in tests without setting up logging, making errors here extremely difficult to track down. Panic logs more reliably with better debugging details.
I didn't change any of the other
os.Exit(1)
calls, since they're in CR's own tests. I'd love to know why the tests don't use panic generally. Is it to eliminate the option to recover?