Skip to content

Commit fda8d14

Browse files
committed
Uncomment stuff
1 parent 8623b74 commit fda8d14

File tree

1 file changed

+183
-183
lines changed

1 file changed

+183
-183
lines changed

test/runtests.jl

Lines changed: 183 additions & 183 deletions
Original file line numberDiff line numberDiff line change
@@ -60,189 +60,189 @@ function remove_llvmextras(project_file)
6060
end
6161

6262
@testset "PackageCompiler.jl" begin
63-
# @testset "create_sysimage" begin
64-
# new_project = mktempdir()
65-
# old_project = Base.ACTIVE_PROJECT[]
66-
# Base.ACTIVE_PROJECT[] = new_project
67-
# try
68-
# Pkg.add("Example")
69-
# finally
70-
# Base.ACTIVE_PROJECT[] = old_project
71-
# end
72-
# tmp = mktempdir()
73-
# sysimage_path = joinpath(tmp, "sys." * Libdl.dlext)
74-
# script = tempname()
75-
# write(script, """
76-
# script_func() = println(\"I am a script\")
77-
# opt_during_sysimage = Base.JLOptions().opt_level
78-
# print_opt() = println("opt: -O\$opt_during_sysimage")
79-
# """)
80-
# create_sysimage(; sysimage_path=sysimage_path,
81-
# project=new_project,
82-
# precompile_execution_file=joinpath(@__DIR__, "precompile_execution.jl"),
83-
# precompile_statements_file=joinpath.(@__DIR__, ["precompile_statements.jl",
84-
# "precompile_statements2.jl"]),
85-
# script=script,
86-
# sysimage_build_args = `-O1`
87-
# )
88-
89-
# # Check we can load sysimage and that Example is available in Main
90-
# str = read(`$(Base.julia_cmd()) -J $(sysimage_path) -e 'println(Example.hello("foo")); script_func(); print_opt()'`, String)
91-
# @test occursin("Hello, foo", str)
92-
# @test occursin("I am a script", str)
93-
# @test occursin("opt: -O1", str)
94-
# end # testset
95-
96-
# @testset "create_app" begin
97-
# # Test creating an app
98-
# app_source_dir = joinpath(@__DIR__, "..", "examples/MyApp/")
99-
# app_compiled_dir = joinpath(tmp, "MyAppCompiled")
100-
# if is_slow_ci
101-
# incrementals_list = (true, false)
102-
# else
103-
# incrementals_list = (true, false)
104-
# end
105-
# @testset for incremental in incrementals_list
106-
# if incremental == false
107-
# if is_slow_ci
108-
# @warn "Skipping the (incremental=false, filter_stdlibs=false) test because this is \"slow CI\""
109-
# @test_skip false
110-
# filter_stdlibs = (true,)
111-
# else
112-
# filter_stdlibs = (true, false)
113-
# end
114-
# else
115-
# filter_stdlibs = (false,)
116-
# end
117-
# @testset for filter in filter_stdlibs
118-
# @info "starting: create_app testset" incremental filter
119-
# tmp_app_source_dir = joinpath(tmp, "MyApp")
120-
# cp(app_source_dir, tmp_app_source_dir)
121-
# if is_gha_ci && (is_julia_1_6 || is_julia_1_9)
122-
# # Julia 1.6: Issue #706 "Cannot locate artifact 'LLVMExtra'" on 1.6 so remove.
123-
# # Julia 1.9: There's no GitHub Issue, but it seems we hit a similar problem.
124-
# @test_skip false
125-
# remove_llvmextras(joinpath(tmp_app_source_dir, "Project.toml"))
126-
# end
127-
# try
128-
# create_app(tmp_app_source_dir, app_compiled_dir; incremental=incremental, force=true, filter_stdlibs=filter, include_lazy_artifacts=true,
129-
# precompile_execution_file=joinpath(app_source_dir, "precompile_app.jl"),
130-
# executables=["MyApp" => "julia_main",
131-
# "SecondApp" => "second_main",
132-
# "ReturnType" => "wrong_return_type",
133-
# "Error" => "erroring",
134-
# "Undefined" => "undefined",
135-
# ])
136-
# finally
137-
# rm(tmp_app_source_dir; recursive=true)
138-
# # Get rid of some local state
139-
# rm(joinpath(new_depot, "packages"); recursive=true, force=true)
140-
# rm(joinpath(new_depot, "compiled"); recursive=true, force=true)
141-
# rm(joinpath(new_depot, "artifacts"); recursive=true, force=true)
142-
# end # try
143-
# app_path(app_name) = abspath(app_compiled_dir, "bin", app_name * (Sys.iswindows() ? ".exe" : ""))
144-
# app_output = read(`$(app_path("MyApp")) I get --args --julia-args --threads=3 --check-bounds=yes -O1`, String)
145-
146-
# # Check stdlib filtering
147-
# if filter == true
148-
# @test !(occursin("LinearAlgebra", app_output))
149-
# else
150-
# @test occursin("LinearAlgebra", app_output)
151-
# end
152-
# # Check dependency run
153-
# @test occursin("Example.domath", app_output)
154-
# # Check PROGRAM_FILE
155-
# @test occursin("Base.PROGRAM_FILE = $(repr(app_path("MyApp")))", app_output)
156-
# # Check jll package runs
157-
# @test occursin("Hello, World!", app_output)
158-
# # Check artifact runs
159-
# @test occursin("Artifact printed: Hello, World!", app_output)
160-
# # Check artifact gets run from the correct place
161-
# @test occursin("HelloWorld artifact at $(realpath(app_compiled_dir))", app_output)
162-
# # Check ARGS
163-
# @test occursin("""ARGS = ["I", "get", "--args"]""", app_output)
164-
# # Check julia-args
165-
# @test occursin("(Base.JLOptions()).opt_level = 1", app_output)
166-
# @test occursin("(Base.JLOptions()).nthreads = 3", app_output)
167-
# @test occursin("(Base.JLOptions()).check_bounds = 1", app_output)
168-
# # Check transitive inclusion of dependencies
169-
# @test occursin("is_crayons_loaded() = true", app_output)
170-
# # Check app is precompiled in a normal process
171-
# @test occursin("outputo: ok", app_output)
172-
# @test occursin("myrand: ok", app_output)
173-
# # Check distributed
174-
# @test occursin("n = 20000000", app_output)
175-
# @test occursin("From worker 2:\t8", app_output)
176-
# @test occursin("From worker 3:\t8", app_output)
177-
# @test occursin("From worker 4:\t8", app_output)
178-
# @test occursin("From worker 5:\t8", app_output)
179-
180-
# if is_julia_1_6 || is_julia_1_9
181-
# # Julia 1.6: Issue #706 "Cannot locate artifact 'LLVMExtra'" on 1.6 so remove.
182-
# # Julia 1.9: There's no GitHub Issue, but it seems we hit a similar problem.
183-
# @test_skip false
184-
# else
185-
# @test occursin("LLVMExtra path: ok!", app_output)
186-
# end
187-
# @test occursin("micromamba_jll path: ok!", app_output)
188-
189-
# # Test second app
190-
# app_output = read(`$(app_path("SecondApp"))`, String)
191-
# @test occursin("Hello from second main", app_output)
192-
193-
# io = IOBuffer()
194-
# p = run(pipeline(ignorestatus(`$(app_path("ReturnType"))`), stderr=io;))
195-
# @test occursin("ERROR: expected a Cint return value from function MyApp.wrong_return_type", String(take!(io)))
196-
# @test p.exitcode == 1
197-
198-
# io = IOBuffer()
199-
# p = run(pipeline(ignorestatus(`$(app_path("Error"))`), stderr=io;))
200-
# @test occursin("MethodError: no method matching +(", String(take!(io)))
201-
# @test p.exitcode == 1
202-
203-
# io = IOBuffer()
204-
# p = run(pipeline(ignorestatus(`$(app_path("Undefined"))`), stderr=io;))
205-
# str = String(take!(io))
206-
# @test all(occursin(str), ["UndefVarError:", "undefined", "not defined"])
207-
# @test p.exitcode == 1
208-
# @info "done: create_app testset" incremental filter
209-
# end
210-
# end
211-
# end # testset
212-
213-
# if !is_slow_ci
214-
# # Test library creation
215-
# lib_source_dir = joinpath(@__DIR__, "..", "examples/MyLib")
216-
# lib_target_dir = joinpath(tmp, "MyLibCompiled")
217-
218-
# # This is why we have to skip this test on 1.12:
219-
# incremental = false
220-
221-
# filter = true
222-
# lib_name = "inc"
223-
224-
# tmp_lib_src_dir = joinpath(tmp, "MyLib")
225-
# cp(lib_source_dir, tmp_lib_src_dir)
226-
# create_library(tmp_lib_src_dir, lib_target_dir; incremental=incremental, force=true, filter_stdlibs=filter,
227-
# precompile_execution_file=joinpath(lib_source_dir, "build", "generate_precompile.jl"),
228-
# precompile_statements_file=joinpath(lib_source_dir, "build", "additional_precompile.jl"),
229-
# lib_name=lib_name, version=v"1.0.0")
230-
# rm(tmp_lib_src_dir; recursive=true)
231-
# end
232-
233-
# # Test creating an empty sysimage
234-
# if !is_slow_ci
235-
# tmp = mktempdir()
236-
# sysimage_path = joinpath(tmp, "empty." * Libdl.dlext)
237-
# foreach(x -> touch(joinpath(tmp, x)), ["Project.toml", "Manifest.toml"])
238-
239-
# # This is why we need to skip this test on 1.12:
240-
# incremental=false
241-
242-
# create_sysimage(String[]; sysimage_path=sysimage_path, incremental=incremental, filter_stdlibs=true, project=tmp)
243-
# hello = read(`$(Base.julia_cmd()) -J $(sysimage_path) -e 'print("hello, world")'`, String)
244-
# @test hello == "hello, world"
245-
# end
63+
@testset "create_sysimage" begin
64+
new_project = mktempdir()
65+
old_project = Base.ACTIVE_PROJECT[]
66+
Base.ACTIVE_PROJECT[] = new_project
67+
try
68+
Pkg.add("Example")
69+
finally
70+
Base.ACTIVE_PROJECT[] = old_project
71+
end
72+
tmp = mktempdir()
73+
sysimage_path = joinpath(tmp, "sys." * Libdl.dlext)
74+
script = tempname()
75+
write(script, """
76+
script_func() = println(\"I am a script\")
77+
opt_during_sysimage = Base.JLOptions().opt_level
78+
print_opt() = println("opt: -O\$opt_during_sysimage")
79+
""")
80+
create_sysimage(; sysimage_path=sysimage_path,
81+
project=new_project,
82+
precompile_execution_file=joinpath(@__DIR__, "precompile_execution.jl"),
83+
precompile_statements_file=joinpath.(@__DIR__, ["precompile_statements.jl",
84+
"precompile_statements2.jl"]),
85+
script=script,
86+
sysimage_build_args = `-O1`
87+
)
88+
89+
# Check we can load sysimage and that Example is available in Main
90+
str = read(`$(Base.julia_cmd()) -J $(sysimage_path) -e 'println(Example.hello("foo")); script_func(); print_opt()'`, String)
91+
@test occursin("Hello, foo", str)
92+
@test occursin("I am a script", str)
93+
@test occursin("opt: -O1", str)
94+
end # testset
95+
96+
@testset "create_app" begin
97+
# Test creating an app
98+
app_source_dir = joinpath(@__DIR__, "..", "examples/MyApp/")
99+
app_compiled_dir = joinpath(tmp, "MyAppCompiled")
100+
if is_slow_ci
101+
incrementals_list = (true, false)
102+
else
103+
incrementals_list = (true, false)
104+
end
105+
@testset for incremental in incrementals_list
106+
if incremental == false
107+
if is_slow_ci
108+
@warn "Skipping the (incremental=false, filter_stdlibs=false) test because this is \"slow CI\""
109+
@test_skip false
110+
filter_stdlibs = (true,)
111+
else
112+
filter_stdlibs = (true, false)
113+
end
114+
else
115+
filter_stdlibs = (false,)
116+
end
117+
@testset for filter in filter_stdlibs
118+
@info "starting: create_app testset" incremental filter
119+
tmp_app_source_dir = joinpath(tmp, "MyApp")
120+
cp(app_source_dir, tmp_app_source_dir)
121+
if is_gha_ci && (is_julia_1_6 || is_julia_1_9)
122+
# Julia 1.6: Issue #706 "Cannot locate artifact 'LLVMExtra'" on 1.6 so remove.
123+
# Julia 1.9: There's no GitHub Issue, but it seems we hit a similar problem.
124+
@test_skip false
125+
remove_llvmextras(joinpath(tmp_app_source_dir, "Project.toml"))
126+
end
127+
try
128+
create_app(tmp_app_source_dir, app_compiled_dir; incremental=incremental, force=true, filter_stdlibs=filter, include_lazy_artifacts=true,
129+
precompile_execution_file=joinpath(app_source_dir, "precompile_app.jl"),
130+
executables=["MyApp" => "julia_main",
131+
"SecondApp" => "second_main",
132+
"ReturnType" => "wrong_return_type",
133+
"Error" => "erroring",
134+
"Undefined" => "undefined",
135+
])
136+
finally
137+
rm(tmp_app_source_dir; recursive=true)
138+
# Get rid of some local state
139+
rm(joinpath(new_depot, "packages"); recursive=true, force=true)
140+
rm(joinpath(new_depot, "compiled"); recursive=true, force=true)
141+
rm(joinpath(new_depot, "artifacts"); recursive=true, force=true)
142+
end # try
143+
app_path(app_name) = abspath(app_compiled_dir, "bin", app_name * (Sys.iswindows() ? ".exe" : ""))
144+
app_output = read(`$(app_path("MyApp")) I get --args --julia-args --threads=3 --check-bounds=yes -O1`, String)
145+
146+
# Check stdlib filtering
147+
if filter == true
148+
@test !(occursin("LinearAlgebra", app_output))
149+
else
150+
@test occursin("LinearAlgebra", app_output)
151+
end
152+
# Check dependency run
153+
@test occursin("Example.domath", app_output)
154+
# Check PROGRAM_FILE
155+
@test occursin("Base.PROGRAM_FILE = $(repr(app_path("MyApp")))", app_output)
156+
# Check jll package runs
157+
@test occursin("Hello, World!", app_output)
158+
# Check artifact runs
159+
@test occursin("Artifact printed: Hello, World!", app_output)
160+
# Check artifact gets run from the correct place
161+
@test occursin("HelloWorld artifact at $(realpath(app_compiled_dir))", app_output)
162+
# Check ARGS
163+
@test occursin("""ARGS = ["I", "get", "--args"]""", app_output)
164+
# Check julia-args
165+
@test occursin("(Base.JLOptions()).opt_level = 1", app_output)
166+
@test occursin("(Base.JLOptions()).nthreads = 3", app_output)
167+
@test occursin("(Base.JLOptions()).check_bounds = 1", app_output)
168+
# Check transitive inclusion of dependencies
169+
@test occursin("is_crayons_loaded() = true", app_output)
170+
# Check app is precompiled in a normal process
171+
@test occursin("outputo: ok", app_output)
172+
@test occursin("myrand: ok", app_output)
173+
# Check distributed
174+
@test occursin("n = 20000000", app_output)
175+
@test occursin("From worker 2:\t8", app_output)
176+
@test occursin("From worker 3:\t8", app_output)
177+
@test occursin("From worker 4:\t8", app_output)
178+
@test occursin("From worker 5:\t8", app_output)
179+
180+
if is_julia_1_6 || is_julia_1_9
181+
# Julia 1.6: Issue #706 "Cannot locate artifact 'LLVMExtra'" on 1.6 so remove.
182+
# Julia 1.9: There's no GitHub Issue, but it seems we hit a similar problem.
183+
@test_skip false
184+
else
185+
@test occursin("LLVMExtra path: ok!", app_output)
186+
end
187+
@test occursin("micromamba_jll path: ok!", app_output)
188+
189+
# Test second app
190+
app_output = read(`$(app_path("SecondApp"))`, String)
191+
@test occursin("Hello from second main", app_output)
192+
193+
io = IOBuffer()
194+
p = run(pipeline(ignorestatus(`$(app_path("ReturnType"))`), stderr=io;))
195+
@test occursin("ERROR: expected a Cint return value from function MyApp.wrong_return_type", String(take!(io)))
196+
@test p.exitcode == 1
197+
198+
io = IOBuffer()
199+
p = run(pipeline(ignorestatus(`$(app_path("Error"))`), stderr=io;))
200+
@test occursin("MethodError: no method matching +(", String(take!(io)))
201+
@test p.exitcode == 1
202+
203+
io = IOBuffer()
204+
p = run(pipeline(ignorestatus(`$(app_path("Undefined"))`), stderr=io;))
205+
str = String(take!(io))
206+
@test all(occursin(str), ["UndefVarError:", "undefined", "not defined"])
207+
@test p.exitcode == 1
208+
@info "done: create_app testset" incremental filter
209+
end
210+
end
211+
end # testset
212+
213+
if !is_slow_ci
214+
# Test library creation
215+
lib_source_dir = joinpath(@__DIR__, "..", "examples/MyLib")
216+
lib_target_dir = joinpath(tmp, "MyLibCompiled")
217+
218+
# This is why we have to skip this test on 1.12:
219+
incremental = false
220+
221+
filter = true
222+
lib_name = "inc"
223+
224+
tmp_lib_src_dir = joinpath(tmp, "MyLib")
225+
cp(lib_source_dir, tmp_lib_src_dir)
226+
create_library(tmp_lib_src_dir, lib_target_dir; incremental=incremental, force=true, filter_stdlibs=filter,
227+
precompile_execution_file=joinpath(lib_source_dir, "build", "generate_precompile.jl"),
228+
precompile_statements_file=joinpath(lib_source_dir, "build", "additional_precompile.jl"),
229+
lib_name=lib_name, version=v"1.0.0")
230+
rm(tmp_lib_src_dir; recursive=true)
231+
end
232+
233+
# Test creating an empty sysimage
234+
if !is_slow_ci
235+
tmp = mktempdir()
236+
sysimage_path = joinpath(tmp, "empty." * Libdl.dlext)
237+
foreach(x -> touch(joinpath(tmp, x)), ["Project.toml", "Manifest.toml"])
238+
239+
# This is why we need to skip this test on 1.12:
240+
incremental=false
241+
242+
create_sysimage(String[]; sysimage_path=sysimage_path, incremental=incremental, filter_stdlibs=true, project=tmp)
243+
hello = read(`$(Base.julia_cmd()) -J $(sysimage_path) -e 'print("hello, world")'`, String)
244+
@test hello == "hello, world"
245+
end
246246

247247
@testset "examples/MyLib" begin
248248
# This testset makes sure that the `examples/MyLib` example does not bitrot.

0 commit comments

Comments
 (0)