-
-
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
Add the ability to use function calls in @testset
directly.
#42518
Add the ability to use function calls in @testset
directly.
#42518
Conversation
stdlib/Test/src/Test.jl
Outdated
desc, testsettype, options = parse_testset_args(args[1:end-1]) | ||
if desc === nothing | ||
desc = "test set" | ||
end | ||
if tests.head === :call | ||
desc = string(tests.args[1]) # use the function name as test name |
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.
Unsure if this is the correct way to deal with getting a string of the function name here.
no idea what's going on with the |
I don't know what's going on with the failing package jobs, but I think this is ready for review now. |
Small bump - would be nice to get some feedback here, whether this is desired for Base etc. I think it could improve modularization of testsuites & runnability of single tests quite a bit, without requiring something heavier. |
Triage approves! Just needs a rebase. |
This allows for easier factoring of tests into functions, making it possible to `include` a `test/runtests.jl` file without running tests directly and enabling running of specific testsets explicitly.
fa7293d
to
5b655b4
Compare
Rebased on current master! Let's see if we can get a green CI run. |
Well FreeBSD didn't want to play nice, but everything else passed. I hope this can be merged before it needs another rebase :) |
freebsd tests aren't your fault. |
…JuliaLang#42518)" This reverts commit a23aa79.
Slipped on the |
Just noted that this feature allows
which currently requires |
Yes, |
…ang#42518) * Add the ability to use function calls in @testset This allows for easier factoring of tests into functions, making it possible to `include` a `test/runtests.jl` file without running tests directly and enabling running of specific testsets explicitly. * Fix doctest of @testset on functions * Add note about naming of testset for called functions * Tweak documentation, expand on intended use case * Add NEWS.md entry * Fix explicit description behavior, add documentation to docstring Co-authored-by: Sukera <[email protected]>
…ang#42518) * Add the ability to use function calls in @testset This allows for easier factoring of tests into functions, making it possible to `include` a `test/runtests.jl` file without running tests directly and enabling running of specific testsets explicitly. * Fix doctest of @testset on functions * Add note about naming of testset for called functions * Tweak documentation, expand on intended use case * Add NEWS.md entry * Fix explicit description behavior, add documentation to docstring Co-authored-by: Sukera <[email protected]>
This allows for easier factoring of tests into functions, making it possible to
include
atest/runtests.jl
file without running tests directly (should it be written with this in mind) and enabling running of specific testsets explicitly by calling the functions they're defined in instead.For example, this PR makes the following work:
with output:
If a description string is provided, it will be used instead of the function name.
In case of a failure (e.g. by running
@testset g(0)
):The change was surprisingly minimal and I think it just.. works? Rudimentary testing in the REPL as well as those written tests included here didn't provide any obvious footguns, so I'm inclined to say this is a good idea.
Nevertheless, this is still missing a NEWS.md entry, docs could/should be more extensive and I may have missed something, so I'm opening this as a draft.