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

Have @testset run conditionally on ARGS? #32715

Open
antoine-levitt opened this issue Jul 28, 2019 · 3 comments
Open

Have @testset run conditionally on ARGS? #32715

antoine-levitt opened this issue Jul 28, 2019 · 3 comments
Labels
testsystem The unit testing framework and Test stdlib

Comments

@antoine-levitt
Copy link
Contributor

I was looking into running only a subset of tests. There is now functionality in Pkg for doing that by passing a list of tests to run to runtests.jl (JuliaLang/Pkg.jl#1226). The suggested workflow is that runtests.jl does the subsetting manually with something like

using HelloWorld
using Test

@testset "HelloWorld.jl" begin
    if isempty(ARGS) || "all" in ARGS
        all_tests = true
    else
        all_tests = false
    end
    if all_tests || "foo" in ARGS
        @testset "foo" begin
            @test HelloWorld.foo(1) == 2
        end
    end
    if all_tests || "bar" in ARGS
        @testset "bar" begin
            @test HelloWorld.bar(2) == 6
        end
    end
    if all_tests || "baz" in ARGS
        @testset "baz" begin
            @test HelloWorld.baz(3) == 12
        end
    end
end

That's a lot of boilerplate. Of course I can redefine my own @testset-like macro to check ARGS, but can't that be done by @testset itself? What I'm suggesting is that @testset checks if ARGS is non-empty and, if it is, only run the test if the string is in ARGS. It is breaking, though...

@fredrikekre
Copy link
Member

fredrikekre commented Jul 28, 2019

Fixed by JuliaLang/Pkg.jl#1226 (merged two days ago).

@fredrikekre
Copy link
Member

fredrikekre commented Jul 28, 2019

Eh, okay, this is a request to add filtering to the Test stdlib I guess, could also be trivially implemented in a package.

@rfourquet
Copy link
Member

Maybe #33672 would fix this issue, albeit with a different mechanism?

@brenhinkeller brenhinkeller added the testsystem The unit testing framework and Test stdlib label Nov 20, 2022
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

No branches or pull requests

4 participants