Skip to content

Commit 3a64df6

Browse files
committed
Uncomment stuff
1 parent 2ac10ef commit 3a64df6

File tree

1 file changed

+183
-183
lines changed

1 file changed

+183
-183
lines changed

test/runtests.jl

+183-183
Original file line numberDiff line numberDiff line change
@@ -59,189 +59,189 @@ function remove_llvmextras(project_file)
5959
end
6060

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

246246
@testset "examples/MyLib" begin
247247
include("examples_mylib.jl")

0 commit comments

Comments
 (0)