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_logscreates a fresh logger each time (so they don't have a shared count formaxlog).But at least there is a way to test
maxloglogging statements (as shown in the diff, usingTest.collect_test_logs). AndTest.collect_test_logsis 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_logsis just:This errors on master but passes on this branch.