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

Restore support for checking for UndefVarError variable name in at-test_throws #56231

Conversation

nickrobinson251
Copy link
Contributor

@nickrobinson251 nickrobinson251 commented Oct 18, 2024

Fix #54082

Arguably this was a breaking change (as a consequence of #51979). But regardless, it seems like useful functionality to have a public API for testing that an UndefVarError was thrown for the expected variable name (regardless of scope). This is particularly useful if you don't know what the scope is (for example, in my use-case i want to test that a specific UndefVarError is thrown from a module with a gensym'd name).

Pre-v1.11 the syntax for this was

@test_throws UndefVarError(:x) foo()

but that stopped working in v1.11 when UndefVarError got a second field (in fact in v1.11.1 this is an error when before it would pass)

This PR restores that functionality.

We might want to backport it to v1.11.x so that v1.11 isn't the only version that doesn't support this.

@vtjnash vtjnash added testsystem The unit testing framework and Test stdlib merge me PR is reviewed. Merge when all tests are passing backport 1.11 Change should be backported to release-1.11 labels Oct 18, 2024
@nickrobinson251 nickrobinson251 force-pushed the npr-testthrows-undefvarerr-var-match branch from 46b3997 to 3520ff8 Compare October 18, 2024 21:52
@giordano giordano merged commit b0c1525 into JuliaLang:master Oct 19, 2024
7 checks passed
@giordano giordano removed the merge me PR is reviewed. Merge when all tests are passing label Oct 19, 2024
giordano pushed a commit that referenced this pull request Oct 19, 2024
…st_throws (#56231)

Fix #54082

Arguably this was a breaking change (as a consequence of
#51979). But regardless, it seems
like useful functionality to have a public API for testing that an
`UndefVarError` was thrown for the expected variable name (regardless of
scope). This is particularly useful if you don't know what the scope is
(for example, in my use-case i want to test that a specific
`UndefVarError` is thrown from a module with a `gensym`'d name).

Pre-v1.11 the syntax for this was
```julia
@test_throws UndefVarError(:x) foo()
```
but that stopped working in v1.11 when `UndefVarError` got a second
field (in fact in v1.11.1 this is an error when before it would pass)

This PR restores that functionality.

We might want to backport it to v1.11.x so that v1.11 isn't the only
version that doesn't support this.

(cherry picked from commit b0c1525)
@giordano giordano removed the backport 1.11 Change should be backported to release-1.11 label Oct 19, 2024
KristofferC pushed a commit that referenced this pull request Oct 21, 2024
…st_throws (#56231)

Fix #54082 

Arguably this was a breaking change (as a consequence of
#51979). But regardless, it seems
like useful functionality to have a public API for testing that an
`UndefVarError` was thrown for the expected variable name (regardless of
scope). This is particularly useful if you don't know what the scope is
(for example, in my use-case i want to test that a specific
`UndefVarError` is thrown from a module with a `gensym`'d name).

Pre-v1.11 the syntax for this was 
```julia
@test_throws UndefVarError(:x) foo()
```
but that stopped working in v1.11 when `UndefVarError` got a second
field (in fact in v1.11.1 this is an error when before it would pass)

This PR restores that functionality.

We might want to backport it to v1.11.x so that v1.11 isn't the only
version that doesn't support this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testsystem The unit testing framework and Test stdlib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change in behavior of UndefVarError(::Symbol) constructor breaks @test_throws in 1.11.0-beta1
3 participants