-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 TestLogger respect maxlog
#43641
Conversation
This could perhaps break someone's test, but it seems unlikely. I think generally we have chosen not to parse the arguments in the TestLogger, so that the test has a true precise record of what was called (for example, we also ignore the minlevel). But it sounds like #41625 has support for changing this particular behavior. |
Yes, I think this change is a bit questionable in that respect — perhaps a neater strategy would be to enhance the pattern matching in |
What would you suggest? Alternatively, I wonder how much one can really access the log events recorded via the public API- perhaps exposing a richer interface would let users test things like maxlog without needing special handling here. I’ve found |
This reverts commit 02f7332.
@vtjnash that's not true, right? julia/stdlib/Test/src/logging.jl Line 34 in 942697f
julia> Test.collect_test_logs() do
@debug "hi"
end
(Test.LogRecord[], nothing) |
Ah, apparently I was wrong |
Fixes #41625, borrowing some code from SimpleLogger and ConsoleLogger.
Note that this still doesn't work:
since
@test_logs
creates a fresh logger each time (so they don't have a shared count formaxlog
).But at least there is a way to test
maxlog
logging statements (as shown in the diff, usingTest.collect_test_logs
). AndTest.collect_test_logs
is possibly part of the public API since it is referenced from@test_logs
? Although it doesn't have a docstring and isn't in the manual.Edit: actually a better way to test this using only
@test_logs
is just:This errors on master but passes on this branch.