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

Make DPanic fatal in zaptest #1274

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

WGH-
Copy link

@WGH- WGH- commented Apr 17, 2023

The intention of DPanic is to catch errors that should never happen. Unless you added zaptest.WrapOptions(zap.Development()), they were previously silently ignored.

The downside of this change, however, that it's impossible to disable development mode for zaptest logger.

The intention of DPanic is to catch errors that should never happen.
Unless you added zaptest.WrapOptions(zap.Development()), they were
previously silently ignored.

The downside of this change, however, that it's impossible to _disable_
development mode for zaptest logger.
@CLAassistant
Copy link

CLAassistant commented Apr 17, 2023

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot commented Apr 17, 2023

Codecov Report

Merging #1274 (377e39f) into master (845ca51) will decrease coverage by 0.16%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1274      +/-   ##
==========================================
- Coverage   98.08%   97.93%   -0.16%     
==========================================
  Files          50       50              
  Lines        3240     3242       +2     
==========================================
- Hits         3178     3175       -3     
- Misses         53       57       +4     
- Partials        9       10       +1     
Impacted Files Coverage Δ
zaptest/logger.go 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Collaborator

@abhinav abhinav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I agree that the zaptest logger should panic/run in development mode. This was an oversight. For opting out, we could maybe add a zaptest.LoggerOption that allows setting it to false?

zaptest.NewLogger(t) // will panic
zaptest.NewLogger(t, zaptest.Development(false)) // won't panic

There's a question of whether this is a breaking change, though.
Based on the intent of this API, I would consider this more a bugfix than a breaking change, but I'd like to hear thoughts on this from other maintainers.

CC @sywhang @mway @prashantv

@sywhang
Copy link
Contributor

sywhang commented Aug 19, 2023

IMO this is a breaking change in behavior; but since this will only affect tests I think it might be worth considering.

Adding an option for opting out of the panic behavior would save many people from suddenly seeing a bunch of their tests break so I'm +1 on that suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants