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

Print the stacktrace for wrong error when testing @test_throws #50886

Merged
merged 3 commits into from
Aug 24, 2023

Conversation

gbaraldi
Copy link
Member

Makes #20306 a bit better
prints

julia> @test_throws ErrorException f(1.0) == 1
Test Failed at REPL[4]:1
  Expression: f(1.0) == 1
    Expected: ErrorException
      Thrown: MethodError
      MethodError: no method matching f(::Float64)
      
      Closest candidates are:
        f(::Int64)
         @ Main REPL[3]:1
      
      Stacktrace:
       [1] macro expansion
         @ REPL[4]:1 [inlined]
       [2] macro expansion
         @ ~/julia4/usr/share/julia/stdlib/v1.11/Test/src/Test.jl:773 [inlined]
       [3] top-level scope
         @ REPL[4]:1

ERROR: There was an error during testing

where it used to

julia> @test_throws ErrorException f(1.0) == 1
Test Failed at REPL[3]:1
  Expression: f(1.0) == 1
    Expected: ErrorException
      Thrown: MethodError

ERROR: There was an error during testing

@gbaraldi gbaraldi changed the title Print the stacktrace for wrong error when testing Print the stacktrace for wrong error when testing @test_throws Aug 11, 2023
@brenhinkeller brenhinkeller added testsystem The unit testing framework and Test stdlib domain:display and printing Aesthetics and correctness of printed representations of objects. labels Aug 11, 2023
@gbaraldi
Copy link
Member Author

Bump!

Copy link
Sponsor Member

@IanButterworth IanButterworth left a comment

Choose a reason for hiding this comment

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

SGTM!

stdlib/Test/src/Test.jl Outdated Show resolved Hide resolved
Co-authored-by: Ian Butterworth <i.r.butterworth@gmail.com>
@IanButterworth IanButterworth merged commit 4ac6b05 into master Aug 24, 2023
6 checks passed
@IanButterworth IanButterworth deleted the gb/test-throw-stack branch August 24, 2023 20:06
vchuravy pushed a commit to JuliaLang/Test.jl that referenced this pull request Oct 7, 2023
…iaLang/julia#50886)

Co-authored-by: Ian Butterworth <i.r.butterworth@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:display and printing Aesthetics and correctness of printed representations of objects. testsystem The unit testing framework and Test stdlib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants