Skip to content

Commit f0c058a

Browse files
committed
Add a test for #22101
1 parent aadf566 commit f0c058a

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/workspace.jl

+34
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

3+
using Base.Test
4+
35
script = """
46
# Issue #11948
57
f(x) = x+1
@@ -24,3 +26,35 @@ mutable struct Foo end
2426
@assert Tuple{Type{LastMain.Foo}} !== Tuple{Type{Main.Foo}}
2527
"""
2628
run(`$exename --startup-file=no -e $script2`)
29+
30+
# Issue #22101
31+
mktempdir() do dir
32+
withenv("JULIA_DEBUG_LOADING" => nothing) do
33+
# We need to ensure that the module does a nontrivial amount of work during precompilation
34+
write(joinpath(dir, "Test22101.jl"), """
35+
__precompile__()
36+
module Test22101
37+
export f22101
38+
f22101() = collect(1:10)
39+
f22101()
40+
end
41+
""")
42+
write(joinpath(dir, "testdriver.jl"), """
43+
insert!(LOAD_PATH, 1, $(repr(dir)))
44+
insert!(Base.LOAD_CACHE_PATH, 1, $(repr(dir)))
45+
try
46+
using Test22101
47+
f22101()
48+
workspace()
49+
using Test22101
50+
finally
51+
splice!(LOAD_PATH, 1)
52+
splice!(Base.LOAD_CACHE_PATH, 1)
53+
end
54+
exit(isdefined(Main, :f22101) ? 0 : 1)
55+
""")
56+
# Ensure that STDIO doesn't get swallowed (helps with debugging)
57+
cmd = `$(Base.julia_cmd()) --startup-file=no --precompile=yes $(joinpath(dir, "testdriver.jl"))`
58+
@test success(pipeline(cmd, stdout=STDOUT, stderr=STDERR))
59+
end
60+
end

0 commit comments

Comments
 (0)