Skip to content

allow testsets without a description #13

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

Merged
merged 1 commit into from
Feb 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/ReTest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export retest, @testset

using Distributed
using Base.Threads: nthreads
using Random: shuffle!
using Random: shuffle!, randstring

# from Test:
export Test,
Expand Down Expand Up @@ -103,7 +103,6 @@ function parse_ts(source, mod, args::Tuple, parent=nothing)
error("unsupported @testset")
end
end
@isdefined(desc) || error("@testset requires a description")

body = args[end]
isa(body, Expr) || error("Expected begin/end block or for loop as argument to @testset")
Expand All @@ -117,10 +116,20 @@ function parse_ts(source, mod, args::Tuple, parent=nothing)
@assert all(arg -> Meta.isexpr(arg, :(=)), loops.args)
loops = loops.args
end

if !@isdefined(desc)
v = loops[1].args[1]
desc = Expr(:string, "anonym $(randstring('0':'9')): $v = ", v)
for l = loops[2:end]
v = l.args[1]
push!(desc.args, ", $v = ", v)
end
end
elseif body.head === :block
loops = nothing
tsbody = body
if !@isdefined(desc)
desc = "anonym $(randstring('0':'9'))"
end
else
error("Expected begin/end block or for loop as argument to @testset")
end
Expand Down
16 changes: 16 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,22 @@ empty!(MultiLoops.RUN)
retest(MultiLoops, "1 1")
@test MultiLoops.RUN == [(1, 1)]

module Anonym
using ReTest

RUN = []

@testset for x=1:2
@testset begin
@test true
push!(RUN, x)
end
end
end

retest(Anonym)
@test Anonym.RUN == [1, 2]

### Failing ##################################################################

module Failing
Expand Down