@@ -3,21 +3,21 @@ using SafeTestsets
33@safetestset " Clean implementation (non-trimmable)" begin
44 using JET
55 using SciMLBase: successful_retcode
6- include (" clean_optimization .jl" )
7- @test successful_retcode (minimize (1.0 ). retcode)
8- # can't use `@test_opt` macro here because it would eval before `using JET`
9- # is processed
10- test_opt (minimize, (typeof (1.0 ),))
6+ include (" optimization_clean .jl" )
7+ @test successful_retcode (TestModuleClean . minimize (1.0 ). retcode)
8+ # can't use `@test_opt` macro here because it would try to eval before
9+ # `using JET` is processed
10+ test_opt (TestModuleClean . minimize, (typeof (1.0 ),))
1111end
1212
1313@safetestset " Trimmable implementation" begin
1414 using JET
1515 using SciMLBase: successful_retcode
16- include (" trimmable_optimization .jl" )
17- @test successful_retcode (minimize (1.0 ). retcode)
18- # can't use `@test_opt` macro here because it would eval before `using JET`
19- # is processed
20- test_opt (minimize, (typeof (1.0 ),))
16+ include (" optimization_trimmable .jl" )
17+ @test successful_retcode (TestModuleClean . minimize (1.0 ). retcode)
18+ # can't use `@test_opt` macro here because it would try to eval before
19+ # `using JET` is processed
20+ test_opt (TestModuleTrimmable . minimize, (typeof (1.0 ),))
2121end
2222
2323@safetestset " Run trim" begin
4343 )
4444 )
4545 @test isfile (JULIAC)
46- binpath = tempname ()
47- cmd = ` $(Base. julia_cmd ()) --project=. --depwarn=error $(JULIAC) --experimental --trim=unsafe-warn --output-exe $(binpath) main.jl`
4846
49- # since we are calling Julia from Julia, we first need to clean some
50- # environment variables
51- clean_env = copy (ENV )
52- delete! (clean_env, " JULIA_PROJECT" )
53- delete! (clean_env, " JULIA_LOAD_PATH" )
54- # We could just check for success, but then failures are hard to debug.
55- # Instead we use `_execute` to also capture `stdout` and `stderr`.
56- # @test success(setenv(cmd, clean_env))
57- trimcall = _execute (setenv (cmd, clean_env; dir = @__DIR__ ))
58- if trimcall. exitcode != 0
59- @show trimcall. stdout
60- @show trimcall. stderr
47+ for (mainfile, shouldpass) in [(" main_trimmable.jl" , true ),
48+ (" main_clean.jl" , false )]
49+ binpath = tempname ()
50+ cmd = ` $(Base. julia_cmd ()) --project=. --depwarn=error $(JULIAC) --experimental --trim=unsafe-warn --output-exe $(binpath) $(mainfile) `
51+
52+ # since we are calling Julia from Julia, we first need to clean some
53+ # environment variables
54+ clean_env = copy (ENV )
55+ delete! (clean_env, " JULIA_PROJECT" )
56+ delete! (clean_env, " JULIA_LOAD_PATH" )
57+ # We could just check for success, but then failures are hard to debug.
58+ # Instead we use `_execute` to also capture `stdout` and `stderr`.
59+ # @test success(setenv(cmd, clean_env))
60+ trimcall = _execute (setenv (cmd, clean_env; dir = @__DIR__ ))
61+ if trimcall. exitcode != 0 && shouldpass
62+ @show trimcall. stdout
63+ @show trimcall. stderr
64+ end
65+ @test trimcall. exitcode == 0 broken= ! shouldpass
66+ @test isfile (binpath) broken= ! shouldpass
67+ @test success (` $(binpath) 1.0` ) broken= ! shouldpass
6168 end
62- @test trimcall. exitcode == 0
63- @test isfile (binpath)
64- @test success (` $(binpath) 1.0` )
6569end
0 commit comments