File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -201,6 +201,18 @@ function runtests(
201201 warn_unsupported:: Bool = false ,
202202 exclude_tests_after:: VersionNumber = v " 999.0.0" ,
203203)
204+ tests = filter (n -> startswith (" $n " , " test_" ), names (MOI. Test; all = true ))
205+ tests = string .(tests)
206+ for ex in exclude
207+ if ex in tests && any (t -> ex != t && occursin (ex, t), tests)
208+ @warn (
209+ " The exclude string \" $ex \" is ambiguous because it exactly " *
210+ " matches a test, but it also partially matches another. Use " *
211+ " `r\" ^$ex \$\" ` to exclude the exactly matching test, or " *
212+ " `r\" $ex .*\" ` to exclude all partially matching tests." ,
213+ )
214+ end
215+ end
204216 for name_sym in names (@__MODULE__ ; all = true )
205217 name = string (name_sym)
206218 if ! startswith (name, " test_" )
Original file line number Diff line number Diff line change @@ -110,3 +110,16 @@ MOI.Test.test_attribute_unsupported_constraint(
110110 attr = MOI. NumberOfConstraints {F,S} ()
111111 @test_throws MOI. GetAttributeNotAllowed (attr) MOI. get (model, attr)
112112end
113+
114+ @testset " test_warning_on_ambiguous" begin
115+ model = MOI. Utilities. MockOptimizer (
116+ MOI. Utilities. UniversalFallback (MOI. Utilities. Model {Float64} ()),
117+ )
118+ config = MOI. Test. Config ()
119+ # `test_model_Name`` is our target of interest, `test_` is just to avoid
120+ # running any tests.
121+ exclude = [" test_model_Name" , r" test_.+" ]
122+ @test_logs (:warn ,) MOI. Test. runtests (model, config; exclude = exclude)
123+ exclude = [r" ^test_model_Name$" , r" test_.+" ]
124+ @test_logs MOI. Test. runtests (model, config; exclude = exclude)
125+ end
You can’t perform that action at this time.
0 commit comments