-
-
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
RFC: do not print backtrace for TestSetExceptions and Pkg.test() exception. #19750
Conversation
Wouldn't it be cleaner to use dispatch on exception type to ignore the |
Do you mean to add something like Base.showerror(io::IO, ex::TestSetException, bt) = Base.showerror(io, ex) ? I don't see why |
AV seemingly got stuck: https://gist.github.com/KristofferC/33b0f4544ec790e2f8e11a2adcfeaf8a. Close and repoen to restart tests. |
c1e0125
to
bc0da73
Compare
|
||
let | ||
io = IOBuffer() | ||
Base.showerror(io, Test.TestSetException(1,2,3,4,Vector{Union{Base.Test.Error, Base.Test.Fail}}()), backtrace()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line wrap
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unaddressed
In the case of Pkg.test, I think a |
The full command that Pkg.test runs is still printed. Only the back trace to some arbitrary location in Pkg.Entry is suppressed. |
Explicitly, this is still printed: ===============================[ ERROR: Testpkg ]===============================
failed process: Process(`/home/kristoffer/Downloads/julia-3c9d75391c/bin/julia -Cx86-64 -J/home/kristoffer/Downloads/julia-3c9d75391c/lib/julia/sys.so --compile=yes --depwarn=yes --check-bounds=yes --code-coverage=none --color=yes --compilecache=yes /home/kristoffer/.julia/v0.5/Testpkg/test/runtests.jl`, ProcessExited(1)) [1]
================================================================================ What information do you want from the backtrace I removed? |
Any objections against this? |
The ability to see not just what Pkg.Test runs, but how it gets there. Maybe not shown by default, but make it possible. |
The fact that an exception is thrown is basically a hack so that the process will exit with non zero status if run in noninteractive mode and being able to catch the exception when running in the REPL. To see how arbitrary function gets called, isn't that what you use debuggers for. My point is that, if a |
Most functions don't throw exceptions in the course of doing what they should - or they intentionally catch them. If throwing an exception is a hack, then suppressing the backtrace just for this specific type of exception is putting yet more hacks on top of it. |
Yes. And it gives a significant boost to user experience. I'm not sure I got your point. |
Consider the case where |
The backtrace is an artifact of using an exception, and our normal handling of exceptions. If you're not treating it the way we treat normal exceptions, because you're arguing that it's not exceptional behavior but expected, then it's control flow. At that point it seems like you mostly want to print a message in red and could return the results instead. |
It is "exit status"-control flow. Doing what you suggest would exit the process with the wrong exit code when |
What if a test fails not due to |
There are three backtraces currently being printed when Pkg.test fails. The one you are concerned about is the first one and that one is not touched in the PR. There is another PR dealing with that one #19751. |
Good to go? |
I still don't like the unconditional hiding of information here. |
You are using the word "information" but what is removed here is not any actionable information. It is purely implementation details that accidentally leak to the user during completely normal operation of a function. In fact, for every function that we don't print a backtrace to during normal operations we are "hiding information". And that is a crucial part of delivering a good user experience (which the current one is definitely not). If someone says they want to see the backtrace to where Seems we are at an impasse so opinions from more people would be good to hear. |
Package tests failing arguably aren't normal operation - there was a failure, and it's worth displaying how and where it happened. |
This is not being touched in this PR. The full command to the process running the tests together with the backtrace in that process is printed. |
If a plumber comes to your house and says that a pipe is broken, would you really ask him about the color of his underwear? |
I completely agree with @KristofferC here and this change is a significant improvement. I think we just have to view |
This isn't a try-catch though, it's not alternate behavior. It's throwing an exception but always hiding its particular backtrace because we apparently don't like this piece of information? The thing that caused the exit code to be as desired was an error thrown from inside Pkg. |
How about changing throw(PkgTestError(join(messages, "and"))) to something like print_with_color(Base.error_color(), STDOUT, join(messages, "and"))
!Base.isinteractive() && exit(1) |
Is |
I am not sure, haven't tried it yet. Just trying to make progress. |
57359b6
to
5b5a226
Compare
I implemented my last comment and just stop throwing an exception. Worked as expected and gave the wrong exit status for everything I tried it on. @tkelman is this better now since it doesn't "pun" on exception throwing? |
showerror(io, er, bt) | ||
println(io) | ||
end | ||
Base.showerror(IOContext(STDERR, :limit => true), er, bt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was left out from #19569
Wouldn't that make |
Removed last commit since being able to catch a failing |
I think we should go ahead with this. If we find that there are situations where we actually miss the omitted information, then we can add an option to show it again. |
@@ -396,6 +396,12 @@ end | |||
@test_throws ErrorException @testset "$(error())" begin | |||
end | |||
|
|||
let | |||
io = IOBuffer() | |||
Base.showerror(io, Test.TestSetException(1,2,3,4,Vector{Union{Base.Test.Error, Base.Test.Fail}}()), backtrace()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrap long lines
61adfd7
to
2bf98f7
Compare
2bf98f7
to
fce015b
Compare
Squashed, fixed some of the colors and updated first post with screenshot comparisons to make it more clear what is being changed. |
@KristofferC why is the macro expansion stuff useful to print in the stack trace as well? |
Not all of them are (the first one shows where the test is executed). The other ones are in the same stackframe because of inlining so not sure how to deal with it. |
Appears to not just be the 32-bit failure we've been seeing. |
Now the only failure is the ongoing 32-bit Linux failure. |
Removes the backtraces that points to internal functions that are running tests when these test runners run as expected.
Difference between master and PR
PR:
Master