Skip to content

Commit c718376

Browse files
authored
fix escaping in testset with options (#37641)
1 parent 26e38cc commit c718376

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

stdlib/Test/src/Test.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,7 +1237,7 @@ function parse_testset_args(args)
12371237
elseif isa(arg, Expr) && arg.head === :(=)
12381238
# we're building up a Dict literal here
12391239
key = Expr(:quote, arg.args[1])
1240-
push!(options.args, Expr(:call, :(=>), key, arg.args[2]))
1240+
push!(options.args, Expr(:call, :(=>), key, esc(arg.args[2])))
12411241
else
12421242
error("Unexpected argument $arg to @testset")
12431243
end

stdlib/Test/test/runtests.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,13 @@ for i in 1:6
566566
@test typeof(tss[i].results[4].results[1]) == (iseven(i) ? Pass : Fail)
567567
end
568568

569+
# test that second argument is escaped correctly
570+
foo = 3
571+
tss = @testset CustomTestSet foo=foo "custom testset - escaping" begin
572+
@test true
573+
end
574+
@test tss.foo == 3
575+
569576
# test @inferred
570577
uninferrable_function(i) = (1, "1")[i]
571578
uninferrable_small_union(i) = (1, nothing)[i]

0 commit comments

Comments
 (0)