File tree Expand file tree Collapse file tree 1 file changed +18
-8
lines changed
Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -33,15 +33,25 @@ MODULES_TO_TEST = get(
3333 " General;Benchmarks;Bridges;Bridges/Constraint;Bridges/Objective;Bridges/Variable;FileFormats;Nonlinear;Test;Utilities" ,
3434)
3535
36+ function include_with_method_redefinition_check (jl_filename)
37+ stderr_filename = tempname ()
38+ open (stderr_filename, " w" ) do io
39+ return redirect_stderr (() -> include (jl_filename), io)
40+ end
41+ contents = read (stderr_filename, String)
42+ print (stderr , contents)
43+ warnings = findall (
44+ r" WARNING: Method definition (.+?) in module (.+?) at (.+?) overwritten at (.+?)\n " ,
45+ contents,
46+ )
47+ if isempty (warnings)
48+ error (" Found overwritten method" )
49+ end
50+ return
51+ end
52+
3653for submodule in split (MODULES_TO_TEST, " ;" )
37- # This `test_nowarn` checks for warnings that get thrown when we include a
38- # method twice by mistake:
39- # WARNING: Method definition test_foo() in module TestFoo
40- # These warnings are thrown only if Julia is started with
41- # julia --warn-overwrite=yes
42- # The entire test file is run, and then the warnings are checked on exit
43- # from `include()`.
44- Test. @test_nowarn include (" $(submodule) /runtests.jl" )
54+ include_with_method_redefinition_check (" $submodule /runtests" )
4555 GC. gc () # Force GC run here to reduce memory pressure
4656end
4757
You can’t perform that action at this time.
0 commit comments