Skip to content

Commit 1533037

Browse files
committed
Check whether Base.isprecompiled is defined, instead of version number
1 parent 2393335 commit 1533037

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

test/runtests.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,20 @@ up_path = joinpath(@__DIR__, "UsesPreferences")
8888
function did_precompile(output)
8989
# TODO: When we support only Julia v1.10+, remove this function and
9090
# only use `Base.isprecompiled` to check this.
91+
isdefined(Base, :isprecompiled) ||
9192
occursin("Precompiling UsesPreferences [$(string(up_uuid))]", output) ||
9293
occursin("Precompiling\e[22m\e[39m UsesPreferences", output) ||
9394
occursin(r"\e\[32m +✓ +\e\[39mUsesPreferences", output)
9495
end
9596
cuda_test_base = """
9697
using UsesPreferences
97-
VERSION >= v"1.10" && @test Base.isprecompiled(Base.identify_package("UsesPreferences"))
98+
isdefined(Base, :isprecompiled) && @test Base.isprecompiled(Base.identify_package("UsesPreferences"))
9899
@test UsesPreferences.backend == "CUDA"
99100
"""
100101
cuda_test_did_precompile = """
101102
using Test
102103
# Make sure `UsesPreferences` has to be recompiled
103-
VERSION >= v"1.10" && @test !Base.isprecompiled(Base.identify_package("UsesPreferences"))
104+
isdefined(Base, :isprecompiled) && @test !Base.isprecompiled(Base.identify_package("UsesPreferences"))
104105
""" * cuda_test_base
105106
output = activate_and_run(up_path, cuda_test_did_precompile; env=Dict("JULIA_DEBUG" => "loading"))
106107
@test did_precompile(output)
@@ -109,7 +110,7 @@ up_path = joinpath(@__DIR__, "UsesPreferences")
109110
cuda_test_didnt_precompile = """
110111
using Test
111112
# Make sure `UsesPreferences` is already precompiled
112-
VERSION >= v"1.10" && @test Base.isprecompiled(Base.identify_package("UsesPreferences"))
113+
isdefined(Base, :isprecompiled) && @test Base.isprecompiled(Base.identify_package("UsesPreferences"))
113114
""" * cuda_test_base
114115
output = activate_and_run(up_path, cuda_test_didnt_precompile; env=Dict("JULIA_DEBUG" => "loading"))
115116
@test !did_precompile(output)
@@ -129,9 +130,9 @@ up_path = joinpath(@__DIR__, "UsesPreferences")
129130
username_test = """
130131
using Test
131132
# Make sure `UsesPreferences` is already precompiled
132-
VERSION >= v"1.10" && @test Base.isprecompiled(Base.identify_package("UsesPreferences"))
133+
isdefined(Base, :isprecompiled) && @test Base.isprecompiled(Base.identify_package("UsesPreferences"))
133134
using UsesPreferences, Preferences
134-
VERSION >= v"1.10" && @test Base.isprecompiled(Base.identify_package("UsesPreferences"))
135+
isdefined(Base, :isprecompiled) && @test Base.isprecompiled(Base.identify_package("UsesPreferences"))
135136
@test UsesPreferences.get_username() == "giordano"
136137
"""
137138
output = activate_and_run(up_path, username_test; env=Dict("JULIA_DEBUG" => "loading"))

0 commit comments

Comments
 (0)