Skip to content

Commit

Permalink
Allow using an unexported custom AbstractTestSet in @testset (#53212
Browse files Browse the repository at this point in the history
)

Co-authored-by: Sukera <Seelengrab@users.noreply.github.com>
  • Loading branch information
Seelengrab and Seelengrab authored Feb 8, 2024
1 parent 667cdde commit 3dadada
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion stdlib/Test/src/Test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1731,7 +1731,8 @@ function parse_testset_args(args)
options = :(Dict{Symbol, Any}())
for arg in args
# a standalone symbol is assumed to be the test set we should use
if isa(arg, Symbol)
# the same is true for a symbol that's not exported from a module
if isa(arg, Symbol) || Base.isexpr(arg, :.)
testsettype = esc(arg)
# a string is the description
elseif isa(arg, AbstractString) || (isa(arg, Expr) && arg.head === :string)
Expand Down
18 changes: 18 additions & 0 deletions stdlib/Test/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1586,3 +1586,21 @@ end
@testset "Docstrings" begin
@test isempty(Docs.undocumented_names(Test))
end

module CustomTestSetModule
using Test
struct CustomTestSet <: Test.AbstractTestSet
description::String
end
Test.record(::CustomTestSet, result) = result
Test.finish(cts::CustomTestSet) = cts
end

@testset "Unexported custom TestSet" begin
using .CustomTestSetModule
let res = @testset CustomTestSetModule.CustomTestSet begin
@test true
end
@test res isa CustomTestSetModule.CustomTestSet
end
end

0 comments on commit 3dadada

Please sign in to comment.