Skip to content

Commit 180ab6c

Browse files
committed
Try fixing the non-stdlib tests via refactor
In JuliaLang/julia#53922 it was revealed that simply gating the supposition-requiring test behind an if statement was insufficient when a macro is involved in the branch not taken. To try to make this approach work, the current conditional fuzzer-running code was refactored to make the the macro and other code requiring Supposition be nicely contained in a file that's only loaded when NON_STDLIB_TESTS is true. Put another way, we've hoisted the conditional running from an "is the code run?" if-branch to a file-loading if-branch.
1 parent 528f245 commit 180ab6c

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

test/runtests.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ using StyledStrings: StyledStrings, Legacy, SimpleColor, FACES, Face,
77
using .StyledMarkup: MalformedStylingMacro
88
using Base: AnnotatedString, AnnotatedChar, AnnotatedIOBuffer, annotations
99

10-
include("maybefuzz.jl") # For use in the "Styled Markup" testset
10+
const NON_STDLIB_TESTS = Main == @__MODULE__
11+
if NON_STDLIB_TESTS
12+
include("styfuzz.jl") # For use in the "Styled Markup" testset
13+
else
14+
styfuzz() = nothing
15+
end
1116

1217
# For output testing
1318

@@ -424,7 +429,7 @@ end
424429
end
425430

426431
# Markup fuzzing!
427-
maybefuzz()
432+
styfuzz()
428433

429434
@testset "AnnotatedIOBuffer" begin
430435
aio = AnnotatedIOBuffer()
Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

3-
const NON_STDLIB_TESTS = Main == @__MODULE__
3+
# *Not* run as part of the Julia central stdlib testsuite
44

55
const IS_CI = lowercase(get(ENV, "CI", "no")) in ("true", "t", "1", "yes", "y")
66
const PARSER_FILE = joinpath("src", "styledmarkup.jl")
@@ -22,24 +22,18 @@ function hasparserdiverged()
2222
!success(Cmd(`git diff --quiet --diff-filter=M $upstream -- $PARSER_FILE`, dir=PROJECT_DIR))
2323
end
2424

25-
if NON_STDLIB_TESTS
26-
using Supposition
27-
include("fuzz.jl")
28-
using .Fuzzer
29-
end
25+
using Supposition
26+
include("fuzz.jl")
27+
using .Fuzzer
3028

31-
if NON_STDLIB_TESTS
32-
function maybefuzz()
33-
isstyled(s) = StyledStrings.styled(s) isa Base.AnnotatedString
34-
max_examples = if hasparserdiverged()
35-
ifelse(IS_CI, 5_000, 10_000)
36-
else
37-
1_000
38-
end
39-
@testset "Fuzz ($max_examples)" begin
40-
@check max_examples = max_examples isstyled(Fuzzer.content)
41-
end
29+
function styfuzz()
30+
isstyled(s) = StyledStrings.styled(s) isa Base.AnnotatedString
31+
max_examples = if hasparserdiverged()
32+
ifelse(IS_CI, 5_000, 10_000)
33+
else
34+
1_000
35+
end
36+
@testset "Fuzz ($max_examples)" begin
37+
@check max_examples = max_examples isstyled(Fuzzer.content)
4238
end
43-
else
44-
maybefuzz() = nothing
4539
end

0 commit comments

Comments
 (0)